From 22548dda2c73f9a81ff0c2e5bc14508d46e24cdf Mon Sep 17 00:00:00 2001 From: Erwan Carriou Date: Wed, 4 Jul 2018 23:36:44 +0200 Subject: [PATCH] Bump 2.9.0 --- designer/app/index.html | 2 +- designer/behavior.html | 2 +- designer/component.html | 2 +- designer/diagram.html | 55 +++ designer/index.html | 2 +- designer/lib/designer/vendor.js | 56 ++- designer/lib/diagram/vendor.js | 446 ++++++++++++++++++ designer/lib/editor/vendor.js | 2 +- .../lib/system-runtime/system-runtime.min.js | 2 +- designer/model.html | 2 +- designer/schema.html | 2 +- designer/scripts/designer-runtime.js | 2 +- designer/scripts/diagram.js | 3 + designer/scripts/editor-behavior.js | 2 +- designer/scripts/editor-component.js | 2 +- designer/scripts/editor-model.js | 2 +- designer/scripts/editor-schema.js | 2 +- designer/scripts/editor-system.js | 2 +- designer/scripts/editor-type.js | 2 +- designer/scripts/system-designer.js | 2 +- designer/styles/designer.css | 6 + designer/styles/diagram.css | 443 +++++++++++++++++ designer/system.html | 2 +- designer/type.html | 2 +- package.json | 8 +- 25 files changed, 1005 insertions(+), 48 deletions(-) create mode 100644 designer/diagram.html create mode 100644 designer/lib/diagram/vendor.js create mode 100644 designer/scripts/diagram.js create mode 100644 designer/styles/diagram.css diff --git a/designer/app/index.html b/designer/app/index.html index 249b82d..3e02bc0 100644 --- a/designer/app/index.html +++ b/designer/app/index.html @@ -1,5 +1,5 @@ - + Loading... diff --git a/designer/behavior.html b/designer/behavior.html index e58abfc..002763c 100644 --- a/designer/behavior.html +++ b/designer/behavior.html @@ -1,5 +1,5 @@ - + diff --git a/designer/component.html b/designer/component.html index 6a6cec2..e67355f 100644 --- a/designer/component.html +++ b/designer/component.html @@ -1,5 +1,5 @@ - + diff --git a/designer/diagram.html b/designer/diagram.html new file mode 100644 index 0000000..bcdca2c --- /dev/null +++ b/designer/diagram.html @@ -0,0 +1,55 @@ + + + + + + + + + class diagram · system + + + + + + + + + +
+
+
+ + +
+
+ +
+ +
+ +
+
+ + + + + + + + + \ No newline at end of file diff --git a/designer/index.html b/designer/index.html index c015616..f7fc778 100644 --- a/designer/index.html +++ b/designer/index.html @@ -1,5 +1,5 @@ - + diff --git a/designer/lib/designer/vendor.js b/designer/lib/designer/vendor.js index a65fc25..56d42fb 100644 --- a/designer/lib/designer/vendor.js +++ b/designer/lib/designer/vendor.js @@ -11,7 +11,6 @@ this.activeTarget=b,this.clear();var c=this.selector+'[data-target="'+b+'"],'+th !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.GitHub=e()}}(function(){var e;return function e(t,r,n){function o(u,s){if(!r[u]){if(!t[u]){var a="function"==typeof require&&require;if(!s&&a)return a(u,!0);if(i)return i(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[u]={exports:{}};t[u][0].call(c.exports,function(e){var r=t[u][1][e];return o(r?r:e)},c,c.exports,e,t,r,n)}return r[u].exports}for(var i="function"==typeof require&&require,u=0;u1&&void 0!==arguments[1]?arguments[1]:"https://api.github.com";o(this,e),this.__apiBase=r,this.__auth=t||{}}return i(e,[{key:"getGist",value:function(e){return new s.default(e,this.__auth,this.__apiBase)}},{key:"getUser",value:function(e){return new f.default(e,this.__auth,this.__apiBase)}},{key:"getOrganization",value:function(e){return new v.default(e,this.__auth,this.__apiBase)}},{key:"getTeam",value:function(e){return new w.default(e,this.__auth,this.__apiBase)}},{key:"getRepo",value:function(e,t){return new g.default(this._getFullName(e,t),this.__auth,this.__apiBase)}},{key:"getIssues",value:function(e,t){return new l.default(this._getFullName(e,t),this.__auth,this.__apiBase)}},{key:"search",value:function(e){return new p.default(e,this.__auth,this.__apiBase)}},{key:"getRateLimit",value:function(){return new y.default(this.__auth,this.__apiBase)}},{key:"getMarkdown",value:function(){return new T.default(this.__auth,this.__apiBase)}},{key:"getProject",value:function(e){return new A.default(e,this.__auth,this.__apiBase)}},{key:"_getFullName",value:function(e,t){var r=e;return t&&(r=e+"/"+t),r}}]),e}();t.exports=P},{"./Gist":1,"./Issue":3,"./Markdown":4,"./Organization":5,"./Project":6,"./RateLimit":7,"./Repository":8,"./Search":10,"./Team":11,"./User":12}],3:[function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",t=e.split(/\s*,\s*/);return t.reduce(function(e,t){return t.search(/rel="next"/)!==-1?(t.match(/<(.*)>/)||[])[1]:e},void 0)}function c(e,t){return function(r){var n=void 0;if(r.hasOwnProperty("config")){var o=r.response,i=o.status,u=o.statusText,s=r.config,a=s.method,f=s.url,c=i+" error making request "+a+" "+f+': "'+u+'"';n=new v(c,t,r),m(c+" "+JSON.stringify(r.data))}else n=r;if(!e)throw m("throwing error"),n;m("going to error callback"),e(n)}}var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},h=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};return e.visibility||e.affiliation||(e.type=e.type||"all"),e.sort=e.sort||"updated",e.per_page=e.per_page||"100",e}},{key:"_dateToISO",value:function(e){return e&&e instanceof Date&&(e=e.toISOString()),e}},{key:"_request",value:function(e,t,r,n,o){var i=this.__getURL(t),u=(r||{}).AcceptHeader;u&&delete r.AcceptHeader;var s=this.__getRequestHeaders(o,u),f={},h=r&&"object"===("undefined"==typeof r?"undefined":l(r))&&a(e);h&&(f=r,r=void 0);var p={url:i,method:e,headers:s,params:f,data:r,responseType:o?"text":"json"};m(p.method+" to "+p.url);var y=(0,d.default)(p).catch(c(n,t));return n&&y.then(function(e){e.data&&Object.keys(e.data).length>0?n(null,e.data,e):"GET"!==p.method&&Object.keys(e.data).length<1?n(null,e.status<300,e):n(null,e.data,e)}),y}},{key:"_request204or404",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"GET";return this._request(n,e,t).then(function(e){return r&&r(null,!0,e),!0},function(e){if(404===e.response.status)return r&&r(null,!1,e),!1;throw r&&r(e),e})}},{key:"_requestAllPages",value:function(e,t,r,n){var i=this;return n=n||[],this._request("GET",e,t).then(function(u){var s,a=void 0;if(u.data instanceof Array)a=u.data;else{if(!(u.data.items instanceof Array)){var c="cannot figure out how to append "+u.data+" to the result set";throw new v(c,e,u)}a=u.data.items}(s=n).push.apply(s,o(a));var l=f(u.headers.link);return l?(m("getting next page: "+l),i._requestAllPages(l,t,r,n)):(r&&r(null,n,u),u.data=n,u)}).catch(c(r,e))}}]),e}();t.exports=b;var w=["GET","HEAD","DELETE"]},{axios:13,debug:40,"js-base64":44}],10:[function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t; }function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,o={};return Object.keys(this.__defaults).forEach(function(e){o[e]=t.__defaults[e]}),Object.keys(r).forEach(function(e){o[e]=r[e]}),h("searching "+e+" with options:",o),this._requestAllPages("/search/"+e,o,n)}},{key:"forRepositories",value:function(e,t){return this._search("repositories",e,t)}},{key:"forCode",value:function(e,t){return this._search("code",e,t)}},{key:"forIssues",value:function(e,t){return this._search("issues",e,t)}},{key:"forUsers",value:function(e,t){return this._search("users",e,t)}}]),t}(f.default);t.exports=p},{"./Requestable":9,debug:40}],11:[function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s=function(){function e(e,t){for(var r=0;r=200&&e<300}};f.headers={common:{Accept:"application/json, text/plain, */*"}},i.forEach(["delete","get","head"],function(e){f.headers[e]={}}),i.forEach(["post","put","patch"],function(e){f.headers[e]=i.merge(a)}),t.exports=f}).call(this,e("_process"))},{"./adapters/http":14,"./adapters/xhr":14,"./helpers/normalizeHeaderName":34,"./utils":37,_process:46}],27:[function(e,t,r){"use strict";t.exports=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n>8-s%1*8)){if(r=o.charCodeAt(s+=.75),r>255)throw new n;t=t<<8|r}return u}var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.prototype=new Error,n.prototype.code=5,n.prototype.name="InvalidCharacterError",t.exports=o},{}],29:[function(e,t,r){"use strict";function n(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,"]")}var o=e("./../utils");t.exports=function(e,t,r){if(!t)return e;var i;if(r)i=r(t);else if(o.isURLSearchParams(t))i=t.toString();else{var u=[];o.forEach(t,function(e,t){null!==e&&"undefined"!=typeof e&&(o.isArray(e)&&(t+="[]"),o.isArray(e)||(e=[e]),o.forEach(e,function(e){o.isDate(e)?e=e.toISOString():o.isObject(e)&&(e=JSON.stringify(e)),u.push(n(t)+"="+n(e))}))}),i=u.join("&")}return i&&(e+=(e.indexOf("?")===-1?"?":"&")+i),e}},{"./../utils":37}],30:[function(e,t,r){"use strict";t.exports=function(e,t){return e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,"")}},{}],31:[function(e,t,r){"use strict";var n=e("./../utils");t.exports=n.isStandardBrowserEnv()?function(){return{write:function(e,t,r,o,i,u){var s=[];s.push(e+"="+encodeURIComponent(t)),n.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),n.isString(o)&&s.push("path="+o),n.isString(i)&&s.push("domain="+i),u===!0&&s.push("secure"),document.cookie=s.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)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},{"./../utils":37}],32:[function(e,t,r){"use strict";t.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},{}],33:[function(e,t,r){"use strict";var n=e("./../utils");t.exports=n.isStandardBrowserEnv()?function(){function e(e){var t=e;return r&&(o.setAttribute("href",t),t=o.href),o.setAttribute("href",t),{href:o.href,protocol:o.protocol?o.protocol.replace(/:$/,""):"",host:o.host,search:o.search?o.search.replace(/^\?/,""):"",hash:o.hash?o.hash.replace(/^#/,""):"",hostname:o.hostname,port:o.port,pathname:"/"===o.pathname.charAt(0)?o.pathname:"/"+o.pathname}}var t,r=/(msie|trident)/i.test(navigator.userAgent),o=document.createElement("a");return t=e(window.location.href),function(r){var o=n.isString(r)?e(r):r;return o.protocol===t.protocol&&o.host===t.host}}():function(){return function(){return!0}}()},{"./../utils":37}],34:[function(e,t,r){"use strict";var n=e("../utils");t.exports=function(e,t){n.forEach(e,function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])})}},{"../utils":37}],35:[function(e,t,r){"use strict";var n=e("./../utils");t.exports=function(e){var t,r,o,i={};return e?(n.forEach(e.split("\n"),function(e){o=e.indexOf(":"),t=n.trim(e.substr(0,o)).toLowerCase(),r=n.trim(e.substr(o+1)),t&&(i[t]=i[t]?i[t]+", "+r:r)}),i):i}},{"./../utils":37}],36:[function(e,t,r){"use strict";t.exports=function(e){return function(t){return e.apply(null,t)}}},{}],37:[function(e,t,r){"use strict";function n(e){return"[object Array]"===T.call(e)}function o(e){return"[object ArrayBuffer]"===T.call(e)}function i(e){return"undefined"!=typeof FormData&&e instanceof FormData}function u(e){var t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function s(e){return"string"==typeof e}function a(e){return"number"==typeof e}function f(e){return"undefined"==typeof e}function c(e){return null!==e&&"object"==typeof e}function l(e){return"[object Date]"===T.call(e)}function h(e){return"[object File]"===T.call(e)}function p(e){return"[object Blob]"===T.call(e)}function d(e){return"[object Function]"===T.call(e)}function y(e){return c(e)&&d(e.pipe)}function _(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams}function g(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function m(){return"undefined"!=typeof window&&"undefined"!=typeof document&&"function"==typeof document.createElement}function v(e,t){if(null!==e&&"undefined"!=typeof e)if("object"==typeof e||n(e)||(e=[e]),n(e))for(var r=0,o=e.length;r0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function o(e){return 3*e.length/4-n(e)}function i(e){var t,r,o,i,u,s,a=e.length;u=n(e),s=new l(3*a/4-u),o=u>0?a-4:a;var f=0;for(t=0,r=0;t>16&255,s[f++]=i>>8&255,s[f++]=255&i;return 2===u?(i=c[e.charCodeAt(t)]<<2|c[e.charCodeAt(t+1)]>>4,s[f++]=255&i):1===u&&(i=c[e.charCodeAt(t)]<<10|c[e.charCodeAt(t+1)]<<4|c[e.charCodeAt(t+2)]>>2,s[f++]=i>>8&255,s[f++]=255&i),s}function u(e){return f[e>>18&63]+f[e>>12&63]+f[e>>6&63]+f[63&e]}function s(e,t,r){for(var n,o=[],i=t;ic?c:a+u));return 1===n?(t=e[r-1],o+=f[t>>2],o+=f[t<<4&63],o+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],o+=f[t>>10],o+=f[t>>4&63],o+=f[t<<2&63],o+="="),i.push(o),i.join("")}r.byteLength=o,r.toByteArray=i,r.fromByteArray=a;for(var f=[],c=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,d=h.length;p=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|e}function _(e){return+e!=e&&(e=0),u.alloc(+e)}function g(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return z(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return V(e).length;default:if(n)return z(e).length;t=(""+t).toLowerCase(),n=!0}}function m(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if(r>>>=0,t>>>=0,r<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return x(this,t,r);case"utf8":case"utf-8":return q(this,t,r);case"ascii":return C(this,t,r);case"latin1":case"binary":return j(this,t,r);case"base64":return O(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function v(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function b(e,t,r,n,o){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:w(e,t,r,n,o);if("number"==typeof t)return t=255&t,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):w(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function w(e,t,r,n,o){function i(e,t){return 1===u?e[t]:e.readUInt16BE(t*u)}var u=1,s=e.length,a=t.length;if(void 0!==n&&(n=String(n).toLowerCase(),"ucs2"===n||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;u=2,s/=2,a/=2,r/=2}var f;if(o){var c=-1;for(f=r;fs&&(r=s-a),f=r;f>=0;f--){for(var l=!0,h=0;ho&&(n=o)):n=o;var i=t.length;if(i%2!==0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var u=0;u239?4:i>223?3:i>191?2:1;if(o+s<=r){var a,f,c,l;switch(s){case 1:i<128&&(u=i);break;case 2:a=e[o+1],128===(192&a)&&(l=(31&i)<<6|63&a,l>127&&(u=l));break;case 3:a=e[o+1],f=e[o+2],128===(192&a)&&128===(192&f)&&(l=(15&i)<<12|(63&a)<<6|63&f,l>2047&&(l<55296||l>57343)&&(u=l));break;case 4:a=e[o+1],f=e[o+2],c=e[o+3],128===(192&a)&&128===(192&f)&&128===(192&c)&&(l=(15&i)<<18|(63&a)<<12|(63&f)<<6|63&c,l>65535&&l<1114112&&(u=l))}}null===u?(u=65533,s=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|1023&u),n.push(u),o+=s}return S(n)}function S(e){var t=e.length;if(t<=ee)return String.fromCharCode.apply(String,e);for(var r="",n=0;nn)&&(r=n);for(var o="",i=t;ir)throw new RangeError("Trying to access beyond buffer length")}function I(e,t,r,n,o,i){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||te.length)throw new RangeError("Index out of range")}function L(e,t,r,n){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-r,2);o>>8*(n?o:1-o)}function D(e,t,r,n){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-r,4);o>>8*(n?o:3-o)&255}function M(e,t,r,n,o,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function G(e,t,r,n,o){return o||M(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),Z.write(e,t,r,n,23,4),r+4}function N(e,t,r,n,o){return o||M(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),Z.write(e,t,r,n,52,8),r+8}function H(e){if(e=Y(e).replace(te,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function Y(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function F(e){return e<16?"0"+e.toString(16):e.toString(16)}function z(e,t){t=t||1/0;for(var r,n=e.length,o=null,i=[],u=0;u55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(u+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=(o-55296<<10|r-56320)+65536}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function J(e){for(var t=[],r=0;r>8,o=r%256,i.push(o),i.push(n);return i}function V(e){return $.toByteArray(H(e))}function W(e,t,r,n){for(var o=0;o=t.length||o>=e.length);++o)t[o+r]=e[o];return o}function K(e){return e!==e}var $=e("base64-js"),Z=e("ieee754"),Q=e("isarray");r.Buffer=u,r.SlowBuffer=_,r.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:n(),r.kMaxLength=o(),u.poolSize=8192,u._augment=function(e){return e.__proto__=u.prototype,e},u.from=function(e,t,r){return s(null,e,t,r)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(e,t,r){return f(null,e,t,r)},u.allocUnsafe=function(e){return c(null,e)},u.allocUnsafeSlow=function(e){return c(null,e)},u.isBuffer=function(e){return!(null==e||!e._isBuffer)},u.compare=function(e,t){if(!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,o=0,i=Math.min(r,n);o0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},u.prototype.compare=function(e,t,r,n,o){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,o>>>=0,this===e)return 0;for(var i=o-n,s=r-t,a=Math.min(i,s),f=this.slice(n,o),c=e.slice(t,r),l=0;lo)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return E(this,e,t,r);case"utf8":case"utf-8":return T(this,e,t,r);case"ascii":return k(this,e,t,r);case"latin1":case"binary":return A(this,e,t,r);case"base64":return P(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ee=4096;u.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),t0&&(o*=256);)n+=this[e+--t]*o;return n},u.prototype.readUInt8=function(e,t){return t||U(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||U(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||U(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||U(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||U(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,r){e=0|e,t=0|t,r||U(e,t,this.length);for(var n=this[e],o=1,i=0;++i=o&&(n-=Math.pow(2,8*t)),n},u.prototype.readIntBE=function(e,t,r){e=0|e,t=0|t,r||U(e,t,this.length);for(var n=t,o=1,i=this[e+--n];n>0&&(o*=256);)i+=this[e+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*t)),i},u.prototype.readInt8=function(e,t){return t||U(e,1,this.length),128&this[e]?(255-this[e]+1)*-1:this[e]},u.prototype.readInt16LE=function(e,t){t||U(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(e,t){t||U(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(e,t){return t||U(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||U(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||U(e,4,this.length),Z.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||U(e,4,this.length),Z.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||U(e,8,this.length),Z.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||U(e,8,this.length),Z.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t=0|t,r=0|r,!n){var o=Math.pow(2,8*r)-1;I(this,e,t,r,o,0)}var i=1,u=0;for(this[t]=255&e;++u=0&&(u*=256);)this[t+i]=e/u&255;return t+r},u.prototype.writeUInt8=function(e,t,r){return e=+e,t=0|t,r||I(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,r){return e=+e,t=0|t,r||I(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):L(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,r){return e=+e,t=0|t,r||I(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):L(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,r){return e=+e,t=0|t,r||I(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):D(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,r){return e=+e,t=0|t,r||I(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t=0|t,!n){var o=Math.pow(2,8*r-1);I(this,e,t,r,o-1,-o)}var i=0,u=1,s=0;for(this[t]=255&e;++i>0)-s&255;return t+r},u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t=0|t,!n){var o=Math.pow(2,8*r-1);I(this,e,t,r,o-1,-o)}var i=r-1,u=1,s=0;for(this[t+i]=255&e;--i>=0&&(u*=256);)e<0&&0===s&&0!==this[t+i+1]&&(s=1),this[t+i]=(e/u>>0)-s&255;return t+r},u.prototype.writeInt8=function(e,t,r){return e=+e,t=0|t,r||I(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,r){return e=+e,t=0|t,r||I(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):L(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,r){return e=+e,t=0|t,r||I(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):L(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,r){return e=+e,t=0|t,r||I(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):D(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,r){return e=+e,t=0|t,r||I(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,r){return G(this,e,t,!0,r)},u.prototype.writeFloatBE=function(e,t,r){return G(this,e,t,!1,r)},u.prototype.writeDoubleLE=function(e,t,r){return N(this,e,t,!0,r)},u.prototype.writeDoubleBE=function(e,t,r){return N(this,e,t,!1,r)},u.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--o)e[o+t]=this[o+r];else if(i<1e3||!u.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,r=void 0===r?this.length:r>>>0,e||(e=0);var i;if("number"==typeof e)for(i=t;i=31||"undefined"!=typeof navigator&&navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function i(e){var t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+r.humanize(this.diff),t){var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var o=0,i=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))}),e.splice(i,0,n)}}function u(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function s(e){try{null==e?r.storage.removeItem("debug"):r.storage.debug=e}catch(e){}}function a(){try{return r.storage.debug}catch(e){}if("undefined"!=typeof n&&"env"in n)return n.env.DEBUG}function f(){try{return window.localStorage}catch(e){}}r=t.exports=e("./debug"),r.log=u,r.formatArgs=i,r.save=s,r.load=a,r.useColors=o,r.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:f(),r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],r.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},r.enable(a())}).call(this,e("_process"))},{"./debug":41,_process:46}],41:[function(e,t,r){function n(e){var t,n=0;for(t in e)n=(n<<5)-n+e.charCodeAt(t),n|=0;return r.colors[Math.abs(n)%r.colors.length]}function o(e){function t(){if(t.enabled){var e=t,n=+new Date,o=n-(f||n);e.diff=o,e.prev=f,e.curr=n,f=n;for(var i=new Array(arguments.length),u=0;u>1,c=-7,l=r?o-1:0,h=r?-1:1,p=e[t+l];for(l+=h,i=p&(1<<-c)-1,p>>=-c,c+=s;c>0;i=256*i+e[t+l],l+=h,c-=8);for(u=i&(1<<-c)-1,i>>=-c,c+=n;c>0;u=256*u+e[t+l],l+=h,c-=8);if(0===i)i=1-f;else{if(i===a)return u?NaN:(p?-1:1)*(1/0);u+=Math.pow(2,n),i-=f}return(p?-1:1)*u*Math.pow(2,i-n)},r.write=function(e,t,r,n,o,i){var u,s,a,f=8*i-o-1,c=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,u=c):(u=Math.floor(Math.log(t)/Math.LN2),t*(a=Math.pow(2,-u))<1&&(u--,a*=2),t+=u+l>=1?h/a:h*Math.pow(2,1-l),t*a>=2&&(u++,a/=2),u+l>=c?(s=0,u=c):u+l>=1?(s=(t*a-1)*Math.pow(2,o),u+=l):(s=t*Math.pow(2,l-1)*Math.pow(2,o),u=0));o>=8;e[r+p]=255&s,p+=d,s/=256,o-=8);for(u=u<0;e[r+p]=255&u,p+=d,u/=256,f-=8);e[r+p-d]|=128*y}},{}],43:[function(e,t,r){var n={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},{}],44:[function(e,t,r){!function(r){"use strict";var n,o=r.Base64,i="2.1.9";if("undefined"!=typeof t&&t.exports)try{n=e("buffer").Buffer}catch(e){}var u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=function(e){for(var t={},r=0,n=e.length;r>>6)+a(128|63&t):a(224|t>>>12&15)+a(128|t>>>6&63)+a(128|63&t)}var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return a(240|t>>>18&7)+a(128|t>>>12&63)+a(128|t>>>6&63)+a(128|63&t)},c=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,l=function(e){return e.replace(c,f)},h=function(e){var t=[0,2,1][e.length%3],r=e.charCodeAt(0)<<16|(e.length>1?e.charCodeAt(1):0)<<8|(e.length>2?e.charCodeAt(2):0),n=[u.charAt(r>>>18),u.charAt(r>>>12&63),t>=2?"=":u.charAt(r>>>6&63),t>=1?"=":u.charAt(63&r)];return n.join("")},p=r.btoa?function(e){return r.btoa(e)}:function(e){return e.replace(/[\s\S]{1,3}/g,h)},d=n?function(e){return(e.constructor===n.constructor?e:new n(e)).toString("base64")}:function(e){return p(l(e))},y=function(e,t){return t?d(String(e)).replace(/[+\/]/g,function(e){return"+"==e?"-":"_"}).replace(/=/g,""):d(String(e))},_=function(e){return y(e,!0)},g=new RegExp(["[À-ß][€-¿]","[à-ï][€-¿]{2}","[ð-÷][€-¿]{3}"].join("|"),"g"),m=function(e){switch(e.length){case 4:var t=(7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3),r=t-65536;return a((r>>>10)+55296)+a((1023&r)+56320);case 3:return a((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return a((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},v=function(e){return e.replace(g,m)},b=function(e){var t=e.length,r=t%4,n=(t>0?s[e.charAt(0)]<<18:0)|(t>1?s[e.charAt(1)]<<12:0)|(t>2?s[e.charAt(2)]<<6:0)|(t>3?s[e.charAt(3)]:0),o=[a(n>>>16),a(n>>>8&255),a(255&n)];return o.length-=[0,0,2,1][r],o.join("")},w=r.atob?function(e){return r.atob(e)}:function(e){return e.replace(/[\s\S]{1,4}/g,b)},E=n?function(e){return(e.constructor===n.constructor?e:new n(e,"base64")).toString()}:function(e){return v(w(e))},T=function(e){return E(String(e).replace(/[-_]/g,function(e){return"-"==e?"+":"/"}).replace(/[^A-Za-z0-9\+\/]/g,""))},k=function(){var e=r.Base64;return r.Base64=o,e};if(r.Base64={VERSION:i,atob:w,btoa:p,fromBase64:T,toBase64:y,utob:l,encode:y,encodeURI:_,btou:v,decode:T,noConflict:k},"function"==typeof Object.defineProperty){var A=function(e){return{value:e,enumerable:!1,writable:!0,configurable:!0}};r.Base64.extendString=function(){Object.defineProperty(String.prototype,"fromBase64",A(function(){return T(this)})),Object.defineProperty(String.prototype,"toBase64",A(function(e){return y(this,e)})),Object.defineProperty(String.prototype,"toBase64URI",A(function(){return y(this,!0)}))}}r.Meteor&&(Base64=r.Base64)}(this)},{buffer:39}],45:[function(e,t,r){function n(e){if(e=String(e),!(e.length>1e4)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*l;case"days":case"day":case"d":return r*c;case"hours":case"hour":case"hrs":case"hr":case"h":return r*f;case"minutes":case"minute":case"mins":case"min":case"m":return r*a;case"seconds":case"second":case"secs":case"sec":case"s":return r*s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function o(e){return e>=c?Math.round(e/c)+"d":e>=f?Math.round(e/f)+"h":e>=a?Math.round(e/a)+"m":e>=s?Math.round(e/s)+"s":e+"ms"}function i(e){return u(e,c,"day")||u(e,f,"hour")||u(e,a,"minute")||u(e,s,"second")||e+" ms"}function u(e,t,r){if(!(e0)return n(e);if("number"===r&&isNaN(e)===!1)return t.long?i(e):o(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],46:[function(e,t,r){function n(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function i(e){if(l===setTimeout)return setTimeout(e,0);if((l===n||!l)&&setTimeout)return l=setTimeout,setTimeout(e,0);try{return l(e,0)}catch(t){try{return l.call(null,e,0)}catch(t){return l.call(this,e,0)}}}function u(e){if(h===clearTimeout)return clearTimeout(e);if((h===o||!h)&&clearTimeout)return h=clearTimeout,clearTimeout(e);try{return h(e)}catch(t){try{return h.call(null,e)}catch(t){return h.call(this,e)}}}function s(){_&&d&&(_=!1,d.length?y=d.concat(y):g=-1,y.length&&a())}function a(){if(!_){var e=i(s);_=!0;for(var t=y.length;t;){for(d=y,y=[];++g1)for(var r=1;r=55296&&t<=56319&&o65535&&(t-=65536,o+=b(t>>>10&1023|55296),t=56320|1023&t),o+=b(t);return o}function s(e){if(e>=55296&&e<=57343)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value")}function a(e,t){return b(e>>t&63|128)}function f(e){if(0==(4294967168&e))return b(e);var t="";return 0==(4294965248&e)?t=b(e>>6&31|192):0==(4294901760&e)?(s(e),t=b(e>>12&15|224),t+=a(e,6)):0==(4292870144&e)&&(t=b(e>>18&7|240),t+=a(e,12),t+=a(e,6)),t+=b(63&e|128)}function c(e){for(var t,r=i(e),n=r.length,o=-1,u="";++o=m)throw Error("Invalid byte index");var e=255&g[v];if(v++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function h(){var e,t,r,n,o;if(v>m)throw Error("Invalid byte index");if(v==m)return!1;if(e=255&g[v],v++,0==(128&e))return e;if(192==(224&e)){if(t=l(),o=(31&e)<<6|t,o>=128)return o;throw Error("Invalid continuation byte")}if(224==(240&e)){if(t=l(),r=l(),o=(15&e)<<12|t<<6|r,o>=2048)return s(o),o;throw Error("Invalid continuation byte")}if(240==(248&e)&&(t=l(),r=l(),n=l(),o=(7&e)<<18|t<<12|r<<6|n,o>=65536&&o<=1114111))return o;throw Error("Invalid UTF-8 detected")}function p(e){g=i(e),m=g.length,v=0;for(var t,r=[];(t=h())!==!1;)r.push(t);return u(r)}var d="object"==typeof n&&n,y="object"==typeof r&&r&&r.exports==d&&r,_="object"==typeof t&&t;_.global!==_&&_.window!==_||(o=_);var g,m,v,b=String.fromCharCode,w={version:"2.1.2",encode:c,decode:p};if("function"==typeof e&&"object"==typeof e.amd&&e.amd)e(function(){return w});else if(d&&!d.nodeType)if(y)y.exports=w;else{var E={},T=E.hasOwnProperty;for(var k in w)T.call(w,k)&&(d[k]=w[k])}else o.utf8=w}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[2])(2)}); -//# sourceMappingURL=GitHub.bundle.min.js.map /* ********************************************** @@ -746,7 +745,7 @@ Prism.languages.javascript = Prism.languages.extend('clike', { Prism.languages.insertBefore('javascript', 'keyword', { 'regex': { - pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[[^\]\r\n]+]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/, + pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[[^\]\r\n]+]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})\]]))/, lookbehind: true, greedy: true }, @@ -760,23 +759,24 @@ Prism.languages.insertBefore('javascript', 'keyword', { Prism.languages.insertBefore('javascript', 'string', { 'template-string': { - pattern: /`(?:\\[\s\S]|[^\\`])*`/, + pattern: /`(?:\\[\s\S]|\${[^}]+}|[^\\`])*`/, greedy: true, inside: { 'interpolation': { - pattern: /\$\{[^}]+\}/, + pattern: /\${[^}]+}/, inside: { 'interpolation-punctuation': { - pattern: /^\$\{|\}$/, + pattern: /^\${|}$/, alias: 'punctuation' }, - rest: Prism.languages.javascript + rest: null // See below } }, 'string': /[\s\S]+/ } } }); +Prism.languages.javascript['template-string'].inside['interpolation'].inside.rest = Prism.languages.javascript; if (Prism.languages.markup) { Prism.languages.insertBefore('markup', 'tag', { @@ -820,7 +820,7 @@ Prism.languages.js = Prism.languages.javascript; var src = pre.getAttribute('data-src'); var language, parent = pre; - var lang = /\blang(?:uage)?-(?!\*)([\w-]+)\b/i; + var lang = /\blang(?:uage)?-([\w-]+)\b/i; while (parent && !lang.test(parent.className)) { parent = parent.parentNode; } @@ -864,32 +864,36 @@ Prism.languages.js = Prism.languages.javascript; } }; - if (pre.hasAttribute('data-download-link') && Prism.plugins.toolbar) { - Prism.plugins.toolbar.registerButton('download-file', function () { - var a = document.createElement('a'); - a.textContent = pre.getAttribute('data-download-link-label') || 'Download'; - a.setAttribute('download', ''); - a.href = src; - return a; - }); - } - xhr.send(null); }); + if (Prism.plugins.toolbar) { + Prism.plugins.toolbar.registerButton('download-file', function (env) { + var pre = env.element.parentNode; + if (!pre || !/pre/i.test(pre.nodeName) || !pre.hasAttribute('data-src') || !pre.hasAttribute('data-download-link')) { + return; + } + var src = pre.getAttribute('data-src'); + var a = document.createElement('a'); + a.textContent = pre.getAttribute('data-download-link-label') || 'Download'; + a.setAttribute('download', ''); + a.href = src; + return a; + }); + } + }; document.addEventListener('DOMContentLoaded', self.Prism.fileHighlight); })(); - -(function(){"undefined"==typeof Math.sgn&&(Math.sgn=function(a){return 0==a?0:a>0?1:-1});var a={subtract:function(a,b){return{x:a.x-b.x,y:a.y-b.y}},dotProduct:function(a,b){return a.x*b.x+a.y*b.y},square:function(a){return Math.sqrt(a.x*a.x+a.y*a.y)},scale:function(a,b){return{x:a.x*b,y:a.y*b}}},b=64,c=Math.pow(2,-b-1),d=function(b,c){for(var d=[],e=f(b,c),h=c.length-1,i=2*h-1,j=g(e,i,d,0),k=a.subtract(b,c[0]),m=a.square(k),n=0,o=0;j>o;o++){k=a.subtract(b,l(c,h,d[o],null,null));var p=a.square(k);m>p&&(m=p,n=d[o])}return k=a.subtract(b,c[h]),p=a.square(k),m>p&&(m=p,n=1),{location:n,distance:m}},e=function(a,b){var c=d(a,b);return{point:l(b,b.length-1,c.location,null,null),location:c.location}},f=function(b,c){for(var d=c.length-1,e=2*d-1,f=[],g=[],h=[],i=[],k=[[1,.6,.3,.1],[.4,.6,.6,.4],[.1,.3,.6,1]],l=0;d>=l;l++)f[l]=a.subtract(c[l],b);for(var l=0;d-1>=l;l++)g[l]=a.subtract(c[l+1],c[l]),g[l]=a.scale(g[l],3);for(var m=0;d-1>=m;m++)for(var n=0;d>=n;n++)h[m]||(h[m]=[]),h[m][n]=a.dotProduct(g[m],f[n]);for(l=0;e>=l;l++)i[l]||(i[l]=[]),i[l].y=0,i[l].x=parseFloat(l)/e;for(var o=d,p=d-1,q=0;o+p>=q;q++){var r=Math.max(0,q-p),s=Math.min(q,o);for(l=r;s>=l;l++)j=q-l,i[l+j].y+=h[j][l]*k[j][l]}return i},g=function(a,c,d,e){var f,j,m=[],n=[],o=[],p=[];switch(h(a,c)){case 0:return 0;case 1:if(e>=b)return d[0]=(a[0].x+a[c].x)/2,1;if(i(a,c))return d[0]=k(a,c),1}l(a,c,.5,m,n),f=g(m,c,o,e+1),j=g(n,c,p,e+1);for(var q=0;f>q;q++)d[q]=o[q];for(var q=0;j>q;q++)d[q+f]=p[q];return f+j},h=function(a,b){var c,d,e=0;c=d=Math.sgn(a[0].y);for(var f=1;b>=f;f++)c=Math.sgn(a[f].y),c!=d&&e++,d=c;return e},i=function(a,b){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;i=a[0].y-a[b].y,j=a[b].x-a[0].x,k=a[0].x*a[b].y-a[b].x*a[0].y;for(var t=max_distance_below=0,u=1;b>u;u++){var v=i*a[u].x+j*a[u].y+k;v>t?t=v:vd?1:0},k=function(a,b){var c=1,d=0,e=a[b].x-a[0].x,f=a[b].y-a[0].y,g=a[0].x-0,h=a[0].y-0,i=e*d-f*c,j=1/i,k=(e*h-f*g)*j;return 0+c*k},l=function(a,b,c,d,e){for(var f=[[]],g=0;b>=g;g++)f[0][g]=a[g];for(var h=1;b>=h;h++)for(var g=0;b-h>=g;g++)f[h]||(f[h]=[]),f[h][g]||(f[h][g]={}),f[h][g].x=(1-c)*f[h-1][g].x+c*f[h-1][g+1].x,f[h][g].y=(1-c)*f[h-1][g].y+c*f[h-1][g+1].y;if(null!=d)for(g=0;b>=g;g++)d[g]=f[g][0];if(null!=e)for(g=0;b>=g;g++)e[g]=f[b-g][g];return f[b][0]},m={},n=function(a){var b=m[a];if(!b){b=[];var c=function(){return function(b){return Math.pow(b,a)}},d=function(){return function(b){return Math.pow(1-b,a)}},e=function(a){return function(b){return a}},f=function(){return function(a){return a}},g=function(){return function(a){return 1-a}},h=function(a){return function(b){for(var c=1,d=0;di;i++){for(var j=[new e(a)],k=0;a-i>k;k++)j.push(new f);for(var k=0;i>k;k++)j.push(new g);b.push(new h(j))}b.push(new d),m[a]=b}return b},o=function(a,b){for(var c=n(a.length-1),d=0,e=0,f=0;f0?1:-1,h=null;ed;)d+=.005*e,f=o(a,d),c+=p(f,b),b=f;return c},t=function(a,b,c){return r(a,b,c).point},u=function(a,b,c){return r(a,b,c).location},v=function(a,b){var c=o(a,b),d=o(a.slice(0,a.length-1),b),e=d.y-c.y,f=d.x-c.x;return 0==e?1/0:Math.atan(e/f)},w=function(a,b,c){var d=r(a,b,c);return d.location>1&&(d.location=1),d.location<0&&(d.location=0),v(a,d.location)},x=function(a,b,c,d){d=null==d?0:d;var e=r(a,b,d),f=v(a,e.location),g=Math.atan(-1/f),h=c/2*Math.sin(g),i=c/2*Math.cos(g);return[{x:e.point.x+i,y:e.point.y+h},{x:e.point.x-i,y:e.point.y-h}]},y=this.jsBezier={distanceFromCurve:d,gradientAtPoint:v,gradientAtPointAlongCurveFrom:w,nearestPointOnCurve:e,pointOnCurve:o,pointAlongCurveFrom:t,perpendicularToCurveAt:x,locationAlongCurveFrom:u,getLength:s,version:"0.9.0"};"undefined"!=typeof exports&&(exports.jsBezier=y)}).call("undefined"!=typeof window?window:this),function(){"use strict";var a=this,b=a.Biltong={version:"0.4.0"};"undefined"!=typeof exports&&(exports.Biltong=b);var c=function(a){return"[object Array]"===Object.prototype.toString.call(a)},d=function(a,b,d){return a=c(a)?a:[a.x,a.y],b=c(b)?b:[b.x,b.y],d(a,b)},e=b.gradient=function(a,b){return d(a,b,function(a,b){return b[0]==a[0]?b[1]>a[1]?1/0:-(1/0):b[1]==a[1]?b[0]>a[0]?0:-0:(b[1]-a[1])/(b[0]-a[0])})},f=(b.normal=function(a,b){return-1/e(a,b)},b.lineLength=function(a,b){return d(a,b,function(a,b){return Math.sqrt(Math.pow(b[1]-a[1],2)+Math.pow(b[0]-a[0],2))})},b.quadrant=function(a,b){return d(a,b,function(a,b){return b[0]>a[0]?b[1]>a[1]?2:1:b[0]==a[0]?b[1]>a[1]?2:1:b[1]>a[1]?3:4})}),g=(b.theta=function(a,b){return d(a,b,function(a,b){var c=e(a,b),d=Math.atan(c),g=f(a,b);return(4==g||3==g)&&(d+=Math.PI),0>d&&(d+=2*Math.PI),d})},b.intersects=function(a,b){var c=a.x,d=a.x+a.w,e=a.y,f=a.y+a.h,g=b.x,h=b.x+b.w,i=b.y,j=b.y+b.h;return g>=c&&d>=g&&i>=e&&f>=i||h>=c&&d>=h&&i>=e&&f>=i||g>=c&&d>=g&&j>=e&&f>=j||h>=c&&d>=g&&j>=e&&f>=j||c>=g&&h>=c&&e>=i&&j>=e||d>=g&&h>=d&&e>=i&&j>=e||c>=g&&h>=c&&f>=i&&j>=f||d>=g&&h>=c&&f>=i&&j>=f},b.encloses=function(a,b,c){var d=a.x,e=a.x+a.w,f=a.y,g=a.y+a.h,h=b.x,i=b.x+b.w,j=b.y,k=b.y+b.h,l=function(a,b,d,e){return c?b>=a&&d>=e:b>a&&d>e};return l(d,h,e,i)&&l(f,j,g,k)},[null,[1,-1],[1,1],[-1,1],[-1,-1]]),h=[null,[-1,-1],[-1,1],[1,1],[1,-1]];b.pointOnLine=function(a,b,c){var d=e(a,b),i=f(a,b),j=c>0?g[i]:h[i],k=Math.atan(d),l=Math.abs(c*Math.sin(k))*j[1],m=Math.abs(c*Math.cos(k))*j[0];return{x:a.x+m,y:a.y+l}},b.perpendicularLineTo=function(a,b,c){var d=e(a,b),f=Math.atan(-1/d),g=c/2*Math.sin(f),h=c/2*Math.cos(f);return[{x:b.x+h,y:b.y+g},{x:b.x-h,y:b.y-g}]}}.call("undefined"!=typeof window?window:this),function(){"use strict";var a=this,b={android:navigator.userAgent.toLowerCase().indexOf("android")>-1},c=function(a,b,c){c=c||a.parentNode;for(var d=c.querySelectorAll(b),e=0;ec&&a[c]!=b;c++);c-1&&9>v,x=function(a,b){if(null==a)return[0,0];var c=C(a),d=B(c,0);return[d[b+"X"],d[b+"Y"]]},y=function(a){return null==a?[0,0]:w?[a.clientX+document.documentElement.scrollLeft,a.clientY+document.documentElement.scrollTop]:x(a,"page")},z=function(a){return x(a,"screen")},A=function(a){return x(a,"client")},B=function(a,b){return a.item?a.item(b):a[b]},C=function(a){return a.touches&&a.touches.length>0?a.touches:a.changedTouches&&a.changedTouches.length>0?a.changedTouches:a.targetTouches&&a.targetTouches.length>0?a.targetTouches:[a]},D=function(a){return C(a).length},E=function(a,b,c,d){if(i(a,b,c),d.__tauid=c.__tauid,a.addEventListener)a.addEventListener(b,c,!1);else if(a.attachEvent){var e=b+c.__tauid;a["e"+e]=c,a[e]=function(){a["e"+e]&&a["e"+e](window.event)},a.attachEvent("on"+b,a[e])}},F=function(a,b,c){null!=c&&G(a,function(){var e=d(this);if(j(e,b,c),null!=c.__tauid)if(e.removeEventListener)e.removeEventListener(b,c,!1),s&&u[b]&&e.removeEventListener(u[b],c,!1);else if(this.detachEvent){var f=b+c.__tauid;e[f]&&e.detachEvent("on"+b,e[f]),e[f]=null,e["e"+f]=null}c.__taTouchProxy&&F(a,c.__taTouchProxy[1],c.__taTouchProxy[0])})},G=function(a,b){if(null!=a){a="undefined"!=typeof Window&&"unknown"!=typeof a.top&&a==a.top?[a]:"string"!=typeof a&&null==a.tagName&&null!=a.length?a:"string"==typeof a?document.querySelectorAll(a):[a];for(var c=0;c-1&&9>h,l=9===h,m=function(a){if(k)return[a.clientX+document.documentElement.scrollLeft,a.clientY+document.documentElement.scrollTop];var b=o(a),c=n(b,0);return l?[c.pageX||c.clientX,c.pageY||c.clientY]:[c.pageX,c.pageY]},n=function(a,b){return a.item?a.item(b):a[b]},o=function(a){return a.touches&&a.touches.length>0?a.touches:a.changedTouches&&a.changedTouches.length>0?a.changedTouches:a.targetTouches&&a.targetTouches.length>0?a.targetTouches:[a]},p={draggable:"katavorio-draggable",droppable:"katavorio-droppable",drag:"katavorio-drag",selected:"katavorio-drag-selected",active:"katavorio-drag-active",hover:"katavorio-drag-hover",noSelect:"katavorio-drag-no-select",ghostProxy:"katavorio-ghost-proxy",clonedDrag:"katavorio-clone-drag"},q="katavorio-drag-scope",r=["stop","start","drag","drop","over","out","beforeStart"],s=function(){},t=function(){return!0},u=function(a,b,c){for(var d=0;d1)for(var f=0;f0&&W&&b.setPosition(this.el,W),T.sort(G);for(var e=0;eb.rank?-1:0},H=function(a){return null==a?null:(a="string"==typeof a||a.constructor===String?document.getElementById(a):a,null==a?null:(a._katavorio=a._katavorio||F(),a))};a.Katavorio=function(a){var f=[],g={};this._dragsByScope={},this._dropsByScope={};var h=1,i=function(a,b){w(a,function(a){for(var c=0;c0},k=(this.getMatchingDroppables=function(a){for(var b=[],c={},d=0;d=0&&f.splice(d,1),j(a[b],c)&&w(a[b],function(a){a.destroy()}),delete a[b]}},B=function(a,b,c,d){a=H(a),a[b]&&a[b].off(c,d)};this.elementRemoved=function(a){this.destroyDraggable(a),this.destroyDroppable(a)},this.destroyDraggable=function(a,b,c){1===arguments.length?A(a,"_katavorioDrag",this._dragsByScope):B(a,"_katavorioDrag",b,c)},this.destroyDroppable=function(a,b,c){1===arguments.length?A(a,"_katavorioDrop",this._dropsByScope):B(a,"_katavorioDrop",b,c)},this.reset=function(){this._dragsByScope={},this._dropsByScope={},f=[],g={},C={}};var C={},F=function(a,c,d){var f=e(c)?c:c.id,g=e(c)?!0:c.active!==!1,h=C[f]||function(){var a={name:f,members:[]};return C[f]=a,a}();return w(a,function(a){if(a._katavorioDrag){if(d&&null!=a._katavorioDrag.posseRoles[h.name])return;b(h.members,a._katavorioDrag),b(a._katavorioDrag.posses,h.name),a._katavorioDrag.posseRoles[h.name]=g}}),h};this.addToPosse=function(a,b){for(var c=[],d=1;d=f.length,i=function(){return e[g[1]]||function(){return e[g[1]]=[],e[g[1]]}()};if(h)g?i()[g[3]]=c:e[a]=c;else if(g){var j=i();e=j[g[3]]||function(){return j[g[3]]={},j[g[3]]}()}else e=e[a]||function(){return e[a]={},e[a]}()}),a}},functionChain:function(a,b,c){for(var d=0;d-1&&a.splice(c,1),-1!==c},remove:function(a,b){var c=a.indexOf(b);return c>-1&&a.splice(c,1),-1!==c},addWithFunction:function(a,b,c){-1===j.jsPlumbUtil.findWithFunction(a,c)&&a.push(b)},addToList:function(a,b,c,d){var e=a[b];return null==e&&(e=[],a[b]=e),e[d?"unshift":"push"](c),e},suggest:function(a,b,c){return-1===a.indexOf(b)?(c?a.unshift(b):a.push(b),!0):!1},extend:function(b,c,d){var e;for(c=a(c)?c:[c],e=0;e2)for(e=2;el&&n!==!1;){if(d[g])a[g][l].apply(this,[h,i]);else try{n=a[g][l].apply(this,[h,i])}catch(o){j.jsPlumbUtil.log("jsPlumb: fire failed for event "+g+" : "+o)}l++,(null==a||null==a[g])&&(m=!0)}}c=!1,f()}return this};var f=function(){var a=e.pop();a&&this.fire.apply(this,a)}.bind(this);this.unbind=function(b,c){if(0===arguments.length)a={};else if(1===arguments.length){if("string"==typeof b)delete a[b];else if(b.__jsPlumb){var d;for(var e in b.__jsPlumb)d=b.__jsPlumb[e],j.jsPlumbUtil.remove(a[d]||[],b)}}else 2===arguments.length&&j.jsPlumbUtil.remove(a[b]||[],c);return this},this.getListener=function(b){return a[b]},this.setSuspendEvents=function(a){b=a},this.isSuspendEvents=function(){return b},this.silently=function(a){this.setSuspendEvents(!0);try{a()}catch(b){j.jsPlumbUtil.log("Cannot execute silent function "+b)}this.setSuspendEvents(!1)},this.cleanupListeners=function(){for(var b in a)a[b]=null}},j.jsPlumbUtil.EventGenerator.prototype={cleanup:function(){this.cleanupListeners()}},"undefined"!=typeof exports&&(exports.jsPlumbUtil=j.jsPlumbUtil)}.call("undefined"!=typeof window?window:this),function(){"use strict";var a=this;a.jsPlumbUtil.matchesSelector=function(a,b,c){c=c||a.parentNode;for(var d=c.querySelectorAll(b),e=0;ef;f++)d&&d===e[f]||e[f].setHover(b,!0,c)},g=function(a){return null==a?null:a.split(" ")},h=function(a,b,c){for(var d in b)a[d]=c},i=function(a,c){c=b.isArray(c)||null!=c.length&&!b.isString(c)?c:[c];for(var d=0;dj;j++){var l=a._jsPlumb.types[j];if("__default"!==l){var m=a._jsPlumb.instance.getType(l,e);null!=m&&(i=b.merge(i,m,["cssClass"]),h(f,m,l))}}c&&(i=b.populate(i,c,"_")),a.applyType(i,d,f),d||a.repaint()}},k=a.jsPlumbUIComponent=function(a){b.EventGenerator.apply(this,arguments);var c=this,d=arguments,e=c.idPrefix,f=e+(new Date).getTime();this._jsPlumb={instance:a._jsPlumb,parameters:a.parameters||{},paintStyle:null,hoverPaintStyle:null,paintStyleInUse:null,hover:!1,beforeDetach:a.beforeDetach,beforeDrop:a.beforeDrop,overlayPlacements:[],hoverClass:a.hoverClass||a._jsPlumb.Defaults.HoverClass,types:[],typeCache:{}},this.cacheTypeItem=function(a,b,c){this._jsPlumb.typeCache[c]=this._jsPlumb.typeCache[c]||{},this._jsPlumb.typeCache[c][a]=b},this.getCachedTypeItem=function(a,b){return this._jsPlumb.typeCache[b]?this._jsPlumb.typeCache[b][a]:null},this.getId=function(){return f};var g=a.overlays||[],h={};if(this.defaultOverlayKeys){for(var i=0;if;f++)this.hasType(d[f])||(this._jsPlumb.types.push(d[f]),e=!0);e&&j(this,b,c)}},removeType:function(a,b,c){var d=g(a),e=!1,f=function(a){var b=this._jsPlumb.types.indexOf(a);return-1!==b?(l(this,b),this._jsPlumb.types.splice(b,1),!0):!1}.bind(this);if(null!=d){for(var h=0,i=d.length;i>h;h++)e=f(d[h])||e;e&&j(this,b,c)}},clearTypes:function(a,b){for(var c=this._jsPlumb.types.length,d=0;c>d;d++)l(this,0),this._jsPlumb.types.splice(0,1);j(this,a,b)},toggleType:function(a,b,c){var d=g(a);if(null!=d){for(var e=0,f=d.length;f>e;e++){var h=this._jsPlumb.types.indexOf(d[e]);-1!==h?(l(this,h),this._jsPlumb.types.splice(h,1)):this._jsPlumb.types.push(d[e])}j(this,b,c)}},applyType:function(a,b){if(this.setPaintStyle(a.paintStyle,b),this.setHoverPaintStyle(a.hoverPaintStyle,b),a.parameters)for(var c in a.parameters)this.setParameter(c,a.parameters[c]);this._jsPlumb.paintStyleInUse=this.getPaintStyle()},setPaintStyle:function(a,b){this._jsPlumb.paintStyle=a,this._jsPlumb.paintStyleInUse=this._jsPlumb.paintStyle,d(this),b||this.repaint()},getPaintStyle:function(){return this._jsPlumb.paintStyle},setHoverPaintStyle:function(a,b){this._jsPlumb.hoverPaintStyle=a,d(this),b||this.repaint()},getHoverPaintStyle:function(){return this._jsPlumb.hoverPaintStyle},destroy:function(a){(a||null==this.typeId)&&(this.cleanupListeners(),this.clone=null,this._jsPlumb=null)},isHover:function(){return this._jsPlumb.hover},setHover:function(a,b,d){if(this._jsPlumb&&!this._jsPlumb.instance.currentlyDragging&&!this._jsPlumb.instance.isHoverSuspended()){this._jsPlumb.hover=a;var e=a?"addClass":"removeClass";null!=this.canvas&&(null!=this._jsPlumb.instance.hoverClass&&this._jsPlumb.instance[e](this.canvas,this._jsPlumb.instance.hoverClass),null!=this._jsPlumb.hoverClass&&this._jsPlumb.instance[e](this.canvas,this._jsPlumb.hoverClass)),null!=this._jsPlumb.hoverPaintStyle&&(this._jsPlumb.paintStyleInUse=a?this._jsPlumb.hoverPaintStyle:this._jsPlumb.paintStyle,this._jsPlumb.instance.isSuspendDrawing()||(d=d||c(),this.repaint({timestamp:d,recalc:!1}))),this.getAttachedElements&&!b&&f(this,a,c(),this)}}});var m=0,n=function(){var a=m+1;return m++,a},o=a.jsPlumbInstance=function(d){this.version="2.6.12",d&&p.extend(this.Defaults,d),this.logEnabled=this.Defaults.LogEnabled,this._connectionTypes={},this._endpointTypes={},b.EventGenerator.apply(this);var f=this,g=n(),h=f.bind,j={},l=1,m=function(a){if(null==a)return null;if(3===a.nodeType||8===a.nodeType)return{el:a,text:!0};var c=f.getElement(a);return{el:c,id:b.isString(a)&&null==c?a:Y(c)}};this.getInstanceIndex=function(){return g},this.setZoom=function(a,b){return l=a,f.fire("zoom",l),b&&f.repaintEverything(),!0},this.getZoom=function(){return l};for(var o in this.Defaults)j[o]=this.Defaults[o];var q,r=[];this.unbindContainer=function(){if(null!=q&&r.length>0)for(var a=0;ae;e++)d.overlays.push(d.sourceEndpoint.connectorOverlays[e])}d.sourceEndpoint&&d.sourceEndpoint.scope&&(d.scope=d.sourceEndpoint.scope),!d["pointer-events"]&&d.sourceEndpoint&&d.sourceEndpoint.connectorPointerEvents&&(d["pointer-events"]=d.sourceEndpoint.connectorPointerEvents);var h=function(a,b,c){return f.addEndpoint(a,N(b,{anchor:d.anchors?d.anchors[c]:d.anchor,endpoint:d.endpoints?d.endpoints[c]:d.endpoint,paintStyle:d.endpointStyles?d.endpointStyles[c]:d.endpointStyle,hoverPaintStyle:d.endpointHoverStyles?d.endpointHoverStyles[c]:d.endpointHoverStyle}))},i=function(a,b,c,e){if(d[a]&&!d[a].endpoint&&!d[a+"Endpoint"]&&!d.newConnection){var f=Y(d[a]),g=c[f];if(g=g?g[e]:null){if(!g.enabled)return!1;var i=null!=g.endpoint&&g.endpoint._jsPlumb?g.endpoint:h(d[a],g.def,b);if(i.isFull())return!1;d[a+"Endpoint"]=i,!d.scope&&g.def.scope&&(d.scope=g.def.scope),g.uniqueEndpoint?g.endpoint?i.finalEndpoint=g.endpoint:(g.endpoint=i,i.setDeleteOnEmpty(!1)):i.setDeleteOnEmpty(!0),0===b&&g.def.connectorOverlays&&(d.overlays=d.overlays||[],Array.prototype.push.apply(d.overlays,g.def.connectorOverlays))}}};return i("source",0,this.sourceEndpointDefinitions,d.type||"default")!==!1&&i("target",1,this.targetEndpointDefinitions,d.type||"default")!==!1?(d.sourceEndpoint&&d.targetEndpoint&&(M(d.sourceEndpoint,d.targetEndpoint)||(d=null)),d):void 0}.bind(f),P=function(a){var b=f.Defaults.ConnectionType||f.getDefaultConnectionType();a._jsPlumb=f,a.newConnection=P,a.newEndpoint=R,a.endpointsByUUID=w,a.endpointsByElement=v,a.finaliseConnection=Q,a.id="con_"+H();var c=new b(a);return c.isDetachable()&&(c.endpoints[0].initDraggable("_jsPlumbSource"),c.endpoints[1].initDraggable("_jsPlumbTarget")),c},Q=f.finaliseConnection=function(a,b,c,d){if(b=b||{},a.suspendedEndpoint||u.push(a),a.pending=null,a.endpoints[0].isTemporarySource=!1,d!==!1&&f.anchorManager.newConnection(a),J(a.source),!b.doNotFireConnectionEvent&&b.fireEvent!==!1){var e={connection:a,source:a.source,target:a.target,sourceId:a.sourceId,targetId:a.targetId,sourceEndpoint:a.endpoints[0],targetEndpoint:a.endpoints[1]};f.fire("connection",e,c)}},R=function(a,b){var c=f.Defaults.EndpointType||p.Endpoint,d=p.extend({},a);d._jsPlumb=f,d.newConnection=P,d.newEndpoint=R,d.endpointsByUUID=w,d.endpointsByElement=v,d.fireDetachEvent=_,d.elementId=b||Y(d.source);var e=new c(d);return e.id="ep_"+H(),sa(d.elementId,d.source),p.headless||f.getDragManager().endpointAdded(d.source,b),e},S=function(a,b,c){var d=v[a];if(d&&d.length)for(var e=0,f=d.length;f>e;e++){for(var g=0,h=d[e].connections.length;h>g;g++){var i=b(d[e].connections[g]);if(i)return}c&&c(d[e])}},T=function(a,b){return p.each(a,function(a){f.isDragSupported(a)&&(A[f.getAttribute(a,"id")]=b,f.setElementDraggable(a,b))})},U=function(a,b,c){b="block"===b;var d=null;c&&(d=function(a){a.setVisible(b,!0,!0)});var e=m(a);S(e.id,function(a){if(b&&c){var d=a.sourceId===e.id?1:0;a.endpoints[d].isVisible()&&a.setVisible(!0)}else a.setVisible(b)},d)},V=function(a){var b;return p.each(a,function(a){var c=f.getAttribute(a,"id");return b=null==A[c]?!1:A[c],b=!b,A[c]=b,f.setDraggable(a,b),b}.bind(this)),b},W=function(a,b){var c=null;b&&(c=function(a){var b=a.isVisible();a.setVisible(!b)}),S(a,function(a){var b=a.isVisible();a.setVisible(!b)},c)},X=function(a){var b=y[a];return b?{o:b,s:C[a]}:ta({elId:a})},Y=function(a,c,d){if(b.isString(a))return a;if(null==a)return null;var e=f.getAttribute(a,"id");return e&&"undefined"!==e||(2===arguments.length&&void 0!==arguments[1]?e=c:(1===arguments.length||3===arguments.length&&!arguments[2])&&(e="jsPlumb_"+g+"_"+H()),d||f.setAttribute(a,"id",e)),e};this.setConnectionBeingDragged=function(a){B=a},this.isConnectionBeingDragged=function(){return B},this.getManagedElements=function(){return x},this.connectorClass="jtk-connector",this.connectorOutlineClass="jtk-connector-outline",this.connectedClass="jtk-connected",this.hoverClass="jtk-hover",this.endpointClass="jtk-endpoint",this.endpointConnectedClass="jtk-endpoint-connected",this.endpointFullClass="jtk-endpoint-full",this.endpointDropAllowedClass="jtk-endpoint-drop-allowed",this.endpointDropForbiddenClass="jtk-endpoint-drop-forbidden",this.overlayClass="jtk-overlay",this.draggingClass="jtk-dragging",this.elementDraggingClass="jtk-element-dragging",this.sourceElementDraggingClass="jtk-source-element-dragging",this.targetElementDraggingClass="jtk-target-element-dragging",this.endpointAnchorClassPrefix="jtk-endpoint-anchor",this.hoverSourceClass="jtk-source-hover",this.hoverTargetClass="jtk-target-hover",this.dragSelectClass="jtk-drag-select",this.Anchors={},this.Connectors={svg:{}},this.Endpoints={svg:{}},this.Overlays={svg:{}},this.ConnectorRenderers={},this.SVG="svg",this.addEndpoint=function(a,c,d){d=d||{};var e=p.extend({},d);p.extend(e,c),e.endpoint=e.endpoint||f.Defaults.Endpoint,e.paintStyle=e.paintStyle||f.Defaults.EndpointStyle;for(var g=[],h=b.isArray(a)||null!=a.length&&!b.isString(a)?a:[a],i=0,j=h.length;j>i;i++){e.source=f.getElement(h[i]),qa(e.source);var k=Y(e.source),l=R(e,k),m=sa(k,e.source).info.o;b.addToList(v,k,l),D||l.paint({anchorLoc:l.anchor.compute({xy:[m.left,m.top],wh:C[k],element:l,timestamp:E}),timestamp:E}),g.push(l)}return 1===g.length?g[0]:g},this.addEndpoints=function(a,c,d){for(var e=[],g=0,h=c.length;h>g;g++){var i=f.addEndpoint(a,c[g],d);b.isArray(i)?Array.prototype.push.apply(e,i):e.push(i)}return e},this.animate=function(a,c,d){if(!this.animationSupported)return!1;d=d||{};var e=f.getElement(a),g=Y(e),h=p.animEvents.step,i=p.animEvents.complete;d[h]=b.wrap(d[h],function(){f.revalidate(g)}),d[i]=b.wrap(d[i],function(){f.revalidate(g)}),f.doAnimate(e,c,d)},this.checkCondition=function(a,c){var d=f.getListener(a),e=!0;if(d&&d.length>0){var g=Array.prototype.slice.call(arguments,1);try{for(var h=0,i=d.length;i>h;h++)e=e&&d[h].apply(d[h],g)}catch(j){b.log(f,"cannot check condition ["+a+"]"+j)}}return e},this.connect=function(a,c){var d,e=O(a,c);if(e){if(null==e.source&&null==e.sourceEndpoint)return void b.log("Cannot establish connection - source does not exist");if(null==e.target&&null==e.targetEndpoint)return void b.log("Cannot establish connection - target does not exist");qa(e.source),d=P(e),Q(d,e)}return d};var Z=[{el:"source",elId:"sourceId",epDefs:"sourceEndpointDefinitions"},{el:"target",elId:"targetId",epDefs:"targetEndpointDefinitions"}],$=function(a,b,c,d){var e,f,g,h=Z[c],i=a[h.elId],j=(a[h.el],a.endpoints[c]),k={index:c,originalSourceId:0===c?i:a.sourceId,newSourceId:a.sourceId,originalTargetId:1===c?i:a.targetId,newTargetId:a.targetId,connection:a};if(b.constructor===p.Endpoint)e=b,e.addConnection(a),b=e.element;else if(f=Y(b),g=this[h.epDefs][f],f===a[h.elId])e=null;else if(g)for(var l in g){if(!g[l].enabled)return;e=null!=g[l].endpoint&&g[l].endpoint._jsPlumb?g[l].endpoint:this.addEndpoint(b,g[l].def),g[l].uniqueEndpoint&&(g[l].endpoint=e),e.addConnection(a)}else e=a.makeEndpoint(0===c,b,f);return null!=e&&(j.detachFromConnection(a),a.endpoints[c]=e,a[h.el]=e.element,a[h.elId]=e.elementId,k[0===c?"newSourceId":"newTargetId"]=e.elementId,aa(k),d||a.repaint()),k.element=b,k}.bind(this);this.setSource=function(a,b,c){var d=$(a,b,0,c);this.anchorManager.sourceChanged(d.originalSourceId,d.newSourceId,a,d.el)},this.setTarget=function(a,b,c){var d=$(a,b,1,c);this.anchorManager.updateOtherEndpoint(d.originalSourceId,d.originalTargetId,d.newTargetId,a)},this.deleteEndpoint=function(a,b,c){var d="string"==typeof a?w[a]:a;return d&&f.deleteObject({endpoint:d,dontUpdateHover:b,deleteAttachedObjects:c}),f},this.deleteEveryEndpoint=function(){var a=f.setSuspendDrawing(!0);for(var b in v){var c=v[b];if(c&&c.length)for(var d=0,e=c.length;e>d;d++)f.deleteEndpoint(c[d],!0)}v={},x={},w={},y={},z={},f.anchorManager.reset();var g=f.getDragManager();return g&&g.reset(),a||f.setSuspendDrawing(!1),f};var _=function(a,b,c){var d=f.Defaults.ConnectionType||f.getDefaultConnectionType(),e=a.constructor===d,g=e?{connection:a,source:a.source,target:a.target,sourceId:a.sourceId,targetId:a.targetId,sourceEndpoint:a.endpoints[0],targetEndpoint:a.endpoints[1]}:a;b&&f.fire("connectionDetached",g,c),f.fire("internal.connectionDetached",g,c),f.anchorManager.connectionDetached(g)},aa=f.fireMoveEvent=function(a,b){f.fire("connectionMoved",a,b)};this.unregisterEndpoint=function(a){a._jsPlumb.uuid&&(w[a._jsPlumb.uuid]=null),f.anchorManager.deleteEndpoint(a);for(var b in v){var c=v[b];if(c){for(var d=[],e=0,g=c.length;g>e;e++)c[e]!==a&&d.push(c[e]);v[b]=d}v[b].length<1&&delete v[b]}};var ba="isDetachAllowed",ca="beforeDetach",da="checkCondition";this.deleteConnection=function(a,c){return null!=a&&(c=c||{},c.force||b.functionChain(!0,!1,[[a.endpoints[0],ba,[a]],[a.endpoints[1],ba,[a]],[a,ba,[a]],[f,da,[ca,a]]]))?(a.setHover(!1),_(a,!a.pending&&c.fireEvent!==!1,c.originalEvent),a.endpoints[0].detachFromConnection(a),a.endpoints[1].detachFromConnection(a),b.removeWithFunction(u,function(b){return a.id===b.id}),a.cleanup(),a.destroy(),!0):!1},this.deleteEveryConnection=function(a){a=a||{};var b=u.length,c=0;return f.batch(function(){for(var d=0;b>d;d++)c+=f.deleteConnection(u[0],a)?1:0}),c},this.deleteConnectionsForElement=function(a,b){b=b||{},a=f.getElement(a);var c=Y(a),d=v[c];if(d&&d.length)for(var e=0,g=d.length;g>e;e++)d[e].deleteEveryConnection(b);return f},this.deleteObject=function(a){var c={endpoints:{},connections:{},endpointCount:0,connectionCount:0},d=a.deleteAttachedObjects!==!1,e=function(b){null!=b&&null==c.connections[b.id]&&(a.dontUpdateHover||null==b._jsPlumb||b.setHover(!1),c.connections[b.id]=b,c.connectionCount++)},g=function(b){if(null!=b&&null==c.endpoints[b.id]&&(a.dontUpdateHover||null==b._jsPlumb||b.setHover(!1),c.endpoints[b.id]=b,c.endpointCount++,d))for(var f=0;fe;e++)a[e][b].apply(a[e],c);return d(a)},fa=function(a,b,c){for(var d=[],e=0,f=a.length;f>e;e++)d.push([a[e][b].apply(a[e],c),a[e]]);return d},ga=function(a,b,c){return function(){return ea(a,b,arguments,c)}},ha=function(a,b){return function(){return fa(a,b,arguments)}},ia=function(a,b){var c=[];if(a)if("string"==typeof a){if("*"===a)return a;c.push(a)}else if(b)c=a;else if(a.length)for(var d=0,e=a.length;e>d;d++)c.push(m(a[d]).id);else c.push(m(a).id);return c},ja=function(a,b,c){return"*"===a?!0:a.length>0?-1!==a.indexOf(b):!c};this.getConnections=function(a,b){a?a.constructor===String&&(a={scope:a}):a={};for(var c=a.scope||f.getDefaultScope(),d=ia(c,!0),e=ia(a.source),g=ia(a.target),h=!b&&d.length>1?{}:[],i=function(a,c){if(!b&&d.length>1){var e=h[a];null==e&&(e=h[a]=[]),e.push(c)}else h.push(c)},j=0,k=u.length;k>j;j++){var l=u[j],m=l.proxies&&l.proxies[0]?l.proxies[0].originalEp.elementId:l.sourceId,n=l.proxies&&l.proxies[1]?l.proxies[1].originalEp.elementId:l.targetId;ja(d,l.scope)&&ja(e,m)&&ja(g,n)&&i(l.scope,l)}return h};var ka=function(a,b){return function(c){for(var d=0,e=a.length;e>d;d++)c(a[d]);return b(a)}},la=function(a){return function(b){return a[b]}},ma=function(a,b){var c,d,e={length:a.length,each:ka(a,b),get:la(a)},f=["setHover","removeAllOverlays","setLabel","addClass","addOverlay","removeOverlay","removeOverlays","showOverlay","hideOverlay","showOverlays","hideOverlays","setPaintStyle","setHoverPaintStyle","setSuspendEvents","setParameter","setParameters","setVisible","repaint","addType","toggleType","removeType","removeClass","setType","bind","unbind"],g=["getLabel","getOverlay","isHover","getParameter","getParameters","getPaintStyle","getHoverPaintStyle","isVisible","hasType","getType","isSuspendEvents"];for(c=0,d=f.length;d>c;c++)e[f[c]]=ga(a,f[c],b);for(c=0,d=g.length;d>c;c++)e[g[c]]=ha(a,g[c]);return e},na=function(a){var b=ma(a,na);return p.extend(b,{setDetachable:ga(a,"setDetachable",na),setReattach:ga(a,"setReattach",na),setConnector:ga(a,"setConnector",na),"delete":function(){for(var b=0,c=a.length;c>b;b++)f.deleteConnection(a[b])},isDetachable:ha(a,"isDetachable"),isReattach:ha(a,"isReattach")})},oa=function(a){var b=ma(a,oa);return p.extend(b,{setEnabled:ga(a,"setEnabled",oa),setAnchor:ga(a,"setAnchor",oa),isEnabled:ha(a,"isEnabled"),deleteEveryConnection:function(){for(var b=0,c=a.length;c>b;b++)a[b].deleteEveryConnection()},"delete":function(){for(var b=0,c=a.length;c>b;b++)f.deleteEndpoint(a[b])}})};this.select=function(a){return a=a||{},a.scope=a.scope||"*",na(a.connections||f.getConnections(a,!0))},this.selectEndpoints=function(a){a=a||{},a.scope=a.scope||"*";var b=!a.element&&!a.source&&!a.target,c=b?"*":ia(a.element),d=b?"*":ia(a.source),e=b?"*":ia(a.target),f=ia(a.scope,!0),g=[];for(var h in v){var i=ja(c,h,!0),j=ja(d,h,!0),k="*"!==d,l=ja(e,h,!0),m="*"!==e;if(i||j||l)a:for(var n=0,o=v[h].length;o>n;n++){var p=v[h][n];if(ja(f,p.scope,!0)){var q=k&&d.length>0&&!p.isSource,r=m&&e.length>0&&!p.isTarget;if(q||r)continue a;g.push(p)}}}return oa(g)},this.getAllConnections=function(){return u},this.getDefaultScope=function(){return F},this.getEndpoint=K,this.getEndpoints=function(a){return v[m(a).id]||[]},this.getDefaultEndpointType=function(){return p.Endpoint},this.getDefaultConnectionType=function(){return p.Connection},this.getId=Y,this.appendElement=I;var pa=!1;this.isHoverSuspended=function(){return pa},this.setHoverSuspended=function(a){pa=a},this.hide=function(a,b){return U(a,"none",b),f},this.idstamp=H;var qa=function(a){if(!q&&a){var b=f.getElement(a);b.offsetParent&&f.setContainer(b.offsetParent)}},ra=function(){f.Defaults.Container&&f.setContainer(f.Defaults.Container)},sa=f.manage=function(a,b,c){return x[a]||(x[a]={el:b,endpoints:[],connections:[]},x[a].info=ta({elId:a,timestamp:E}),c||f.fire("manageElement",{id:a,info:x[a].info,el:b})),x[a]},ta=this.updateOffset=function(a){var b,c=a.timestamp,d=a.recalc,e=a.offset,g=a.elId;return D&&!c&&(c=E),!d&&c&&c===z[g]?{o:a.offset||y[g],s:C[g]}:(d||!e&&null==y[g]?(b=x[g]?x[g].el:null,null!=b&&(C[g]=f.getSize(b),y[g]=f.getOffset(b),z[g]=c)):(y[g]=e||y[g],null==C[g]&&(b=x[g].el,null!=b&&(C[g]=f.getSize(b))),z[g]=c),y[g]&&!y[g].right&&(y[g].right=y[g].left+C[g][0], -y[g].bottom=y[g].top+C[g][1],y[g].width=C[g][0],y[g].height=C[g][1],y[g].centerx=y[g].left+y[g].width/2,y[g].centery=y[g].top+y[g].height/2),{o:y[g],s:C[g]})};this.init=function(){t||(ra(),f.anchorManager=new a.jsPlumb.AnchorManager({jsPlumbInstance:f}),t=!0,f.fire("ready",f))}.bind(this),this.log=s,this.jsPlumbUIComponent=k,this.makeAnchor=function(){var c,d=function(b,c){if(a.jsPlumb.Anchors[b])return new a.jsPlumb.Anchors[b](c);if(!f.Defaults.DoNotThrowErrors)throw{msg:"jsPlumb: unknown anchor type '"+b+"'"}};if(0===arguments.length)return null;var e=arguments[0],g=arguments[1],h=(arguments[2],null);if(e.compute&&e.getOrientation)return e;if("string"==typeof e)h=d(arguments[0],{elementId:g,jsPlumbInstance:f});else if(b.isArray(e))if(b.isArray(e[0])||b.isString(e[0]))2===e.length&&b.isObject(e[1])?b.isString(e[0])?(c=a.jsPlumb.extend({elementId:g,jsPlumbInstance:f},e[1]),h=d(e[0],c)):(c=a.jsPlumb.extend({elementId:g,jsPlumbInstance:f,anchors:e[0]},e[1]),h=new a.jsPlumb.DynamicAnchor(c)):h=new p.DynamicAnchor({anchors:e,selector:null,elementId:g,jsPlumbInstance:f});else{var i={x:e[0],y:e[1],orientation:e.length>=4?[e[2],e[3]]:[0,0],offsets:e.length>=6?[e[4],e[5]]:[0,0],elementId:g,jsPlumbInstance:f,cssClass:7===e.length?e[6]:null};h=new a.jsPlumb.Anchor(i),h.clone=function(){return new a.jsPlumb.Anchor(i)}}return h.id||(h.id="anchor_"+H()),h},this.makeAnchors=function(c,d,e){for(var g=[],h=0,i=c.length;i>h;h++)"string"==typeof c[h]?g.push(a.jsPlumb.Anchors[c[h]]({elementId:d,jsPlumbInstance:e})):b.isArray(c[h])&&g.push(f.makeAnchor(c[h],d,e));return g},this.makeDynamicAnchor=function(b,c){return new a.jsPlumb.DynamicAnchor({anchors:b,selector:c,elementId:null,jsPlumbInstance:f})},this.targetEndpointDefinitions={},this.sourceEndpointDefinitions={};var ua=function(a,b,c,d,e){for(var f=a.target||a.srcElement,g=!1,h=d.getSelector(b,c),i=0;i0&&a>=c.def.maxConnections},element:c.el,elementId:c.id,isSource:g,isTarget:h,addClass:function(a){f.addClass(c.el,a)},removeClass:function(a){f.removeClass(c.el,a)},onDrop:function(a){var b=a.endpoints[0];b.anchor.unlock()},isDropAllowed:function(){return i.isDropAllowed.apply(i,arguments)},isRedrop:function(a){return null!=a.suspendedElement&&null!=a.suspendedEndpoint&&a.suspendedEndpoint.element===c.el},getEndpoint:function(b){var e=c.def.endpoint;if(null==e||null==e._jsPlumb){var g=f.deriveEndpointAndAnchorSpec(b.getType().join(" "),!0),h=g.endpoints?a.jsPlumb.extend(d,{endpoint:c.def.def.endpoint||g.endpoints[1]}):d;g.anchors&&(h=a.jsPlumb.extend(h,{anchor:c.def.def.anchor||g.anchors[1]})),e=f.addEndpoint(c.el,h),e._mtNew=!0}if(d.uniqueEndpoint&&(c.def.endpoint=e),e.setDeleteOnEmpty(!0),b.isDetachable()&&e.initDraggable(),null!=e.anchor.positionFinder){var i=f.getUIPosition(arguments,f.getZoom()),j=f.getOffset(c.el),k=f.getSize(c.el),l=null==i?[0,0]:e.anchor.positionFinder(i,j,k,e.anchor.constructorParams);e.anchor.x=l[0],e.anchor.y=l[1]}return e},maybeCleanup:function(a){a._mtNew&&0===a.connections.length?f.deleteObject({endpoint:a}):delete a._mtNew}}),l=a.jsPlumb.dragEvents.drop;return e.scope=e.scope||d.scope||f.Defaults.Scope,e[l]=b.wrap(e[l],j,!0),h&&(e[a.jsPlumb.dragEvents.over]=function(){return!0}),d.allowLoopback===!1&&(e.canDrop=function(a){var b=a.getDragElement()._jsPlumbRelatedElement;return b!==c.el}),f.initDroppable(c.el,e,"internal"),j};this.makeTarget=function(b,c,d){var e=a.jsPlumb.extend({_jsPlumb:this},d);a.jsPlumb.extend(e,c);for(var g=e.maxConnections||-1,h=function(b){var c=m(b),d=c.id,h=a.jsPlumb.extend({},e.dropOptions||{}),i=e.connectionType||"default";this.targetEndpointDefinitions[d]=this.targetEndpointDefinitions[d]||{},qa(d),c.el._isJsPlumbGroup&&null==h.rank&&(h.rank=-1);var j={def:a.jsPlumb.extend({},e),uniqueEndpoint:e.uniqueEndpoint,maxConnections:g,enabled:!0};e.createEndpoint&&(j.uniqueEndpoint=!0,j.endpoint=f.addEndpoint(b,j.def),j.endpoint.setDeleteOnEmpty(!1)),c.def=j,this.targetEndpointDefinitions[d][i]=j,va(c,e,h,e.isSource===!0,!0),c.el._katavorioDrop[c.el._katavorioDrop.length-1].targetDef=j}.bind(this),i=b.length&&b.constructor!==String?b:[b],j=0,k=i.length;k>j;j++)h(i[j]);return this},this.unmakeTarget=function(a,b){var c=m(a);return f.destroyDroppable(c.el,"internal"),b||delete this.targetEndpointDefinitions[c.id],this},this.makeSource=function(c,d,e){var g=a.jsPlumb.extend({_jsPlumb:this},e);a.jsPlumb.extend(g,d);var h=g.connectionType||"default",i=f.deriveEndpointAndAnchorSpec(h);g.endpoint=g.endpoint||i.endpoints[0],g.anchor=g.anchor||i.anchors[0];for(var j=g.maxConnections||-1,k=g.onMaxConnections,n=function(d){var e=d.id,i=this.getElement(d.el);this.sourceEndpointDefinitions[e]=this.sourceEndpointDefinitions[e]||{},qa(e);var m={def:a.jsPlumb.extend({},g),uniqueEndpoint:g.uniqueEndpoint,maxConnections:j,enabled:!0};g.createEndpoint&&(m.uniqueEndpoint=!0,m.endpoint=f.addEndpoint(c,m.def),m.endpoint.setDeleteOnEmpty(!1)),this.sourceEndpointDefinitions[e][h]=m,d.def=m;var n=a.jsPlumb.dragEvents.stop,o=a.jsPlumb.dragEvents.drag,p=a.jsPlumb.extend({},g.dragOptions||{}),q=p.drag,r=p.stop,s=null,t=!1;p.scope=p.scope||g.scope,p[o]=b.wrap(p[o],function(){q&&q.apply(this,arguments),t=!1}),p[n]=b.wrap(p[n],function(){if(r&&r.apply(this,arguments),this.currentlyDragging=!1,null!=s._jsPlumb){var a=g.anchor||this.Defaults.Anchor,b=s.anchor,c=s.connections[0],d=this.makeAnchor(a,e,this),h=s.element;if(null!=d.positionFinder){var i=f.getOffset(h),j=this.getSize(h),k={left:i.left+b.x*j[0],top:i.top+b.y*j[1]},l=d.positionFinder(k,i,j,d.constructorParams);d.x=l[0],d.y=l[1]}s.setAnchor(d,!0),s.repaint(),this.repaint(s.elementId),null!=c&&this.repaint(c.targetId)}}.bind(this));var u=function(c){if(3!==c.which&&2!==c.button){var m=this.sourceEndpointDefinitions[e][h];if(m.enabled){if(e=this.getId(this.getElement(d.el)),g.filter){var n=b.isString(g.filter)?ua(c,d.el,g.filter,this,g.filterExclude):g.filter(c,d.el);if(n===!1)return}var o=this.select({source:e}).length;if(m.maxConnections>=0&&o>=m.maxConnections)return k&&k({element:d.el,maxConnections:j},c),!1;var q=a.jsPlumb.getPositionOnElement(c,i,l),r={};a.jsPlumb.extend(r,g),r.isTemporarySource=!0,r.anchor=[q[0],q[1],0,0],r.dragOptions=p,m.def.scope&&(r.scope=m.def.scope),s=this.addEndpoint(e,r),t=!0,s.setDeleteOnEmpty(!0),m.uniqueEndpoint&&(m.endpoint?s.finalEndpoint=m.endpoint:(m.endpoint=s,s.setDeleteOnEmpty(!1)));var u=function(){f.off(s.canvas,"mouseup",u),f.off(d.el,"mouseup",u),t&&(t=!1,f.deleteEndpoint(s))};f.on(s.canvas,"mouseup",u),f.on(d.el,"mouseup",u);var v={};if(m.def.extract)for(var w in m.def.extract){var x=(c.srcElement||c.target).getAttribute(w);x&&(v[m.def.extract[w]]=x)}f.trigger(s.canvas,"mousedown",c,v),b.consume(c)}}}.bind(this);this.on(d.el,"mousedown",u),m.trigger=u,g.filter&&(b.isString(g.filter)||b.isFunction(g.filter))&&f.setDragFilter(d.el,g.filter);var v=a.jsPlumb.extend({},g.dropOptions||{});va(d,g,v,!0,g.isTarget===!0)}.bind(this),o=c.length&&c.constructor!==String?c:[c],p=0,q=o.length;q>p;p++)n(m(o[p]));return this},this.unmakeSource=function(a,b,c){var d=m(a);f.destroyDroppable(d.el,"internal");var e=this.sourceEndpointDefinitions[d.id];if(e)for(var g in e)if(null==b||b===g){var h=e[g].trigger;h&&f.off(d.el,"mousedown",h),c||delete this.sourceEndpointDefinitions[d.id][g]}return this},this.unmakeEverySource=function(){for(var a in this.sourceEndpointDefinitions)f.unmakeSource(a,null,!0);return this.sourceEndpointDefinitions={},this};var wa=function(a,c,d){c=b.isArray(c)?c:[c];var e=Y(a);d=d||"default";for(var f=0;fl;l++)i=m(c[l]),k[i.id]&&k[i.id][g]&&(h[l]=k[i.id][g].enabled,j=e?!h[l]:d,k[i.id][g].enabled=j,f[j?"removeClass":"addClass"](i.el,"jtk-"+a+"-disabled"))}else{i=m(c);var o=i.id;k[o]&&k[o][g]&&(h=k[o][g].enabled,j=e?!h:d,k[o][g].enabled=j,f[j?"removeClass":"addClass"](i.el,"jtk-"+a+"-disabled"))}return h}.bind(this),za=function(a,c){return b.isString(a)||!a.length?c.apply(this,[a]):a.length?c.apply(this,[a[0]]):void 0}.bind(this);this.toggleSourceEnabled=function(a,b){return ya("source",a,null,!0,b),this.isSourceEnabled(a,b)},this.setSourceEnabled=function(a,b,c){return ya("source",a,b,null,c)},this.isSource=function(a,b){return b=b||"default",za(a,function(a){var c=this.sourceEndpointDefinitions[m(a).id];return null!=c&&null!=c[b]}.bind(this))},this.isSourceEnabled=function(a,b){return b=b||"default",za(a,function(a){var c=this.sourceEndpointDefinitions[m(a).id];return c&&c[b]&&c[b].enabled===!0}.bind(this))},this.toggleTargetEnabled=function(a,b){return ya("target",a,null,!0,b),this.isTargetEnabled(a,b)},this.isTarget=function(a,b){return b=b||"default",za(a,function(a){var c=this.targetEndpointDefinitions[m(a).id];return null!=c&&null!=c[b]}.bind(this))},this.isTargetEnabled=function(a,b){return b=b||"default",za(a,function(a){var c=this.targetEndpointDefinitions[m(a).id];return c&&c[b]&&c[b].enabled===!0}.bind(this))},this.setTargetEnabled=function(a,b,c){return ya("target",a,b,null,c)},this.ready=function(a){f.bind("ready",a)};var Aa=function(a,b){if("object"==typeof a&&a.length)for(var c=0,d=a.length;d>c;c++)b(a[c]);else b(a);return f};this.repaint=function(a,b,c){return Aa(a,function(a){J(a,b,c)})},this.revalidate=function(a,b,c){return Aa(a,function(a){var d=c?a:f.getId(a);f.updateOffset({elId:d,recalc:!0,timestamp:b});var e=f.getDragManager();e&&e.updateOffsets(d),f.repaint(a)})},this.repaintEverything=function(){var a,b=c();for(a in v)f.updateOffset({elId:a,recalc:!0,timestamp:b});for(a in v)J(a,null,b);return this},this.removeAllEndpoints=function(a,b,c){c=c||[];var d=function(a){var e,g,h=m(a),i=v[h.id];if(i)for(c.push(h),e=0,g=i.length;g>e;e++)f.deleteEndpoint(i[e],!1);if(delete v[h.id],b&&h.el&&3!==h.el.nodeType&&8!==h.el.nodeType)for(e=0,g=h.el.childNodes.length;g>e;e++)d(h.el.childNodes[e])};return d(a),this};var Ba=function(a,b){f.removeAllEndpoints(a.id,!0,b);for(var c=f.getDragManager(),d=function(a){c&&c.elementRemoved(a.id),f.anchorManager.clearFor(a.id),f.anchorManager.removeFloatingConnection(a.id),f.isSource(a.el)&&f.unmakeSource(a.el),f.isTarget(a.el)&&f.unmakeTarget(a.el),f.destroyDraggable(a.el),f.destroyDroppable(a.el),delete f.floatingConnections[a.id],delete x[a.id],delete y[a.id],a.el&&(f.removeElement(a.el),a.el._jsPlumb=null)},e=1;e0;)d(e.el.childNodes[0]);b||Ba(e,c)}};return f.batch(function(){d(a,!0)},b===!1),f},this.reset=function(a){f.silently(function(){pa=!1,f.removeAllGroups(),f.removeGroupManager(),f.deleteEveryEndpoint(),a||f.unbind(),this.targetEndpointDefinitions={},this.sourceEndpointDefinitions={},u.length=0,this.doReset&&this.doReset()}.bind(this))};var Ca=function(a){a.canvas&&a.canvas.parentNode&&a.canvas.parentNode.removeChild(a.canvas),a.cleanup(),a.destroy()};this.clear=function(){f.select().each(Ca),f.selectEndpoints().each(Ca),v={},w={}},this.setDefaultScope=function(a){return F=a,f},this.setDraggable=T,this.deriveEndpointAndAnchorSpec=function(a,b){for(var c=((b?"":"default ")+a).split(/[\s]/),d=null,e=null,g=null,h=null,i=0;ih;h++)v[c][h].setElementId(c),v[c][h].setReferenceElement(a);delete v[e],this.sourceEndpointDefinitions[c]=this.sourceEndpointDefinitions[e],delete this.sourceEndpointDefinitions[e],this.targetEndpointDefinitions[c]=this.targetEndpointDefinitions[e],delete this.targetEndpointDefinitions[e],this.anchorManager.changeId(e,c);var j=this.getDragManager();j&&j.changeId(e,c),x[c]=x[e],delete x[e];var k=function(b,d,e){for(var f=0,g=b.length;g>f;f++)b[f].endpoints[d].setElementId(c),b[f].endpoints[d].setReferenceElement(a),b[f][e+"Id"]=c,b[f][e]=a};k(f,0,"source"),k(g,1,"target"),this.repaint(c)},this.setDebugLog=function(a){s=a},this.setSuspendDrawing=function(a,b){var c=D;return D=a,E=a?(new Date).getTime():null,b&&this.repaintEverything(),c},this.isSuspendDrawing=function(){return D},this.getSuspendedAt=function(){return E},this.batch=function(a,c){var d=this.isSuspendDrawing();d||this.setSuspendDrawing(!0);try{a()}catch(e){b.log("Function run while suspended failed",e)}d||this.setSuspendDrawing(!1,!c)},this.doWhileSuspended=this.batch,this.getCachedData=X,this.timestamp=c,this.show=function(a,b){return U(a,"block",b),f},this.toggleVisible=W,this.toggleDraggable=V,this.addListener=this.bind;var Da=[];this.registerFloatingConnection=function(a,c,d){Da[a.id]=c,b.addToList(v,a.id,d)},this.getFloatingConnectionFor=function(a){return Da[a]}};b.extend(a.jsPlumbInstance,b.EventGenerator,{setAttribute:function(a,b,c){this.setAttribute(a,b,c)},getAttribute:function(b,c){return this.getAttribute(a.jsPlumb.getElement(b),c)},convertToFullOverlaySpec:function(a){return b.isString(a)&&(a=[a,{}]),a[1].id=a[1].id||b.uuid(),a},registerConnectionType:function(b,c){if(this._connectionTypes[b]=a.jsPlumb.extend({},c),c.overlays){for(var d={},e=0;e0?a.touches:a.changedTouches&&a.changedTouches.length>0?a.changedTouches:a.targetTouches&&a.targetTouches.length>0?a.targetTouches:[a]},i=function(a){var b={},c=[],d={},e={},f={};this.register=function(g){var h=a.getId(g),i=a.getOffset(g);b[h]||(b[h]=g,c.push(g),d[h]={});var j=function(b){if(b)for(var c=0;c0){var l=a.getOffset(g);d[h][k]={id:k,offset:{left:l.left-i.left,top:l.top-i.top}},f[k]=h}j(b.childNodes[c])}};j(g)},this.updateOffsets=function(b,c){if(null!=b){c=c||{};var e=jsPlumb.getElement(b),g=a.getId(e),h=d[g],i=a.getOffset(e);if(h)for(var j in h)if(h.hasOwnProperty(j)){var k=jsPlumb.getElement(j),l=c[j]||a.getOffset(k);if(null==k.offsetParent&&null!=d[g][j])continue;d[g][j]={id:j,offset:{left:l.left-i.left,top:l.top-i.top}},f[j]=g}}},this.endpointAdded=function(c,g){g=g||a.getId(c);var h=document.body,i=c.parentNode;for(e[g]=e[g]?e[g]+1:1;null!=i&&i!==h;){var j=a.getId(i,null,!0);if(j&&b[j]){var k=a.getOffset(i);if(null==d[j][g]){var l=a.getOffset(c);d[j][g]={id:g,offset:{left:l.left-k.left,top:l.top-k.top}},f[g]=j}break}i=i.parentNode}},this.endpointDeleted=function(a){if(e[a.elementId]&&(e[a.elementId]--,e[a.elementId]<=0))for(var b in d)d.hasOwnProperty(b)&&d[b]&&(delete d[b][a.elementId],delete f[a.elementId])},this.changeId=function(a,b){d[b]=d[a],d[a]={},f[b]=f[a],f[a]=null},this.getElementsForDraggable=function(a){return d[a]},this.elementRemoved=function(a){var b=f[a];b&&(delete d[b][a],delete f[a])},this.reset=function(){b={},c=[],d={},e={}},this.dragEnded=function(b){if(null!=b.offsetParent){var c=a.getId(b),d=f[c];d&&this.updateOffsets(d)}},this.setParent=function(b,c,e,g,h){var i=f[c];d[g]||(d[g]={});var j=a.getOffset(e),k=h||a.getOffset(b);i&&d[i]&&delete d[i][c],d[g][c]={id:c,offset:{left:k.left-j.left,top:k.top-j.top}},f[c]=g},this.clearParent=function(a,b){var c=f[b];c&&(delete d[c][b],delete f[b])},this.revalidateParent=function(b,c,d){var e=f[c];if(e){var g={};g[c]=d,this.updateOffsets(e,g),a.revalidate(e)}},this.getDragAncestor=function(b){var c=jsPlumb.getElement(b),d=a.getId(c),e=f[d];return e?jsPlumb.getElement(e):null}},j=function(a){return null==a?null:a.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},k=function(a,b,c){b=j(b),"undefined"!=typeof a.className.baseVal?a.className.baseVal=b:a.className=b;try{for(var d=a.classList;d.length>0;)d.remove(d.item(0));for(var e=0;e0||a.scrollLeft>0)&&(d.left-=a.scrollLeft,d.top-=a.scrollTop)}.bind(this);null!=e;)d.left+=e.offsetLeft,d.top+=e.offsetTop,f(e),e=b?e.offsetParent:e.offsetParent===c?null:e.offsetParent;if(null!=c&&!b&&(c.scrollTop>0||c.scrollLeft>0)){var g=null!=a.offsetParent?this.getStyle(a.offsetParent,"position"):"static",h=this.getStyle(a,"position");"absolute"!==h&&"fixed"!==h&&"absolute"!==g&&"fixed"!==g&&(d.left-=c.scrollLeft,d.top-=c.scrollTop)}return d},getPositionOnElement:function(a,b,c){var d="undefined"!=typeof b.getBoundingClientRect?b.getBoundingClientRect():{left:0,top:0,width:0,height:0},e=document.body,f=document.documentElement,g=window.pageYOffset||f.scrollTop||e.scrollTop,h=window.pageXOffset||f.scrollLeft||e.scrollLeft,i=f.clientTop||e.clientTop||0,j=f.clientLeft||e.clientLeft||0,k=0,l=0,m=d.top+g-i+k*c,n=d.left+h-j+l*c,o=jsPlumb.pageLocation(a),p=d.width||b.offsetWidth*c,q=d.height||b.offsetHeight*c,r=(o[0]-n)/p,s=(o[1]-m)/q;return[r,s]},getAbsolutePosition:function(a){var b=function(b){var c=a.style[b];return c?parseFloat(c.substring(0,c.length-2)):void 0};return[b("left"),b("top")]},setAbsolutePosition:function(a,b,c,d){c?this.animate(a,{left:"+="+(b[0]-c[0]),top:"+="+(b[1]-c[1])},d):(a.style.left=b[0]+"px",a.style.top=b[1]+"px")},getSize:function(a){return[a.offsetWidth,a.offsetHeight]},getWidth:function(a){return a.offsetWidth},getHeight:function(a){return a.offsetHeight},getRenderMode:function(){return"svg"}})}.call("undefined"!=typeof window?window:this),function(){"use strict";var a=this,b=a.jsPlumb,c=a.jsPlumbUtil,d="__label",e=function(a,c){var e={cssClass:c.cssClass,labelStyle:a.labelStyle,id:d,component:a,_jsPlumb:a._jsPlumb.instance},f=b.extend(e,c);return new(b.Overlays[a._jsPlumb.instance.getRenderMode()].Label)(f)},f=function(a,d){var e=null;if(c.isArray(d)){var f=d[0],g=b.extend({component:a,_jsPlumb:a._jsPlumb.instance},d[1]);3===d.length&&b.extend(g,d[2]),e=new(b.Overlays[a._jsPlumb.instance.getRenderMode()][f])(g)}else e=d.constructor===String?new(b.Overlays[a._jsPlumb.instance.getRenderMode()][d])({component:a,_jsPlumb:a._jsPlumb.instance}):d;return e.id=e.id||c.uuid(),a.cacheTypeItem("overlay",e,e.id),a._jsPlumb.overlays[e.id]=e,e};b.OverlayCapableJsPlumbUIComponent=function(b){a.jsPlumbUIComponent.apply(this,arguments),this._jsPlumb.overlays={},this._jsPlumb.overlayPositions={},b.label&&(this.getDefaultType().overlays[d]=["Label",{label:b.label,location:b.labelLocation||this.defaultLabelLocation||.5,labelStyle:b.labelStyle||this._jsPlumb.instance.Defaults.LabelStyle,id:d}]),this.setListenerComponent=function(a){if(this._jsPlumb)for(var b in this._jsPlumb.overlays)this._jsPlumb.overlays[b].setListenerComponent(a)}},b.OverlayCapableJsPlumbUIComponent.applyType=function(a,b){if(b.overlays){var c,d={};for(c in b.overlays){var e=a._jsPlumb.overlays[b.overlays[c][1].id];if(e)e.updateFrom(b.overlays[c][1]),d[b.overlays[c][1].id]=!0;else{var f=a.getCachedTypeItem("overlay",b.overlays[c][1].id);null!=f?(f.reattach(a._jsPlumb.instance,a),f.setVisible(!0),f.updateFrom(b.overlays[c][1]),a._jsPlumb.overlays[f.id]=f):f=a.addOverlay(b.overlays[c],!0),d[f.id]=!0}}for(c in a._jsPlumb.overlays)null==d[a._jsPlumb.overlays[c].id]&&a.removeOverlay(a._jsPlumb.overlays[c].id,!0)}},c.extend(b.OverlayCapableJsPlumbUIComponent,a.jsPlumbUIComponent,{setHover:function(a,b){if(this._jsPlumb&&!this._jsPlumb.instance.isConnectionBeingDragged())for(var c in this._jsPlumb.overlays)this._jsPlumb.overlays[c][a?"addClass":"removeClass"](this._jsPlumb.instance.hoverClass)},addOverlay:function(a,b){var c=f(this,a);return b||this.repaint(),c},getOverlay:function(a){return this._jsPlumb.overlays[a]},getOverlays:function(){return this._jsPlumb.overlays},hideOverlay:function(a){var b=this.getOverlay(a);b&&b.hide()},hideOverlays:function(){for(var a in this._jsPlumb.overlays)this._jsPlumb.overlays[a].hide()},showOverlay:function(a){var b=this.getOverlay(a);b&&b.show()},showOverlays:function(){for(var a in this._jsPlumb.overlays)this._jsPlumb.overlays[a].show()},removeAllOverlays:function(a){for(var b in this._jsPlumb.overlays)this._jsPlumb.overlays[b].cleanup&&this._jsPlumb.overlays[b].cleanup();this._jsPlumb.overlays={},this._jsPlumb.overlayPositions=null,a||this.repaint()},removeOverlay:function(a,b){var c=this._jsPlumb.overlays[a];c&&(c.setVisible(!1),!b&&c.cleanup&&c.cleanup(),delete this._jsPlumb.overlays[a],this._jsPlumb.overlayPositions&&delete this._jsPlumb.overlayPositions[a])},removeOverlays:function(){for(var a=0,b=arguments.length;b>a;a++)this.removeOverlay(arguments[a])},moveParent:function(a){if(this.bgCanvas&&(this.bgCanvas.parentNode.removeChild(this.bgCanvas),a.appendChild(this.bgCanvas)),this.canvas&&this.canvas.parentNode){this.canvas.parentNode.removeChild(this.canvas),a.appendChild(this.canvas);for(var b in this._jsPlumb.overlays)if(this._jsPlumb.overlays[b].isAppendedAtTopLevel){var c=this._jsPlumb.overlays[b].getElement();c.parentNode.removeChild(c),a.appendChild(c)}}},getLabel:function(){var a=this.getOverlay(d);return null!=a?a.getLabel():null},getLabelOverlay:function(){return this.getOverlay(d)},setLabel:function(a){var b=this.getOverlay(d);if(b)a.constructor===String||a.constructor===Function?b.setLabel(a):(a.label&&b.setLabel(a.label),a.location&&b.setLocation(a.location));else{var c=a.constructor===String||a.constructor===Function?{label:a}:a;b=e(this,c),this._jsPlumb.overlays[d]=b}this._jsPlumb.instance.isSuspendDrawing()||this.repaint()},cleanup:function(a){for(var b in this._jsPlumb.overlays)this._jsPlumb.overlays[b].cleanup(a),this._jsPlumb.overlays[b].destroy(a);a&&(this._jsPlumb.overlays={},this._jsPlumb.overlayPositions=null)},setVisible:function(a){this[a?"showOverlays":"hideOverlays"]()},setAbsoluteOverlayPosition:function(a,b){this._jsPlumb.overlayPositions[a.id]=b},getAbsoluteOverlayPosition:function(a){return this._jsPlumb.overlayPositions?this._jsPlumb.overlayPositions[a.id]:null},_clazzManip:function(a,b,c){if(!c)for(var d in this._jsPlumb.overlays)this._jsPlumb.overlays[d][a+"Class"](b)},addClass:function(a,b){this._clazzManip("add",a,b)},removeClass:function(a,b){this._clazzManip("remove",a,b)}})}.call("undefined"!=typeof window?window:this),function(){"use strict";var a=this,b=a.jsPlumb,c=a.jsPlumbUtil,d=function(a,b,c){var d=!1;return{drag:function(){if(d)return d=!1,!0;if(b.element){var e=c.getUIPosition(arguments,c.getZoom());null!=e&&c.setPosition(b.element,e),c.repaint(b.element,e),a.paint({anchorPoint:a.anchor.getCurrentLocation({element:a})})}},stopDrag:function(){d=!0}}},e=function(a,b,c,d){var e=b.createElement("div",{position:"absolute"});b.appendElement(e);var f=b.getId(e);b.setPosition(e,c),e.style.width=d[0]+"px",e.style.height=d[1]+"px",b.manage(f,e,!0),a.id=f,a.element=e},f=function(a,c,d,e,f,g,h,i){var j=new b.FloatingAnchor({reference:c,referenceCanvas:e,jsPlumbInstance:g});return h({paintStyle:a,endpoint:d,anchor:j,source:f,scope:i})},g=["connectorStyle","connectorHoverStyle","connectorOverlays","connector","connectionType","connectorClass","connectorHoverClass"],h=function(a,b){var c=0;if(null!=b)for(var d=0;d0)for(var b=0;b0?"add":"remove")+"Class"](i.endpointConnectedClass),this[(this.isFull()?"add":"remove")+"Class"](i.endpointFullClass)},this.detachFromConnection=function(a,b,c){b=null==b?this.connections.indexOf(a):b,b>=0&&(this.connections.splice(b,1),this[(this.connections.length>0?"add":"remove")+"Class"](i.endpointConnectedClass),this[(this.isFull()?"add":"remove")+"Class"](i.endpointFullClass)),!c&&m&&0===this.connections.length&&i.deleteObject({endpoint:this,fireEvent:!1,deleteAttachedObjects:c!==!0})},this.deleteEveryConnection=function(a){for(var b=this.connections.length,c=0;b>c;c++)i.deleteConnection(this.connections[0],a)},this.detachFrom=function(a,b,c){for(var d=[],e=0;ef;f++)i.deleteConnection(d[0]);return this},this.getElement=function(){return this.element},this.setElement=function(d){var e=this._jsPlumb.instance.getId(d),f=this.elementId;return c.removeWithFunction(a.endpointsByElement[this.elementId],function(a){return a.id===this.id}.bind(this)),this.element=b.getElement(d),this.elementId=i.getId(this.element),i.anchorManager.rehomeEndpoint(this,f,this.element),i.dragManager.endpointAdded(this.element),c.addToList(a.endpointsByElement,e,this),this},this.makeInPlaceCopy=function(){var b=this.anchor.getCurrentLocation({element:this}),c=this.anchor.getOrientation(this),d=this.anchor.getCssClass(),e={bind:function(){},compute:function(){return[b[0],b[1]]},getCurrentLocation:function(){return[b[0],b[1]]},getOrientation:function(){return c},getCssClass:function(){return d}};return k({dropOptions:a.dropOptions,anchor:e,source:this.element,paintStyle:this.getPaintStyle(),endpoint:a.hideOnDrag?"Blank":this.endpoint,_transient:!0,scope:this.scope,reference:this})},this.connectorSelector=function(){return this.connections[0]},this.setStyle=this.setPaintStyle,this.paint=function(a){a=a||{};var b=a.timestamp,c=!(a.recalc===!1);if(!b||this.timestamp!==b){var d=i.updateOffset({elId:this.elementId,timestamp:b}),e=a.offset?a.offset.o:d.o;if(null!=e){var f=a.anchorPoint,g=a.connectorPaintStyle;if(null==f){var j=a.dimensions||d.s,k={xy:[e.left,e.top],wh:j,element:this,timestamp:b};if(c&&this.anchor.isDynamic&&this.connections.length>0){var l=h(this,a.elementWithPrecedence),m=l.endpoints[0]===this?1:0,n=0===m?l.sourceId:l.targetId,o=i.getCachedData(n),p=o.o,q=o.s;k.index=0===m?1:0,k.connection=l,k.txy=[p.left,p.top],k.twh=q,k.tElement=l.endpoints[m]}else this.connections.length>0&&(k.connection=this.connections[0]);f=this.anchor.compute(k)}this.endpoint.compute(f,this.anchor.getOrientation(this),this._jsPlumb.paintStyleInUse,g||this.paintStyleInUse),this.endpoint.paint(this._jsPlumb.paintStyleInUse,this.anchor),this.timestamp=b;for(var r in this._jsPlumb.overlays)if(this._jsPlumb.overlays.hasOwnProperty(r)){var s=this._jsPlumb.overlays[r];s.isVisible()&&(this._jsPlumb.overlayPlacements[r]=s.draw(this.endpoint,this._jsPlumb.paintStyleInUse),s.paint(this._jsPlumb.overlayPlacements[r]))}}}},this.getTypeDescriptor=function(){return"endpoint"},this.isVisible=function(){return this._jsPlumb.visible},this.repaint=this.paint;var p=!1;this.initDraggable=function(){if(!p&&b.isDragSupported(this.element)){var g,h={id:null,element:null},m=null,n=!1,o=null,q=d(this,h,i),r=a.dragOptions||{},s={},t=b.dragEvents.start,u=b.dragEvents.stop,v=b.dragEvents.drag,w=b.dragEvents.beforeStart,x=function(a){g=a.e.payload||{}},y=function(c){m=this.connectorSelector();var d=!0;this.isEnabled()||(d=!1),null!=m||this.isSource||this.isTemporarySource||(d=!1),!this.isSource||!this.isFull()||null!=m&&this.dragAllowedWhenFull||(d=!1),null==m||m.isDetachable(this)||(d=!1);var l=i.checkCondition(null==m?"beforeDrag":"beforeStartDetach",{endpoint:this,source:this.element,sourceId:this.elementId,connection:m});if(l===!1?d=!1:"object"==typeof l?b.extend(l,g||{}):l=g||{},d===!1)return i.stopDrag&&i.stopDrag(this.canvas),q.stopDrag(),!1;for(var p=0;p0}.bind(this),i.initDraggable(this.canvas,r,"internal"),this.canvas._jsPlumbRelatedElement=this.element,p=!0}};var q=a.endpoint||this._jsPlumb.instance.Defaults.Endpoint||b.Defaults.Endpoint;this.setEndpoint(q,!0);var r=a.anchor?a.anchor:a.anchors?a.anchors:i.Defaults.Anchor||"Top";this.setAnchor(r,!0);var s=["default",a.type||""].join(" ");this.addType(s,a.data,!0),this.canvas=this.endpoint.canvas,this.canvas._jsPlumb=this,this.initDraggable();var t=function(d,e,f,g){if(b.isDropSupported(this.element)){var h=a.dropOptions||i.Defaults.DropOptions||b.Defaults.DropOptions;h=b.extend({},h),h.scope=h.scope||this.scope;var j=b.dragEvents.drop,k=b.dragEvents.over,l=b.dragEvents.out,m=this,n=i.EndpointDropHandler({getEndpoint:function(){return m},jsPlumb:i,enabled:function(){return null!=f?f.isEnabled():!0},isFull:function(){return f.isFull()},element:this.element,elementId:this.elementId,isSource:this.isSource,isTarget:this.isTarget,addClass:function(a){m.addClass(a)},removeClass:function(a){m.removeClass(a)},isDropAllowed:function(){return m.isDropAllowed.apply(m,arguments)},reference:g,isRedrop:function(a,b){return a.suspendedEndpoint&&b.reference&&a.suspendedEndpoint.id===b.reference.id}});h[j]=c.wrap(h[j],n,!0),h[k]=c.wrap(h[k],function(){var a=b.getDragObject(arguments),c=i.getAttribute(b.getElement(a),"dragId"),d=i.getFloatingConnectionFor(c);if(null!=d){var e=i.getFloatingAnchorIndex(d),f=this.isTarget&&0!==e||d.suspendedEndpoint&&this.referenceEndpoint&&this.referenceEndpoint.id===d.suspendedEndpoint.id;if(f){var g=i.checkCondition("checkDropAllowed",{sourceEndpoint:d.endpoints[e],targetEndpoint:this,connection:d});this[(g?"add":"remove")+"Class"](i.endpointDropAllowedClass),this[(g?"remove":"add")+"Class"](i.endpointDropForbiddenClass),d.endpoints[e].anchor.over(this.anchor,this)}}}.bind(this)),h[l]=c.wrap(h[l],function(){var a=b.getDragObject(arguments),c=null==a?null:i.getAttribute(b.getElement(a),"dragId"),d=c?i.getFloatingConnectionFor(c):null;if(null!=d){var e=i.getFloatingAnchorIndex(d),f=this.isTarget&&0!==e||d.suspendedEndpoint&&this.referenceEndpoint&&this.referenceEndpoint.id===d.suspendedEndpoint.id;f&&(this.removeClass(i.endpointDropAllowedClass),this.removeClass(i.endpointDropForbiddenClass),d.endpoints[e].anchor.out())}}.bind(this)),i.initDroppable(d,h,"internal",e)}}.bind(this);return this.anchor.isFloating||t(this.canvas,!(a._transient||this.anchor.isFloating),this,a.reference),this},c.extend(b.Endpoint,b.OverlayCapableJsPlumbUIComponent,{setVisible:function(a,b,c){if(this._jsPlumb.visible=a,this.canvas&&(this.canvas.style.display=a?"block":"none"),this[a?"showOverlays":"hideOverlays"](),!b)for(var d=0;dc[0][0],d===!1?-1:1}},o=function(a,b){var c=a[0][0]<0?-Math.PI-a[0][0]:Math.PI-a[0][0],d=b[0][0]<0?-Math.PI-b[0][0]:Math.PI-b[0][0];return c>d?1:-1},p={top:function(a,b){return a[0]>b[0]?1:-1},right:n(!0),bottom:n(!0),left:o},q=function(a,b){return a.sort(b)},r=function(a,b){var c=k.getCachedData(a),d=c.s,f=c.o,h=function(b,c,d,f,h,i,j){if(f.length>0)for(var k=q(f,p[b]),l="right"===b||"top"===b,n=m(b,c,d,k,h,i,l),o=function(a,b){e[a.id]=[b[0],b[1],b[2],b[3]],g[a.id]=j},r=0;r-1&&(h[d].splice(i,1),b.addToList(h,e,[f,f.endpoints[0],f.endpoints[0].anchor.constructor===c.DynamicAnchor])),f.updateConnectedClass()},this.sourceChanged=function(a,d,e,f){if(a!==d){e.sourceId=d,e.source=f,b.removeWithFunction(h[a],function(a){return a[0].id===e.id});var g=b.findWithFunction(h[e.targetId],function(a){return a[0].id===e.id});g>-1&&(h[e.targetId][g][0]=e,h[e.targetId][g][1]=e.endpoints[0],h[e.targetId][g][2]=e.endpoints[0].anchor.constructor===c.DynamicAnchor),b.addToList(h,d,[e,e.endpoints[1],e.endpoints[1].anchor.constructor===c.DynamicAnchor]),e.endpoints[1].anchor.isContinuous&&(e.source===e.target?e._jsPlumb.instance.removeElement(e.endpoints[1].canvas):null==e.endpoints[1].canvas.parentNode&&e._jsPlumb.instance.appendElement(e.endpoints[1].canvas)),e.updateConnectedClass()}},this.rehomeEndpoint=function(a,b,c){var e=d[b]||[],f=k.getId(c);if(f!==b){var g=e.indexOf(a);if(g>-1){var h=e.splice(g,1)[0];i.add(h,f)}}for(var j=0;jb.dist?1:0});for(var o=k[0].source,p=k[0].target,q=0;q0?this.anchors[0]:null,f=e,g=this,h=function(a,b,c,d,e){var f=d[0]+a.x*e[0],g=d[1]+a.y*e[1],h=d[0]+e[0]/2,i=d[1]+e[1]/2;return Math.sqrt(Math.pow(b-f,2)+Math.pow(c-g,2))+Math.sqrt(Math.pow(h-f,2)+Math.pow(i-g,2))},i=a.selector||function(a,b,c,d,e){for(var f=c[0]+d[0]/2,g=c[1]+d[1]/2,i=-1,j=1/0,k=0;kl&&(i=k+0,j=l)}return e[i]};this.compute=function(a){var b=a.xy,c=a.wh,d=a.txy,h=a.twh;this.timestamp=a.timestamp;var j=g.getUserDefinedLocation();return null!=j?j:this.isLocked()||null==d||null==h?e.compute(a):(a.timestamp=null,e=i(b,c,d,h,this.anchors),this.x=e.x,this.y=e.y,e!==f&&this.fire("anchorChanged",e),f=e,e.compute(a))},this.getCurrentLocation=function(a){return this.getUserDefinedLocation()||(null!=e?e.getCurrentLocation(a):null)},this.getOrientation=function(a){return null!=e?e.getOrientation(a):[0,0]},this.over=function(a,b){null!=e&&e.over(a,b)},this.out=function(){null!=e&&e.out()},this.getCssClass=function(){return e&&e.getCssClass()||""}},b.extend(c.DynamicAnchor,c.Anchor);var e=function(a,b,d,e,f,g){c.Anchors[f]=function(c){var h=c.jsPlumbInstance.makeAnchor([a,b,d,e,0,0],c.elementId,c.jsPlumbInstance);return h.type=f,g&&g(h,c),h}};e(.5,0,0,-1,"TopCenter"),e(.5,1,0,1,"BottomCenter"),e(0,.5,-1,0,"LeftMiddle"),e(1,.5,1,0,"RightMiddle"),e(.5,0,0,-1,"Top"),e(.5,1,0,1,"Bottom"),e(0,.5,-1,0,"Left"),e(1,.5,1,0,"Right"),e(.5,.5,0,0,"Center"),e(1,0,0,-1,"TopRight"),e(1,1,0,1,"BottomRight"),e(0,0,0,-1,"TopLeft"),e(0,1,0,1,"BottomLeft"),c.Defaults.DynamicAnchors=function(a){return a.jsPlumbInstance.makeAnchors(["TopCenter","RightMiddle","BottomCenter","LeftMiddle"],a.elementId,a.jsPlumbInstance)},c.Anchors.AutoDefault=function(a){var b=a.jsPlumbInstance.makeDynamicAnchor(c.Defaults.DynamicAnchors(a));return b.type="AutoDefault",b};var f=function(a,b){c.Anchors[a]=function(c){var d=c.jsPlumbInstance.makeAnchor(["Continuous",{faces:b}],c.elementId,c.jsPlumbInstance);return d.type=a,d}};c.Anchors.Continuous=function(a){return a.jsPlumbInstance.continuousAnchorFactory.get(a)},f("ContinuousLeft",["left"]),f("ContinuousTop",["top"]),f("ContinuousBottom",["bottom"]),f("ContinuousRight",["right"]),e(0,0,0,0,"Assign",function(a,b){var c=b.position||"Fixed";a.positionFinder=c.constructor===String?b.jsPlumbInstance.AnchorPositionFinders[c]:c,a.constructorParams=b}),a.jsPlumbInstance.prototype.AnchorPositionFinders={Fixed:function(a,b,c){return[(a.left-b.left)/c[0],(a.top-b.top)/c[1]]},Grid:function(a,b,c,d){var e=a.left-b.left,f=a.top-b.top,g=c[0]/d.grid[0],h=c[1]/d.grid[1],i=Math.floor(e/g),j=Math.floor(f/h);return[(i*g+g/2)/c[0],(j*h+h/2)/c[1]]}},c.Anchors.Perimeter=function(a){a=a||{};var b=a.anchorCount||60,c=a.shape;if(!c)throw new Error("no shape supplied to Perimeter Anchor type");var d=function(){for(var a=.5,c=2*Math.PI/b,d=0,e=[],f=0;b>f;f++){var g=a+a*Math.sin(d),h=a+a*Math.cos(d);e.push([g,h,0,0]),d+=c}return e},e=function(a){for(var c=b/a.length,d=[],e=function(a,e,f,g,h){c=b*h;for(var i=(f-a)/c,j=(g-e)/c,k=0;c>k;k++)d.push([a+i*k,e+j*k,0,0])},f=0;f0?a:c+a:a*c;return d.pointOnLine({x:g,y:i},{x:h,y:j},e)}return{x:h,y:j}}return{x:g,y:i}},this.gradientAtPoint=function(a){return e},this.pointAlongPathFrom=function(a,b,c){var e=this.pointOnPath(a,c),f=0>=b?{x:g,y:i}:{x:h,y:j};return 0>=b&&Math.abs(b)>1&&(b*=-1),d.pointOnLine(e,f,b)};var l=function(a,b,c){return c>=Math.min(a,b)&&c<=Math.max(a,b)},m=function(a,b,c){return Math.abs(c-a)a-b?b:k>c-a?c:a};this.pointOnPath=function(b,c){if(0===b)return{x:this.x1,y:this.y1,theta:this.startAngle};if(1===b)return{x:this.x2,y:this.y2,theta:this.endAngle};c&&(b/=j);var d=e(this,b),f=a.cx+a.r*Math.cos(d),g=a.cy+a.r*Math.sin(d);return{x:l(f),y:l(g),theta:d}},this.gradientAtPoint=function(b,c){var e=this.pointOnPath(b,c),f=d.normal([a.cx,a.cy],[e.x,e.y]);return this.anticlockwise||f!==1/0&&f!==-(1/0)||(f*=-1),f},this.pointAlongPathFrom=function(b,c,d){var e=this.pointOnPath(b,d),f=c/h*2*Math.PI,g=this.anticlockwise?-1:1,i=e.theta+g*f,j=a.cx+this.radius*Math.cos(i),k=a.cy+this.radius*Math.sin(i);return{x:j,y:k}}},Bezier:function(c){this.curve=[{x:c.x1,y:c.y1},{x:c.cp1x,y:c.cp1y},{x:c.cp2x,y:c.cp2y},{x:c.x2,y:c.y2}];b.Segments.AbstractSegment.apply(this,arguments);this.bounds={minX:Math.min(c.x1,c.x2,c.cp1x,c.cp2x),minY:Math.min(c.y1,c.y2,c.cp1y,c.cp2y),maxX:Math.max(c.x1,c.x2,c.cp1x,c.cp2x),maxY:Math.max(c.y1,c.y2,c.cp1y,c.cp2y)},this.type="Bezier";var d=function(b,c,d){return d&&(c=a.jsBezier.locationAlongCurveFrom(b,c>0?0:1,c)),c};this.pointOnPath=function(b,c){return b=d(this.curve,b,c),a.jsBezier.pointOnCurve(this.curve,b)},this.gradientAtPoint=function(b,c){return b=d(this.curve,b,c),a.jsBezier.gradientAtPoint(this.curve,b)},this.pointAlongPathFrom=function(b,c,e){return b=d(this.curve,b,e),a.jsBezier.pointAlongCurveFrom(this.curve,b,c)},this.getLength=function(){return a.jsBezier.getLength(this.curve)},this.getBounds=function(){return this.bounds}}},b.SegmentRenderer={getPath:function(a){return{Straight:function(){var b=a.getCoordinates();return"M "+b.x1+" "+b.y1+" L "+b.x2+" "+b.y2},Bezier:function(){var b=a.params;return"M "+b.x1+" "+b.y1+" C "+b.cp1x+" "+b.cp1y+" "+b.cp2x+" "+b.cp2y+" "+b.x2+" "+b.y2},Arc:function(){var b=a.params,c=a.sweep>Math.PI?1:0,d=a.anticlockwise?0:1;return"M"+a.x1+" "+a.y1+" A "+a.radius+" "+b.r+" 0 "+c+","+d+" "+a.x2+" "+a.y2}}[a.type]()}};var e=function(){this.resetBounds=function(){this.bounds={minX:1/0,minY:1/0,maxX:-(1/0),maxY:-(1/0)}},this.resetBounds()};b.Connectors.AbstractConnector=function(a){e.apply(this,arguments);var f=[],g=0,h=[],i=[],j=a.stub||0,k=c.isArray(j)?j[0]:j,l=c.isArray(j)?j[1]:j,m=a.gap||0,n=c.isArray(m)?m[0]:m,o=c.isArray(m)?m[1]:m,p=null,q=null;this.getPathData=function(){for(var a="",c=0;c0?a/g:(g+a)/g);for(var c=h.length-1,d=1,e=0;e=a){c=e,d=1===a?1:0===a?0:(a-h[e][0])/i[e];break}return{segment:f[c],proportion:d,index:c}},t=function(a,c,d){if(d.x1!==d.x2||d.y1!==d.y2){var e=new b.Segments[c](d);f.push(e),g+=e.getLength(),a.updateBounds(e)}},u=function(){g=f.length=h.length=i.length=0};this.setSegments=function(a){p=[],g=0;for(var b=0;bp?0:1,r=[1,0][q];g=[],h=[],g[q]=a.sourcePos[q]>a.targetPos[q]?-1:1,h[q]=a.sourcePos[q]>a.targetPos[q]?1:-1,g[r]=0,h[r]=0}var s=c?m+n*g[0]:n*g[0],t=e?p+n*g[1]:n*g[1],u=c?o*h[0]:m+o*h[0],v=e?o*h[1]:p+o*h[1],w=g[0]*h[0]+g[1]*h[1],x={sx:s,sy:t,tx:u,ty:v,lw:f,xSpan:Math.abs(u-s),ySpan:Math.abs(v-t),mx:(s+u)/2,my:(t+v)/2,so:g,to:h,x:i,y:j,w:m,h:p,segment:b,startStubX:s+g[0]*k,startStubY:t+g[1]*k,endStubX:u+h[0]*l,endStubY:v+h[1]*l,isXGreaterThanStubTimes2:Math.abs(s-u)>k+l,isYGreaterThanStubTimes2:Math.abs(t-v)>k+l,opposite:-1===w,perpendicular:0===w,orthogonal:1===w,sourceAxis:0===g[0]?"y":"x",points:[i,j,m,p,s,t,u,v],stubs:[k,l]};return x.anchorOrientation=x.opposite?"opposite":x.orthogonal?"orthogonal":"perpendicular",x};this.getSegments=function(){return f},this.updateBounds=function(a){var b=a.getBounds();this.bounds.minX=Math.min(this.bounds.minX,b.minX),this.bounds.maxX=Math.max(this.bounds.maxX,b.maxX),this.bounds.minY=Math.min(this.bounds.minY,b.minY),this.bounds.maxY=Math.max(this.bounds.maxY,b.maxY)};return this.pointOnPath=function(a,b){var c=s(a,b);return c.segment&&c.segment.pointOnPath(c.proportion,!1)||[0,0]},this.gradientAtPoint=function(a,b){var c=s(a,b);return c.segment&&c.segment.gradientAtPoint(c.proportion,!1)||0},this.pointAlongPathFrom=function(a,b,c){var d=s(a,c);return d.segment&&d.segment.pointAlongPathFrom(d.proportion,b,!1)||[0,0]},this.compute=function(a){q=v.call(this,a),u(),this._compute(q,a),this.x=q.points[0],this.y=q.points[1],this.w=q.points[2],this.h=q.points[3],this.segment=q.segment,r()},{addSegment:t,prepareCompute:v,sourceStub:k,targetStub:l,maxStub:Math.max(k,l),sourceGap:n,targetGap:o,maxGap:Math.max(n,o)}},c.extend(b.Connectors.AbstractConnector,e),b.Endpoints.AbstractEndpoint=function(a){e.apply(this,arguments);var b=this.compute=function(a,b,c,d){var e=this._compute.apply(this,arguments);return this.x=e[0],this.y=e[1],this.w=e[2],this.h=e[3],this.bounds.minX=this.x,this.bounds.minY=this.y,this.bounds.maxX=this.x+this.w,this.bounds.maxY=this.y+this.h,e};return{compute:b,cssClass:a.cssClass}},c.extend(b.Endpoints.AbstractEndpoint,e),b.Endpoints.Dot=function(a){this.type="Dot";b.Endpoints.AbstractEndpoint.apply(this,arguments);a=a||{},this.radius=a.radius||10,this.defaultOffset=.5*this.radius,this.defaultInnerRadius=this.radius/3,this._compute=function(a,b,c,d){this.radius=c.radius||this.radius;var e=a[0]-this.radius,f=a[1]-this.radius,g=2*this.radius,h=2*this.radius;if(c.stroke){var i=c.strokeWidth||1;e-=i,f-=i,g+=2*i,h+=2*i}return[e,f,g,h,this.radius]}},c.extend(b.Endpoints.Dot,b.Endpoints.AbstractEndpoint),b.Endpoints.Rectangle=function(a){this.type="Rectangle";b.Endpoints.AbstractEndpoint.apply(this,arguments);a=a||{},this.width=a.width||20,this.height=a.height||20,this._compute=function(a,b,c,d){var e=c.width||this.width,f=c.height||this.height,g=a[0]-e/2,h=a[1]-f/2;return[g,h,e,f]}},c.extend(b.Endpoints.Rectangle,b.Endpoints.AbstractEndpoint);var f=function(a){b.jsPlumbUIComponent.apply(this,arguments),this._jsPlumb.displayElements=[]};c.extend(f,b.jsPlumbUIComponent,{getDisplayElements:function(){return this._jsPlumb.displayElements},appendDisplayElement:function(a){this._jsPlumb.displayElements.push(a)}}),b.Endpoints.Image=function(d){this.type="Image",f.apply(this,arguments),b.Endpoints.AbstractEndpoint.apply(this,arguments);var e=d.onload,g=d.src||d.url,h=d.cssClass?" "+d.cssClass:"";this._jsPlumb.img=new Image,this._jsPlumb.ready=!1,this._jsPlumb.initialized=!1,this._jsPlumb.deleted=!1,this._jsPlumb.widthToUse=d.width,this._jsPlumb.heightToUse=d.height,this._jsPlumb.endpoint=d.endpoint,this._jsPlumb.img.onload=function(){null!=this._jsPlumb&&(this._jsPlumb.ready=!0,this._jsPlumb.widthToUse=this._jsPlumb.widthToUse||this._jsPlumb.img.width,this._jsPlumb.heightToUse=this._jsPlumb.heightToUse||this._jsPlumb.img.height,e&&e(this))}.bind(this),this._jsPlumb.endpoint.setImage=function(a,b){var c=a.constructor===String?a:a.src;e=b,this._jsPlumb.img.src=c,null!=this.canvas&&this.canvas.setAttribute("src",this._jsPlumb.img.src)}.bind(this),this._jsPlumb.endpoint.setImage(g,e),this._compute=function(a,b,c,d){return this.anchorPoint=a,this._jsPlumb.ready?[a[0]-this._jsPlumb.widthToUse/2,a[1]-this._jsPlumb.heightToUse/2,this._jsPlumb.widthToUse,this._jsPlumb.heightToUse]:[0,0,0,0]},this.canvas=b.createElement("img",{position:"absolute",margin:0,padding:0,outline:0},this._jsPlumb.instance.endpointClass+h),this._jsPlumb.widthToUse&&this.canvas.setAttribute("width",this._jsPlumb.widthToUse),this._jsPlumb.heightToUse&&this.canvas.setAttribute("height",this._jsPlumb.heightToUse),this._jsPlumb.instance.appendElement(this.canvas),this.actuallyPaint=function(a,b,d){if(!this._jsPlumb.deleted){this._jsPlumb.initialized||(this.canvas.setAttribute("src",this._jsPlumb.img.src),this.appendDisplayElement(this.canvas),this._jsPlumb.initialized=!0);var e=this.anchorPoint[0]-this._jsPlumb.widthToUse/2,f=this.anchorPoint[1]-this._jsPlumb.heightToUse/2;c.sizeElement(this.canvas,e,f,this._jsPlumb.widthToUse,this._jsPlumb.heightToUse)}},this.paint=function(b,c){null!=this._jsPlumb&&(this._jsPlumb.ready?this.actuallyPaint(b,c):a.setTimeout(function(){this.paint(b,c)}.bind(this),200))}},c.extend(b.Endpoints.Image,[f,b.Endpoints.AbstractEndpoint],{cleanup:function(a){a&&(this._jsPlumb.deleted=!0,this.canvas&&this.canvas.parentNode.removeChild(this.canvas),this.canvas=null)}}),b.Endpoints.Blank=function(a){b.Endpoints.AbstractEndpoint.apply(this,arguments);this.type="Blank",f.apply(this,arguments),this._compute=function(a,b,c,d){return[a[0],a[1],10,0]};var d=a.cssClass?" "+a.cssClass:"";this.canvas=b.createElement("div",{display:"block",width:"1px",height:"1px",background:"transparent",position:"absolute"},this._jsPlumb.instance.endpointClass+d),this._jsPlumb.instance.appendElement(this.canvas),this.paint=function(a,b){c.sizeElement(this.canvas,this.x,this.y,this.w,this.h)}},c.extend(b.Endpoints.Blank,[b.Endpoints.AbstractEndpoint,f],{cleanup:function(){this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}}),b.Endpoints.Triangle=function(a){this.type="Triangle",b.Endpoints.AbstractEndpoint.apply(this,arguments);var c=this;a=a||{},a.width=a.width||55,a.height=a.height||55,this.width=a.width,this.height=a.height,this._compute=function(a,b,d,e){var f=d.width||c.width,g=d.height||c.height,h=a[0]-f/2,i=a[1]-g/2;return[h,i,f,g]}};var g=b.Overlays.AbstractOverlay=function(a){this.visible=!0,this.isAppendedAtTopLevel=!0,this.component=a.component,this.loc=null==a.location?.5:a.location,this.endpointLoc=null==a.endpointLocation?[.5,.5]:a.endpointLocation,this.visible=a.visible!==!1};g.prototype={cleanup:function(a){a&&(this.component=null,this.canvas=null,this.endpointLoc=null)},reattach:function(a,b){},setVisible:function(a){this.visible=a,this.component.repaint()},isVisible:function(){return this.visible},hide:function(){this.setVisible(!1)},show:function(){this.setVisible(!0)},incrementLocation:function(a){this.loc+=a,this.component.repaint()},setLocation:function(a){this.loc=a,this.component.repaint()},getLocation:function(){return this.loc},updateFrom:function(){}},b.Overlays.Arrow=function(a){this.type="Arrow",g.apply(this,arguments),this.isAppendedAtTopLevel=!1,a=a||{};var e=this;this.length=a.length||20,this.width=a.width||20,this.id=a.id;var f=(a.direction||1)<0?-1:1,h=a.paintStyle||{"stroke-width":1},i=a.foldback||.623;this.computeMaxSize=function(){return 1.5*e.width},this.elementCreated=function(c,d){if(this.path=c,a.events)for(var e in a.events)b.on(c,e,a.events[e])},this.draw=function(a,b){var e,g,j,k,l;if(a.pointAlongPathFrom){if(c.isString(this.loc)||this.loc>1||this.loc<0){var m=parseInt(this.loc,10),n=this.loc<0?1:0;e=a.pointAlongPathFrom(n,m,!1),g=a.pointAlongPathFrom(n,m-f*this.length/2,!1),j=d.pointOnLine(e,g,this.length)}else if(1===this.loc){if(e=a.pointOnPath(this.loc),g=a.pointAlongPathFrom(this.loc,-this.length),j=d.pointOnLine(e,g,this.length),-1===f){var o=j;j=e,e=o}}else if(0===this.loc){if(j=a.pointOnPath(this.loc),g=a.pointAlongPathFrom(this.loc,this.length),e=d.pointOnLine(j,g,this.length),-1===f){var p=j;j=e,e=p}}else e=a.pointAlongPathFrom(this.loc,f*this.length/2),g=a.pointOnPath(this.loc),j=d.pointOnLine(e,g,this.length);k=d.perpendicularLineTo(e,j,this.width),l=d.pointOnLine(e,j,i*this.length);var q={hxy:e,tail:k,cxy:l},r=h.stroke||b.stroke,s=h.fill||b.stroke,t=h.strokeWidth||b.strokeWidth;return{component:a,d:q,"stroke-width":t,stroke:r,fill:s,minX:Math.min(e.x,k[0].x,k[1].x),maxX:Math.max(e.x,k[0].x,k[1].x),minY:Math.min(e.y,k[0].y,k[1].y),maxY:Math.max(e.y,k[0].y,k[1].y)}}return{component:a,minX:0,maxX:0,minY:0,maxY:0}}},c.extend(b.Overlays.Arrow,g,{updateFrom:function(a){this.length=a.length||this.length,this.width=a.width||this.width,this.direction=null!=a.direction?a.direction:this.direction,this.foldback=a.foldback||this.foldback}}),b.Overlays.PlainArrow=function(a){a=a||{};var c=b.extend(a,{foldback:1});b.Overlays.Arrow.call(this,c),this.type="PlainArrow"},c.extend(b.Overlays.PlainArrow,b.Overlays.Arrow),b.Overlays.Diamond=function(a){a=a||{};var c=a.length||40,d=b.extend(a,{length:c/2,foldback:2});b.Overlays.Arrow.call(this,d),this.type="Diamond"},c.extend(b.Overlays.Diamond,b.Overlays.Arrow);var h=function(a,b){return(null==a._jsPlumb.cachedDimensions||b)&&(a._jsPlumb.cachedDimensions=a.getDimensions()),a._jsPlumb.cachedDimensions},i=function(a){b.jsPlumbUIComponent.apply(this,arguments),g.apply(this,arguments);var d=this.fire;this.fire=function(){d.apply(this,arguments),this.component&&this.component.fire.apply(this.component,arguments)},this.detached=!1,this.id=a.id,this._jsPlumb.div=null,this._jsPlumb.initialised=!1, -this._jsPlumb.component=a.component,this._jsPlumb.cachedDimensions=null,this._jsPlumb.create=a.create,this._jsPlumb.initiallyInvisible=a.visible===!1,this.getElement=function(){if(null==this._jsPlumb.div){var c=this._jsPlumb.div=b.getElement(this._jsPlumb.create(this._jsPlumb.component));c.style.position="absolute",c.className=this._jsPlumb.instance.overlayClass+" "+(this.cssClass?this.cssClass:a.cssClass?a.cssClass:""),this._jsPlumb.instance.appendElement(c),this._jsPlumb.instance.getId(c),this.canvas=c;var d="translate(-50%, -50%)";c.style.webkitTransform=d,c.style.mozTransform=d,c.style.msTransform=d,c.style.oTransform=d,c.style.transform=d,c._jsPlumb=this,a.visible===!1&&(c.style.display="none")}return this._jsPlumb.div},this.draw=function(a,b,d){var e=h(this);if(null!=e&&2===e.length){var f={x:0,y:0};if(d)f={x:d[0],y:d[1]};else if(a.pointOnPath){var g=this.loc,i=!1;(c.isString(this.loc)||this.loc<0||this.loc>1)&&(g=parseInt(this.loc,10),i=!0),f=a.pointOnPath(g,i)}else{var j=this.loc.constructor===Array?this.loc:this.endpointLoc;f={x:j[0]*a.w,y:j[1]*a.h}}var k=f.x-e[0]/2,l=f.y-e[1]/2;return{component:a,d:{minx:k,miny:l,td:e,cxy:f},minX:k,maxX:k+e[0],minY:l,maxY:l+e[1]}}return{minX:0,maxX:0,minY:0,maxY:0}}};c.extend(i,[b.jsPlumbUIComponent,g],{getDimensions:function(){return[1,1]},setVisible:function(a){this._jsPlumb.div&&(this._jsPlumb.div.style.display=a?"block":"none",a&&this._jsPlumb.initiallyInvisible&&(h(this,!0),this.component.repaint(),this._jsPlumb.initiallyInvisible=!1))},clearCachedDimensions:function(){this._jsPlumb.cachedDimensions=null},cleanup:function(a){a?null!=this._jsPlumb.div&&(this._jsPlumb.div._jsPlumb=null,this._jsPlumb.instance.removeElement(this._jsPlumb.div)):(this._jsPlumb&&this._jsPlumb.div&&this._jsPlumb.div.parentNode&&this._jsPlumb.div.parentNode.removeChild(this._jsPlumb.div),this.detached=!0)},reattach:function(a,b){null!=this._jsPlumb.div&&a.getContainer().appendChild(this._jsPlumb.div),this.detached=!1},computeMaxSize:function(){var a=h(this);return Math.max(a[0],a[1])},paint:function(a,b){this._jsPlumb.initialised||(this.getElement(),a.component.appendDisplayElement(this._jsPlumb.div),this._jsPlumb.initialised=!0,this.detached&&this._jsPlumb.div.parentNode.removeChild(this._jsPlumb.div)),this._jsPlumb.div.style.left=a.component.x+a.d.minx+"px",this._jsPlumb.div.style.top=a.component.y+a.d.miny+"px"}}),b.Overlays.Custom=function(a){this.type="Custom",i.apply(this,arguments)},c.extend(b.Overlays.Custom,i),b.Overlays.GuideLines=function(){var a=this;a.length=50,a.strokeWidth=5,this.type="GuideLines",g.apply(this,arguments),b.jsPlumbUIComponent.apply(this,arguments),this.draw=function(b,c){var e=b.pointAlongPathFrom(a.loc,a.length/2),f=b.pointOnPath(a.loc),g=d.pointOnLine(e,f,a.length),h=d.perpendicularLineTo(e,g,40),i=d.perpendicularLineTo(g,e,20);return{connector:b,head:e,tail:g,headLine:i,tailLine:h,minX:Math.min(e.x,g.x,i[0].x,i[1].x),minY:Math.min(e.y,g.y,i[0].y,i[1].y),maxX:Math.max(e.x,g.x,i[0].x,i[1].x),maxY:Math.max(e.y,g.y,i[0].y,i[1].y)}}},b.Overlays.Label=function(a){this.labelStyle=a.labelStyle;this.cssClass=null!=this.labelStyle?this.labelStyle.cssClass:null;var c=b.extend({create:function(){return b.createElement("div")}},a);if(b.Overlays.Custom.call(this,c),this.type="Label",this.label=a.label||"",this.labelText=null,this.labelStyle){var d=this.getElement();if(this.labelStyle.font=this.labelStyle.font||"12px sans-serif",d.style.font=this.labelStyle.font,d.style.color=this.labelStyle.color||"black",this.labelStyle.fill&&(d.style.background=this.labelStyle.fill),this.labelStyle.borderWidth>0){var e=this.labelStyle.borderStyle?this.labelStyle.borderStyle:"black";d.style.border=this.labelStyle.borderWidth+"px solid "+e}this.labelStyle.padding&&(d.style.padding=this.labelStyle.padding)}},c.extend(b.Overlays.Label,b.Overlays.Custom,{cleanup:function(a){a&&(this.div=null,this.label=null,this.labelText=null,this.cssClass=null,this.labelStyle=null)},getLabel:function(){return this.label},setLabel:function(a){this.label=a,this.labelText=null,this.clearCachedDimensions(),this.update(),this.component.repaint()},getDimensions:function(){return this.update(),i.prototype.getDimensions.apply(this,arguments)},update:function(){if("function"==typeof this.label){var a=this.label(this);this.getElement().innerHTML=a.replace(/\r\n/g,"
")}else null==this.labelText&&(this.labelText=this.label,this.getElement().innerHTML=this.labelText.replace(/\r\n/g,"
"))},updateFrom:function(a){null!=a.label&&this.setLabel(a.label)}})}.call("undefined"!=typeof window?window:this),function(){"use strict";var a=this,b=a.jsPlumb,c=function(b){var c=b._mottle;return c||(c=b._mottle=new a.Mottle),c};b.extend(a.jsPlumbInstance.prototype,{getEventManager:function(){return c(this)},on:function(a,b,c){return this.getEventManager().on.apply(this,arguments),this},off:function(a,b,c){return this.getEventManager().off.apply(this,arguments),this}})}.call("undefined"!=typeof window?window:this),function(){"use strict";var a=this,b=a.jsPlumbUtil,c=a.jsPlumbInstance,d="jtk-group-collapsed",e="jtk-group-expanded",f="[jtk-group-content]",g="elementDraggable",h="stop",i="revert",j="_groupManager",k="_jsPlumbGroup",l="_jsPlumbGroupDrag",m="group:addMember",n="group:removeMember",o="group:add",p="group:remove",q="group:expand",r="group:collapse",s="groupDragStop",t="connectionMoved",u="internal.connectionDetached",v="removeAll",w="orphanAll",x="show",y="hide",z=function(a){function c(a){delete a.proxies;var c,d=i[a.id];null!=d&&(c=function(b){return b.id===a.id},b.removeWithFunction(d.connections.source,c),b.removeWithFunction(d.connections.target,c),delete i[a.id]),d=j[a.id],null!=d&&(c=function(b){return b.id===a.id},b.removeWithFunction(d.connections.source,c),b.removeWithFunction(d.connections.target,c),delete j[a.id])}function f(b,c){for(var d=b.getMembers(),e=0;e0&&h0&&j0?a[0]:v},x=d.ghost===!0,y=x||d.constrain===!0,z=d.revert!==!1,A=d.orphan===!0,B=d.prune===!0,C=d.dropOverride===!0,D=d.proxied!==!1,E=[];if(this.connections={source:[],target:[],internal:[]},this.getAnchor=function(a,b){return d.anchor||"Continuous"},this.getEndpoint=function(a,b){return d.endpoint||["Dot",{radius:10}]},this.collapsed=!1,d.draggable!==!1){var F={stop:function(a){c.fire(s,jsPlumb.extend(a,{group:u}))},scope:l};d.dragOptions&&a.jsPlumb.extend(F,d.dragOptions),c.draggable(d.el,F)}d.droppable!==!1&&c.droppable(d.el,{drop:function(a){var b=a.drag.el;if(!b._isJsPlumbGroup){var d=b._jsPlumbGroup;if(d!==u){if(null!=d&&d.overrideDrop(b,u))return;c.getGroupManager().addToGroup(u,b,!1)}}}});var G=function(a,b){for(var c=null==a.nodeType?a:[a],d=0;dd;d++)u.remove(E[0],a,b,!0);E.length=0,c.getGroupManager().updateConnectionsForGroup(u)},this.orphanAll=function(){for(var a=0;aa?-1:0===a?0:1}),n=function(a){return[m(a[2]-a[0]),m(a[3]-a[1])]},o=function(a,b,c,d){if(j!==b||k!==c){var e=null==j?d.sx:j,f=null==k?d.sy:k,g=e===b?"v":"h";j=b,k=c,a.push([e,f,b,c,g])}},p=function(a){return Math.sqrt(Math.pow(a[0]-a[2],2)+Math.pow(a[1]-a[3],2))},q=function(a){var b=[];return b.push.apply(b,a),b},r=function(a,b,c){for(var f,h,i,j=null,k=0;k0&&j[4]!==f[4]){var m=Math.min(p(j),p(f)),o=Math.min(l,m/2);j[2]-=h[0]*o,j[3]-=h[1]*o,f[0]+=i[0]*o,f[1]+=i[1]*o;var r=h[1]===i[0]&&1===i[0]||h[1]===i[0]&&0===i[0]&&h[0]!==i[1]||h[1]===i[0]&&-1===i[0],s=f[1]>j[3]?1:-1,t=f[0]>j[2]?1:-1,u=s===t,v=u&&r||!u&&!r?f[0]:j[2],w=u&&r||!u&&!r?j[3]:f[1];g.addSegment(a,d,{x1:j[0],y1:j[1],x2:j[2],y2:j[3]}),g.addSegment(a,e,{r:o,x1:j[2],y1:j[3],x2:f[0],y2:f[1],cx:v,cy:w,ac:r})}else{var x=j[2]===j[0]?0:j[2]>j[0]?c.lw/2:-(c.lw/2),y=j[3]===j[1]?0:j[3]>j[1]?c.lw/2:-(c.lw/2);g.addSegment(a,d,{x1:j[0]-x,y1:j[1]-y,x2:j[2]+x,y2:j[3]+y})}j=f}null!=f&&g.addSegment(a,d,{x1:f[0],y1:f[1],x2:f[2],y2:f[3]})};this._compute=function(a,b){c=[],j=null,k=null,f=null;var d=function(){return[a.startStubX,a.startStubY,a.endStubX,a.endStubY]},e={perpendicular:d,orthogonal:d,opposite:function(b){var c=a,d="x"===b?0:1,e={x:function(){return 1===c.so[d]&&(c.startStubX>c.endStubX&&c.tx>c.startStubX||c.sx>c.endStubX&&c.tx>c.sx)||-1===c.so[d]&&(c.startStubXc.endStubY&&c.ty>c.startStubY||c.sy>c.endStubY&&c.ty>c.sy)||-1===c.so[d]&&(c.startStubYj[b][0],p=e[b][m][0],q=e[b][m][1],r=d[b][m][n];return c.segment===r[3]||c.segment===r[2]&&o?f[b]:c.segment===r[2]&&p>q?g[b]:c.segment===r[2]&&q>=p||c.segment===r[1]&&!o?i[b]:c.segment===r[0]||c.segment===r[1]&&o?h[b]:void 0},orthogonal:function(b,c,d,e,f){var g=a,h={x:-1===g.so[0]?Math.min(c,e):Math.max(c,e),y:-1===g.so[1]?Math.min(c,e):Math.max(c,e)}[b];return{x:[[h,d],[h,f],[e,f]],y:[[d,h],[f,h],[f,e]]}[b]},opposite:function(c,d,e,f){var h=a,i={x:"y",y:"x"}[c],j={x:"height",y:"width"}[c],k=h["is"+c.toUpperCase()+"GreaterThanStubTimes2"];if(b.sourceEndpoint.elementId===b.targetEndpoint.elementId){var l=e+(1-b.sourceEndpoint.anchor[i])*b.sourceInfo[j]+g.maxStub;return{x:[[d,l],[f,l]],y:[[l,d],[l,f]]}[c]}return!k||1===h.so[m]&&d>f||-1===h.so[m]&&f>d?{x:[[d,v],[f,v]],y:[[u,d],[u,f]]}[c]:1===h.so[m]&&f>d||-1===h.so[m]&&d>f?{x:[[u,h.sy],[u,h.ty]],y:[[h.sx,v],[h.tx,v]]}[c]:void 0}},y=x[a.anchorOrientation](a.sourceAxis,p,q,s,t);if(y)for(var z=0;z=a&&b>=d?1:c>=a&&d>=b?2:a>=c&&d>=b?3:4},e=function(a,b,c,d,e,f,g,h,i){return i>=h?[a,b]:1===c?d[3]<=0&&e[3]>=1?[a+(d[2]<.5?-1*f:f),b]:d[2]>=1&&e[2]<=0?[a,b+(d[3]<.5?-1*g:g)]:[a+-1*f,b+-1*g]:2===c?d[3]>=1&&e[3]<=0?[a+(d[2]<.5?-1*f:f),b]:d[2]>=1&&e[2]<=0?[a,b+(d[3]<.5?-1*g:g)]:[a+f,b+-1*g]:3===c?d[3]>=1&&e[3]<=0?[a+(d[2]<.5?-1*f:f),b]:d[2]<=0&&e[2]>=1?[a,b+(d[3]<.5?-1*g:g)]:[a+-1*f,b+-1*g]:4===c?d[3]<=0&&e[3]>=1?[a+(d[2]<.5?-1*f:f),b]:d[2]<=0&&e[2]>=1?[a,b+(d[3]<.5?-1*g:g)]:[a+f,b+-1*g]:void 0},f=function(a){a=a||{},this.type="StateMachine";var c,f=b.Connectors.AbstractBezierConnector.apply(this,arguments),g=a.curviness||10,h=a.margin||5,i=a.proximityLimit||80;a.orientation&&"clockwise"===a.orientation;this._computeBezier=function(a,b,j,k,l,m){var n=b.sourcePos[0]c?a.insertBefore(b,a.childNodes[c]):a.appendChild(b)};c.svg={node:t,attr:s,pos:u};var z=function(a){var d=a.pointerEventsSpec||"all",e={};b.jsPlumbUIComponent.apply(this,a.originalArgs),this.canvas=null,this.path=null,this.svg=null,this.bgCanvas=null;var f=a.cssClass+" "+(a.originalArgs[0].cssClass||""),g={style:"",width:0,height:0,"pointer-events":d,position:"absolute"};this.svg=t("svg",g),a.useDivWrapper?(this.canvas=b.createElement("div",{position:"absolute"}),c.sizeElement(this.canvas,0,0,1,1),this.canvas.className=f):(s(this.svg,{"class":f}),this.canvas=this.svg),a._jsPlumb.appendElement(this.canvas,a.originalArgs[0].parent),a.useDivWrapper&&this.canvas.appendChild(this.svg);var h=[this.canvas];return this.getDisplayElements=function(){return h},this.appendDisplayElement=function(a){h.push(a)},this.paint=function(b,d,f){if(null!=b){var g,h=[this.x,this.y],i=[this.w,this.h];null!=f&&(f.xmin<0&&(h[0]+=f.xmin),f.ymin<0&&(h[1]+=f.ymin),i[0]=f.xmax+(f.xmin<0?-f.xmin:0),i[1]=f.ymax+(f.ymin<0?-f.ymin:0)),a.useDivWrapper?(c.sizeElement(this.canvas,h[0],h[1],i[0],i[1]),h[0]=0,h[1]=0,g=u([0,0])):g=u([h[0],h[1]]),e.paint.apply(this,arguments),s(this.svg,{style:g,width:i[0]||0,height:i[1]||0})}},{renderer:e}};c.extend(z,b.jsPlumbUIComponent,{cleanup:function(a){a||null==this.typeId?(this.canvas&&(this.canvas._jsPlumb=null),this.svg&&(this.svg._jsPlumb=null),this.bgCanvas&&(this.bgCanvas._jsPlumb=null),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.bgCanvas&&this.bgCanvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.svg=null,this.canvas=null,this.path=null,this.group=null):(this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.bgCanvas&&this.bgCanvas.parentNode&&this.bgCanvas.parentNode.removeChild(this.bgCanvas))},reattach:function(a){var b=a.getContainer();this.canvas&&null==this.canvas.parentNode&&b.appendChild(this.canvas),this.bgCanvas&&null==this.bgCanvas.parentNode&&b.appendChild(this.bgCanvas)},setVisible:function(a){this.canvas&&(this.canvas.style.display=a?"block":"none")}}),b.ConnectorRenderers.svg=function(a){var c=this,d=z.apply(this,[{cssClass:a._jsPlumb.connectorClass,originalArgs:arguments,pointerEventsSpec:"none",_jsPlumb:a._jsPlumb}]);d.renderer.paint=function(d,e,f){var g=c.getSegments(),h="",i=[0,0];if(f.xmin<0&&(i[0]=-f.xmin),f.ymin<0&&(i[1]=-f.ymin),g.length>0){h=c.getPathData();var j={d:h,transform:"translate("+i[0]+","+i[1]+")","pointer-events":a["pointer-events"]||"visibleStroke"},k=null,l=[c.x,c.y,c.w,c.h];if(d.outlineStroke){var m=d.outlineWidth||1,n=d.strokeWidth+2*m;k=b.extend({},d),delete k.gradient,k.stroke=d.outlineStroke,k.strokeWidth=n,null==c.bgPath?(c.bgPath=t("path",j),b.addClass(c.bgPath,b.connectorOutlineClass),y(c.svg,c.bgPath,0)):s(c.bgPath,j),x(c.svg,c.bgPath,k,l,c)}null==c.path?(c.path=t("path",j),y(c.svg,c.path,d.outlineStroke?1:0)):s(c.path,j),x(c.svg,c.path,d,l,c)}}},c.extend(b.ConnectorRenderers.svg,z);var A=b.SvgEndpoint=function(a){var c=z.apply(this,[{cssClass:a._jsPlumb.endpointClass,originalArgs:arguments,pointerEventsSpec:"all",useDivWrapper:!0,_jsPlumb:a._jsPlumb}]);c.renderer.paint=function(a){var c=b.extend({},a);c.outlineStroke&&(c.stroke=c.outlineStroke),null==this.node?(this.node=this.makeNode(c),this.svg.appendChild(this.node)):null!=this.updateNode&&this.updateNode(this.node),x(this.svg,this.node,c,[this.x,this.y,this.w,this.h],this),u(this.node,[this.x,this.y])}.bind(this)};c.extend(A,z),b.Endpoints.svg.Dot=function(){b.Endpoints.Dot.apply(this,arguments),A.apply(this,arguments),this.makeNode=function(a){return t("circle",{cx:this.w/2,cy:this.h/2,r:this.radius})},this.updateNode=function(a){s(a,{cx:this.w/2,cy:this.h/2,r:this.radius})}},c.extend(b.Endpoints.svg.Dot,[b.Endpoints.Dot,A]),b.Endpoints.svg.Rectangle=function(){b.Endpoints.Rectangle.apply(this,arguments),A.apply(this,arguments),this.makeNode=function(a){return t("rect",{width:this.w,height:this.h})},this.updateNode=function(a){s(a,{width:this.w,height:this.h})}},c.extend(b.Endpoints.svg.Rectangle,[b.Endpoints.Rectangle,A]),b.Connectors.svg.Flowchart=function(){b.Connectors.Flowchart.apply(this,arguments),b.ConnectorRenderers.svg.apply(this,arguments)},c.extend(b.Connectors.svg.Flowchart,[b.Connectors.Flowchart,b.ConnectorRenderers.svg]),b.Connectors.svg.Bezier=function(){b.Connectors.Bezier.apply(this,arguments),b.ConnectorRenderers.svg.apply(this,arguments)},c.extend(b.Connectors.svg.Bezier,[b.Connectors.Bezier,b.ConnectorRenderers.svg]),b.Connectors.svg.Straight=function(){b.Connectors.Straight.apply(this,arguments),b.ConnectorRenderers.svg.apply(this,arguments)},c.extend(b.Connectors.svg.Straight,[b.Connectors.Straight,b.ConnectorRenderers.svg]),b.Connectors.svg.StateMachine=function(){b.Connectors.StateMachine.apply(this,arguments),b.ConnectorRenderers.svg.apply(this,arguments)},c.extend(b.Connectors.svg.StateMachine,[b.Connectors.StateMachine,b.ConnectorRenderers.svg]),b.Endpoints.svg.Image=b.Endpoints.Image,b.Endpoints.svg.Blank=b.Endpoints.Blank,b.Overlays.svg.Label=b.Overlays.Label,b.Overlays.svg.Custom=b.Overlays.Custom;var B=function(a,c){a.apply(this,c),b.jsPlumbUIComponent.apply(this,c),this.isAppendedAtTopLevel=!1;this.path=null,this.paint=function(a,b){if(a.component.svg&&b){null==this.path&&(this.path=t("path",{"pointer-events":"all"}),a.component.svg.appendChild(this.path),this.elementCreated&&this.elementCreated(this.path,a.component),this.canvas=a.component.svg);var e=c&&1===c.length?c[0].cssClass||"":"",f=[0,0];b.xmin<0&&(f[0]=-b.xmin),b.ymin<0&&(f[1]=-b.ymin),s(this.path,{d:d(a.d),"class":e,stroke:a.stroke?a.stroke:null,fill:a.fill?a.fill:null,transform:"translate("+f[0]+","+f[1]+")"})}};var d=function(a){return isNaN(a.cxy.x)||isNaN(a.cxy.y)?"":"M"+a.hxy.x+","+a.hxy.y+" L"+a.tail[0].x+","+a.tail[0].y+" L"+a.cxy.x+","+a.cxy.y+" L"+a.tail[1].x+","+a.tail[1].y+" L"+a.hxy.x+","+a.hxy.y};this.transfer=function(a){a.canvas&&this.path&&this.path.parentNode&&(this.path.parentNode.removeChild(this.path),a.canvas.appendChild(this.path))}};c.extend(B,[b.jsPlumbUIComponent,b.Overlays.AbstractOverlay],{cleanup:function(a){null!=this.path&&(a?this._jsPlumb.instance.removeElement(this.path):this.path.parentNode&&this.path.parentNode.removeChild(this.path))},reattach:function(a,b){this.path&&b.canvas&&b.canvas.appendChild(this.path)},setVisible:function(a){null!=this.path&&(this.path.style.display=a?"block":"none")}}),b.Overlays.svg.Arrow=function(){B.apply(this,[b.Overlays.Arrow,arguments])},c.extend(b.Overlays.svg.Arrow,[b.Overlays.Arrow,B]),b.Overlays.svg.PlainArrow=function(){B.apply(this,[b.Overlays.PlainArrow,arguments])},c.extend(b.Overlays.svg.PlainArrow,[b.Overlays.PlainArrow,B]), -b.Overlays.svg.Diamond=function(){B.apply(this,[b.Overlays.Diamond,arguments])},c.extend(b.Overlays.svg.Diamond,[b.Overlays.Diamond,B]),b.Overlays.svg.GuideLines=function(){var a,c,d=null,e=this;b.Overlays.GuideLines.apply(this,arguments),this.paint=function(b,g){null==d&&(d=t("path"),b.connector.svg.appendChild(d),e.attachListeners(d,b.connector),e.attachListeners(d,e),a=t("path"),b.connector.svg.appendChild(a),e.attachListeners(a,b.connector),e.attachListeners(a,e),c=t("path"),b.connector.svg.appendChild(c),e.attachListeners(c,b.connector),e.attachListeners(c,e));var h=[0,0];g.xmin<0&&(h[0]=-g.xmin),g.ymin<0&&(h[1]=-g.ymin),s(d,{d:f(b.head,b.tail),stroke:"red",fill:null,transform:"translate("+h[0]+","+h[1]+")"}),s(a,{d:f(b.tailLine[0],b.tailLine[1]),stroke:"blue",fill:null,transform:"translate("+h[0]+","+h[1]+")"}),s(c,{d:f(b.headLine[0],b.headLine[1]),stroke:"green",fill:null,transform:"translate("+h[0]+","+h[1]+")"})};var f=function(a,b){return"M "+a.x+","+a.y+" L"+b.x+","+b.y}},c.extend(b.Overlays.svg.GuideLines,b.Overlays.GuideLines)}.call("undefined"!=typeof window?window:this),function(){"use strict";var a=this,b=a.jsPlumb,c=a.jsPlumbUtil,d=a.Katavorio,e=a.Biltong,f=function(a,c){c=c||"main";var f="_katavorio_"+c,g=a[f],h=a.getEventManager();return g||(g=new d({bind:h.on,unbind:h.off,getSize:b.getSize,getConstrainingRectangle:function(a){return[a.parentNode.scrollWidth,a.parentNode.scrollHeight]},getPosition:function(b,c){var d=a.getOffset(b,c,b._katavorioDrag?b.offsetParent:null);return[d.left,d.top]},setPosition:function(a,b){a.style.left=b[0]+"px",a.style.top=b[1]+"px"},addClass:b.addClass,removeClass:b.removeClass,intersects:e.intersects,indexOf:function(a,b){return a.indexOf(b)},scope:a.getDefaultScope(),css:{noSelect:a.dragSelectClass,droppable:"jtk-droppable",draggable:"jtk-draggable",drag:"jtk-drag",selected:"jtk-drag-selected",active:"jtk-drag-active",hover:"jtk-drag-hover",ghostProxy:"jtk-ghost-proxy"}}),g.setZoom(a.getZoom()),a[f]=g,a.bind("zoom",g.setZoom)),g},g=function(a,b){var d=function(d){if(null!=b[d]){if(c.isString(b[d])){var e=b[d].match(/-=/)?-1:1,f=b[d].substring(2);return a[d]+e*f}return b[d]}return a[d]};return[d("left"),d("top")]};b.extend(a.jsPlumbInstance.prototype,{animationSupported:!0,getElement:function(a){return null==a?null:(a="string"==typeof a?a:null!=a.length&&null==a.enctype?a[0]:a,"string"==typeof a?document.getElementById(a):a)},removeElement:function(a){f(this).elementRemoved(a),this.getEventManager().remove(a)},doAnimate:function(a,c,d){d=d||{};var e=this.getOffset(a),f=g(e,c),h=f[0]-e.left,i=f[1]-e.top,j=d.duration||250,k=15,l=j/k,m=k/j*h,n=k/j*i,o=0,p=setInterval(function(){b.setPosition(a,{left:e.left+m*(o+1),top:e.top+n*(o+1)}),null!=d.step&&d.step(o,Math.ceil(l)),o++,o>=l&&(window.clearInterval(p),null!=d.complete&&d.complete())},k)},destroyDraggable:function(a,b){f(this,b).destroyDraggable(a)},unbindDraggable:function(a,b,c,d){f(this,d).destroyDraggable(a,b,c)},destroyDroppable:function(a,b){f(this,b).destroyDroppable(a)},unbindDroppable:function(a,b,c,d){f(this,d).destroyDroppable(a,b,c)},initDraggable:function(a,b,c){f(this,c).draggable(a,b)},initDroppable:function(a,b,c){f(this,c).droppable(a,b)},isAlreadyDraggable:function(a){return null!=a._katavorioDrag},isDragSupported:function(a,b){return!0},isDropSupported:function(a,b){return!0},isElementDraggable:function(a){return a=b.getElement(a),a._katavorioDrag&&a._katavorioDrag.isEnabled()},getDragObject:function(a){return a[0].drag.getDragElement()},getDragScope:function(a){return a._katavorioDrag&&a._katavorioDrag.scopes.join(" ")||""},getDropEvent:function(a){return a[0].e},getUIPosition:function(a,b){var c=a[0].el;if(null==c.offsetParent)return null;var d=a[0].finalPos||a[0].pos,e={left:d[0],top:d[1]};if(c._katavorioDrag&&c.offsetParent!==this.getContainer()){var f=this.getOffset(c.offsetParent);e.left+=f.left,e.top+=f.top}return e},setDragFilter:function(a,b,c){a._katavorioDrag&&a._katavorioDrag.setFilter(b,c)},setElementDraggable:function(a,c){a=b.getElement(a),a._katavorioDrag&&a._katavorioDrag.setEnabled(c)},setDragScope:function(a,b){a._katavorioDrag&&a._katavorioDrag.k.setDragScope(a,b)},setDropScope:function(a,b){a._katavorioDrop&&a._katavorioDrop.length>0&&a._katavorioDrop[0].k.setDropScope(a,b)},addToPosse:function(a,c){var d=Array.prototype.slice.call(arguments,1),e=f(this);b.each(a,function(a){a=[b.getElement(a)],a.push.apply(a,d),e.addToPosse.apply(e,a)})},setPosse:function(a,c){var d=Array.prototype.slice.call(arguments,1),e=f(this);b.each(a,function(a){a=[b.getElement(a)],a.push.apply(a,d),e.setPosse.apply(e,a)})},removeFromPosse:function(a,c){var d=Array.prototype.slice.call(arguments,1),e=f(this);b.each(a,function(a){a=[b.getElement(a)],a.push.apply(a,d),e.removeFromPosse.apply(e,a)})},removeFromAllPosses:function(a){var c=f(this);b.each(a,function(a){c.removeFromAllPosses(b.getElement(a))})},setPosseState:function(a,c,d){var e=f(this);b.each(a,function(a){e.setPosseState(b.getElement(a),c,d)})},dragEvents:{start:"start",stop:"stop",drag:"drag",step:"step",over:"over",out:"out",drop:"drop",complete:"complete",beforeStart:"beforeStart"},animEvents:{step:"step",complete:"complete"},stopDrag:function(a){a._katavorioDrag&&a._katavorioDrag.abort()},addToDragSelection:function(a){f(this).select(a)},removeFromDragSelection:function(a){f(this).deselect(a)},clearDragSelection:function(){f(this).deselectAll()},trigger:function(a,b,c,d){this.getEventManager().trigger(a,b,c,d)},doReset:function(){for(var a in this)0===a.indexOf("_katavorio_")&&this[a].reset()}});var h=function(a){var b=function(){/complete|loaded|interactive/.test(document.readyState)&&"undefined"!=typeof document.body&&null!=document.body?a():setTimeout(b,9)};b()};h(b.init)}.call("undefined"!=typeof window?window:this); +(function(){"undefined"==typeof Math.sgn&&(Math.sgn=function(a){return 0==a?0:a>0?1:-1});var a={subtract:function(a,b){return{x:a.x-b.x,y:a.y-b.y}},dotProduct:function(a,b){return a.x*b.x+a.y*b.y},square:function(a){return Math.sqrt(a.x*a.x+a.y*a.y)},scale:function(a,b){return{x:a.x*b,y:a.y*b}}},b=64,c=Math.pow(2,-b-1),d=function(b,c){for(var d=[],e=f(b,c),h=c.length-1,i=2*h-1,j=g(e,i,d,0),k=a.subtract(b,c[0]),m=a.square(k),n=0,o=0;j>o;o++){k=a.subtract(b,l(c,h,d[o],null,null));var p=a.square(k);m>p&&(m=p,n=d[o])}return k=a.subtract(b,c[h]),p=a.square(k),m>p&&(m=p,n=1),{location:n,distance:m}},e=function(a,b){var c=d(a,b);return{point:l(b,b.length-1,c.location,null,null),location:c.location}},f=function(b,c){for(var d=c.length-1,e=2*d-1,f=[],g=[],h=[],i=[],k=[[1,.6,.3,.1],[.4,.6,.6,.4],[.1,.3,.6,1]],l=0;d>=l;l++)f[l]=a.subtract(c[l],b);for(var l=0;d-1>=l;l++)g[l]=a.subtract(c[l+1],c[l]),g[l]=a.scale(g[l],3);for(var m=0;d-1>=m;m++)for(var n=0;d>=n;n++)h[m]||(h[m]=[]),h[m][n]=a.dotProduct(g[m],f[n]);for(l=0;e>=l;l++)i[l]||(i[l]=[]),i[l].y=0,i[l].x=parseFloat(l)/e;for(var o=d,p=d-1,q=0;o+p>=q;q++){var r=Math.max(0,q-p),s=Math.min(q,o);for(l=r;s>=l;l++)j=q-l,i[l+j].y+=h[j][l]*k[j][l]}return i},g=function(a,c,d,e){var f,j,m=[],n=[],o=[],p=[];switch(h(a,c)){case 0:return 0;case 1:if(e>=b)return d[0]=(a[0].x+a[c].x)/2,1;if(i(a,c))return d[0]=k(a,c),1}l(a,c,.5,m,n),f=g(m,c,o,e+1),j=g(n,c,p,e+1);for(var q=0;f>q;q++)d[q]=o[q];for(var q=0;j>q;q++)d[q+f]=p[q];return f+j},h=function(a,b){var c,d,e=0;c=d=Math.sgn(a[0].y);for(var f=1;b>=f;f++)c=Math.sgn(a[f].y),c!=d&&e++,d=c;return e},i=function(a,b){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;i=a[0].y-a[b].y,j=a[b].x-a[0].x,k=a[0].x*a[b].y-a[b].x*a[0].y;for(var t=max_distance_below=0,u=1;b>u;u++){var v=i*a[u].x+j*a[u].y+k;v>t?t=v:vd?1:0},k=function(a,b){var c=1,d=0,e=a[b].x-a[0].x,f=a[b].y-a[0].y,g=a[0].x-0,h=a[0].y-0,i=e*d-f*c,j=1/i,k=(e*h-f*g)*j;return 0+c*k},l=function(a,b,c,d,e){for(var f=[[]],g=0;b>=g;g++)f[0][g]=a[g];for(var h=1;b>=h;h++)for(var g=0;b-h>=g;g++)f[h]||(f[h]=[]),f[h][g]||(f[h][g]={}),f[h][g].x=(1-c)*f[h-1][g].x+c*f[h-1][g+1].x,f[h][g].y=(1-c)*f[h-1][g].y+c*f[h-1][g+1].y;if(null!=d)for(g=0;b>=g;g++)d[g]=f[g][0];if(null!=e)for(g=0;b>=g;g++)e[g]=f[b-g][g];return f[b][0]},m={},n=function(a){var b=m[a];if(!b){b=[];var c=function(){return function(b){return Math.pow(b,a)}},d=function(){return function(b){return Math.pow(1-b,a)}},e=function(a){return function(b){return a}},f=function(){return function(a){return a}},g=function(){return function(a){return 1-a}},h=function(a){return function(b){for(var c=1,d=0;di;i++){for(var j=[new e(a)],k=0;a-i>k;k++)j.push(new f);for(var k=0;i>k;k++)j.push(new g);b.push(new h(j))}b.push(new d),m[a]=b}return b},o=function(a,b){for(var c=n(a.length-1),d=0,e=0,f=0;f0?1:-1,h=null;ed;)d+=.005*e,f=o(a,d),c+=p(f,b),b=f;return c},t=function(a,b,c){return r(a,b,c).point},u=function(a,b,c){return r(a,b,c).location},v=function(a,b){var c=o(a,b),d=o(a.slice(0,a.length-1),b),e=d.y-c.y,f=d.x-c.x;return 0==e?1/0:Math.atan(e/f)},w=function(a,b,c){var d=r(a,b,c);return d.location>1&&(d.location=1),d.location<0&&(d.location=0),v(a,d.location)},x=function(a,b,c,d){d=null==d?0:d;var e=r(a,b,d),f=v(a,e.location),g=Math.atan(-1/f),h=c/2*Math.sin(g),i=c/2*Math.cos(g);return[{x:e.point.x+i,y:e.point.y+h},{x:e.point.x-i,y:e.point.y-h}]},y=this.jsBezier={distanceFromCurve:d,gradientAtPoint:v,gradientAtPointAlongCurveFrom:w,nearestPointOnCurve:e,pointOnCurve:o,pointAlongCurveFrom:t,perpendicularToCurveAt:x,locationAlongCurveFrom:u,getLength:s,version:"0.9.0"};"undefined"!=typeof exports&&(exports.jsBezier=y)}).call("undefined"!=typeof window?window:this),function(){"use strict";var a=this,b=a.Biltong={version:"0.4.0"};"undefined"!=typeof exports&&(exports.Biltong=b);var c=function(a){return"[object Array]"===Object.prototype.toString.call(a)},d=function(a,b,d){return a=c(a)?a:[a.x,a.y],b=c(b)?b:[b.x,b.y],d(a,b)},e=b.gradient=function(a,b){return d(a,b,function(a,b){return b[0]==a[0]?b[1]>a[1]?1/0:-(1/0):b[1]==a[1]?b[0]>a[0]?0:-0:(b[1]-a[1])/(b[0]-a[0])})},f=(b.normal=function(a,b){return-1/e(a,b)},b.lineLength=function(a,b){return d(a,b,function(a,b){return Math.sqrt(Math.pow(b[1]-a[1],2)+Math.pow(b[0]-a[0],2))})},b.quadrant=function(a,b){return d(a,b,function(a,b){return b[0]>a[0]?b[1]>a[1]?2:1:b[0]==a[0]?b[1]>a[1]?2:1:b[1]>a[1]?3:4})}),g=(b.theta=function(a,b){return d(a,b,function(a,b){var c=e(a,b),d=Math.atan(c),g=f(a,b);return(4==g||3==g)&&(d+=Math.PI),0>d&&(d+=2*Math.PI),d})},b.intersects=function(a,b){var c=a.x,d=a.x+a.w,e=a.y,f=a.y+a.h,g=b.x,h=b.x+b.w,i=b.y,j=b.y+b.h;return g>=c&&d>=g&&i>=e&&f>=i||h>=c&&d>=h&&i>=e&&f>=i||g>=c&&d>=g&&j>=e&&f>=j||h>=c&&d>=g&&j>=e&&f>=j||c>=g&&h>=c&&e>=i&&j>=e||d>=g&&h>=d&&e>=i&&j>=e||c>=g&&h>=c&&f>=i&&j>=f||d>=g&&h>=c&&f>=i&&j>=f},b.encloses=function(a,b,c){var d=a.x,e=a.x+a.w,f=a.y,g=a.y+a.h,h=b.x,i=b.x+b.w,j=b.y,k=b.y+b.h,l=function(a,b,d,e){return c?b>=a&&d>=e:b>a&&d>e};return l(d,h,e,i)&&l(f,j,g,k)},[null,[1,-1],[1,1],[-1,1],[-1,-1]]),h=[null,[-1,-1],[-1,1],[1,1],[1,-1]];b.pointOnLine=function(a,b,c){var d=e(a,b),i=f(a,b),j=c>0?g[i]:h[i],k=Math.atan(d),l=Math.abs(c*Math.sin(k))*j[1],m=Math.abs(c*Math.cos(k))*j[0];return{x:a.x+m,y:a.y+l}},b.perpendicularLineTo=function(a,b,c){var d=e(a,b),f=Math.atan(-1/d),g=c/2*Math.sin(f),h=c/2*Math.cos(f);return[{x:b.x+h,y:b.y+g},{x:b.x-h,y:b.y-g}]}}.call("undefined"!=typeof window?window:this),function(){"use strict";var a=this,b={android:navigator.userAgent.toLowerCase().indexOf("android")>-1},c=function(a,b,c){c=c||a.parentNode;for(var d=c.querySelectorAll(b),e=0;ec&&a[c]!=b;c++);c-1&&9>v,x=function(a,b){if(null==a)return[0,0];var c=C(a),d=B(c,0);return[d[b+"X"],d[b+"Y"]]},y=function(a){return null==a?[0,0]:w?[a.clientX+document.documentElement.scrollLeft,a.clientY+document.documentElement.scrollTop]:x(a,"page")},z=function(a){return x(a,"screen")},A=function(a){return x(a,"client")},B=function(a,b){return a.item?a.item(b):a[b]},C=function(a){return a.touches&&a.touches.length>0?a.touches:a.changedTouches&&a.changedTouches.length>0?a.changedTouches:a.targetTouches&&a.targetTouches.length>0?a.targetTouches:[a]},D=function(a){return C(a).length},E=function(a,b,c,d){if(i(a,b,c),d.__tauid=c.__tauid,a.addEventListener)a.addEventListener(b,c,!1);else if(a.attachEvent){var e=b+c.__tauid;a["e"+e]=c,a[e]=function(){a["e"+e]&&a["e"+e](window.event)},a.attachEvent("on"+b,a[e])}},F=function(a,b,c){null!=c&&G(a,function(){var e=d(this);if(j(e,b,c),null!=c.__tauid)if(e.removeEventListener)e.removeEventListener(b,c,!1),s&&u[b]&&e.removeEventListener(u[b],c,!1);else if(this.detachEvent){var f=b+c.__tauid;e[f]&&e.detachEvent("on"+b,e[f]),e[f]=null,e["e"+f]=null}c.__taTouchProxy&&F(a,c.__taTouchProxy[1],c.__taTouchProxy[0])})},G=function(a,b){if(null!=a){a="undefined"!=typeof Window&&"unknown"!=typeof a.top&&a==a.top?[a]:"string"!=typeof a&&null==a.tagName&&null!=a.length?a:"string"==typeof a?document.querySelectorAll(a):[a];for(var c=0;c-1&&9>h,l=9===h,m=function(a){if(k)return[a.clientX+document.documentElement.scrollLeft,a.clientY+document.documentElement.scrollTop];var b=o(a),c=n(b,0);return l?[c.pageX||c.clientX,c.pageY||c.clientY]:[c.pageX,c.pageY]},n=function(a,b){return a.item?a.item(b):a[b]},o=function(a){return a.touches&&a.touches.length>0?a.touches:a.changedTouches&&a.changedTouches.length>0?a.changedTouches:a.targetTouches&&a.targetTouches.length>0?a.targetTouches:[a]},p={draggable:"katavorio-draggable",droppable:"katavorio-droppable",drag:"katavorio-drag",selected:"katavorio-drag-selected",active:"katavorio-drag-active",hover:"katavorio-drag-hover",noSelect:"katavorio-drag-no-select",ghostProxy:"katavorio-ghost-proxy",clonedDrag:"katavorio-clone-drag"},q="katavorio-drag-scope",r=["stop","start","drag","drop","over","out","beforeStart"],s=function(){},t=function(){return!0},u=function(a,b,c){for(var d=0;d1)for(var f=0;f0&&W&&b.setPosition(this.el,W),T.sort(G);for(var e=0;eb.rank?-1:0},H=function(a){return null==a?null:(a="string"==typeof a||a.constructor===String?document.getElementById(a):a,null==a?null:(a._katavorio=a._katavorio||F(),a))};a.Katavorio=function(a){var f=[],g={};this._dragsByScope={},this._dropsByScope={};var h=1,i=function(a,b){w(a,function(a){for(var c=0;c0},k=(this.getMatchingDroppables=function(a){for(var b=[],c={},d=0;d=0&&f.splice(d,1),j(a[b],c)&&w(a[b],function(a){a.destroy()}),delete a[b]}},B=function(a,b,c,d){a=H(a),a[b]&&a[b].off(c,d)};this.elementRemoved=function(a){this.destroyDraggable(a),this.destroyDroppable(a)},this.destroyDraggable=function(a,b,c){1===arguments.length?A(a,"_katavorioDrag",this._dragsByScope):B(a,"_katavorioDrag",b,c)},this.destroyDroppable=function(a,b,c){1===arguments.length?A(a,"_katavorioDrop",this._dropsByScope):B(a,"_katavorioDrop",b,c)},this.reset=function(){this._dragsByScope={},this._dropsByScope={},f=[],g={},C={}};var C={},F=function(a,c,d){var f=e(c)?c:c.id,g=e(c)?!0:c.active!==!1,h=C[f]||function(){var a={name:f,members:[]};return C[f]=a,a}();return w(a,function(a){if(a._katavorioDrag){if(d&&null!=a._katavorioDrag.posseRoles[h.name])return;b(h.members,a._katavorioDrag),b(a._katavorioDrag.posses,h.name),a._katavorioDrag.posseRoles[h.name]=g}}),h};this.addToPosse=function(a,b){for(var c=[],d=1;d0}function j(a){for(var b in a)if(a.hasOwnProperty(b))return!1;return!0}function k(b){if(c(b))return""+b;if(d(b))return!!b;if(g(b))return new Date(b.getTime());if(h(b))return b;if(a(b)){for(var e=[],i=0;i=f.length,i=function(){return e[g[1]]||function(){return e[g[1]]=[],e[g[1]]}()};if(h)g?i()[g[3]]=c:e[a]=c;else if(g){var j=i();e=j[g[3]]||function(){return j[g[3]]={},j[g[3]]}()}else e=e[a]||function(){return e[a]={},e[a]}();return""}),a}}function n(a,b,c){for(var d=0;d-1&&a.splice(c,1),-1!==c}function r(a,b){var c=a.indexOf(b);return c>-1&&a.splice(c,1),-1!==c}function s(a,b,c){-1===p(a,c)&&a.push(b)}function t(a,b,c,d){var e=a[b];return null==e&&(e=[],a[b]=e),e[d?"unshift":"push"](c),e}function u(a,b,c){return-1===a.indexOf(b)?(c?a.unshift(b):a.push(b),!0):!1}function v(b,c,d){var e;c=a(c)?c:[c];var f=function(a){for(var c=a.__proto__;null!=c;)if(null!=c.prototype){for(var d in c.prototype)c.prototype.hasOwnProperty(d)&&!b.prototype.hasOwnProperty(d)&&(b.prototype[d]=c.prototype[d]);c=c.prototype.__proto__}else c=null};for(e=0;e2)for(e=2;ee&&g!==!1;){if(this.eventsToDieOn[a])this._listeners[a][e].apply(this,[b,c]);else try{g=this._listeners[a][e].apply(this,[b,c])}catch(h){B("jsPlumb: fire failed for event "+a+" : "+h)}e++,(null==this._listeners||null==this._listeners[a])&&(f=!0)}}this.tick=!1,this._drain()}return this},this._drain=function(){var b=a.queue.pop();b&&a.fire.apply(a,b)},this.unbind=function(a,b){if(0===arguments.length)this._listeners={};else if(1===arguments.length){if("string"==typeof a)delete this._listeners[a];else if(a.__jsPlumb){var c=void 0;for(var d in a.__jsPlumb)c=a.__jsPlumb[d],r(this._listeners[c]||[],a)}}else 2===arguments.length&&r(this._listeners[a]||[],b);return this},this.getListener=function(b){return a._listeners[b]},this.setSuspendEvents=function(b){a.eventsSuspended=b},this.isSuspendEvents=function(){return a.eventsSuspended},this.silently=function(b){a.setSuspendEvents(!0);try{b()}catch(c){B("Cannot execute silent function "+c)}a.setSuspendEvents(!1)},this.cleanupListeners=function(){for(var b in a._listeners)a._listeners[b]=null}}return a}();E.isArray=a,E.isNumber=b,E.isString=c,E.isBoolean=d,E.isNull=e,E.isObject=f,E.isDate=g,E.isFunction=h,E.isNamedFunction=i,E.isEmpty=j,E.clone=k,E.merge=l,E.replace=m,E.functionChain=n,E.populate=o,E.findWithFunction=p,E.removeWithFunction=q,E.remove=r,E.addWithFunction=s,E.addToList=t,E.suggest=u,E.extend=v,E.uuid=w,E.fastTrim=x,E.each=y,E.map=z,E.mergeWithParents=A,E.logEnabled=F,E.log=B,E.wrap=C,E.EventGenerator=G}.call("undefined"!=typeof window?window:this),function(){"use strict";var a=this;a.jsPlumbUtil.matchesSelector=function(a,b,c){c=c||a.parentNode;for(var d=c.querySelectorAll(b),e=0;ef;f++)d&&d===e[f]||e[f].setHover(b,!0,c)},g=function(a){return null==a?null:a.split(" ")},h=function(a,b,c){for(var d in b)a[d]=c},i=function(a,c){c=b.isArray(c)||null!=c.length&&!b.isString(c)?c:[c];for(var d=0;dj;j++){var l=a._jsPlumb.types[j];if("__default"!==l){var m=a._jsPlumb.instance.getType(l,e);null!=m&&(i=b.merge(i,m,["cssClass"]),h(f,m,l))}}c&&(i=b.populate(i,c,"_")),a.applyType(i,d,f),d||a.repaint()}},k=a.jsPlumbUIComponent=function(a){b.EventGenerator.apply(this,arguments);var c=this,d=arguments,e=c.idPrefix,f=e+(new Date).getTime();this._jsPlumb={instance:a._jsPlumb,parameters:a.parameters||{},paintStyle:null,hoverPaintStyle:null,paintStyleInUse:null,hover:!1,beforeDetach:a.beforeDetach,beforeDrop:a.beforeDrop,overlayPlacements:[],hoverClass:a.hoverClass||a._jsPlumb.Defaults.HoverClass,types:[],typeCache:{}},this.cacheTypeItem=function(a,b,c){this._jsPlumb.typeCache[c]=this._jsPlumb.typeCache[c]||{},this._jsPlumb.typeCache[c][a]=b},this.getCachedTypeItem=function(a,b){return this._jsPlumb.typeCache[b]?this._jsPlumb.typeCache[b][a]:null},this.getId=function(){return f};var g=a.overlays||[],h={};if(this.defaultOverlayKeys){for(var i=0;if;f++)this.hasType(d[f])||(this._jsPlumb.types.push(d[f]),e=!0);e&&j(this,b,c)}},removeType:function(a,b,c){var d=g(a),e=!1,f=function(a){var b=this._jsPlumb.types.indexOf(a);return-1!==b?(l(this,b),this._jsPlumb.types.splice(b,1),!0):!1}.bind(this);if(null!=d){for(var h=0,i=d.length;i>h;h++)e=f(d[h])||e;e&&j(this,b,c)}},clearTypes:function(a,b){for(var c=this._jsPlumb.types.length,d=0;c>d;d++)l(this,0),this._jsPlumb.types.splice(0,1);j(this,a,b)},toggleType:function(a,b,c){var d=g(a);if(null!=d){for(var e=0,f=d.length;f>e;e++){var h=this._jsPlumb.types.indexOf(d[e]);-1!==h?(l(this,h),this._jsPlumb.types.splice(h,1)):this._jsPlumb.types.push(d[e])}j(this,b,c)}},applyType:function(a,b){if(this.setPaintStyle(a.paintStyle,b),this.setHoverPaintStyle(a.hoverPaintStyle,b),a.parameters)for(var c in a.parameters)this.setParameter(c,a.parameters[c]);this._jsPlumb.paintStyleInUse=this.getPaintStyle()},setPaintStyle:function(a,b){this._jsPlumb.paintStyle=a,this._jsPlumb.paintStyleInUse=this._jsPlumb.paintStyle,d(this),b||this.repaint()},getPaintStyle:function(){return this._jsPlumb.paintStyle},setHoverPaintStyle:function(a,b){this._jsPlumb.hoverPaintStyle=a,d(this),b||this.repaint()},getHoverPaintStyle:function(){return this._jsPlumb.hoverPaintStyle},destroy:function(a){(a||null==this.typeId)&&(this.cleanupListeners(),this.clone=null,this._jsPlumb=null)},isHover:function(){return this._jsPlumb.hover},setHover:function(a,b,d){if(this._jsPlumb&&!this._jsPlumb.instance.currentlyDragging&&!this._jsPlumb.instance.isHoverSuspended()){this._jsPlumb.hover=a;var e=a?"addClass":"removeClass";null!=this.canvas&&(null!=this._jsPlumb.instance.hoverClass&&this._jsPlumb.instance[e](this.canvas,this._jsPlumb.instance.hoverClass),null!=this._jsPlumb.hoverClass&&this._jsPlumb.instance[e](this.canvas,this._jsPlumb.hoverClass)),null!=this._jsPlumb.hoverPaintStyle&&(this._jsPlumb.paintStyleInUse=a?this._jsPlumb.hoverPaintStyle:this._jsPlumb.paintStyle,this._jsPlumb.instance.isSuspendDrawing()||(d=d||c(),this.repaint({timestamp:d,recalc:!1}))),this.getAttachedElements&&!b&&f(this,a,c(),this)}}});var m=0,n=function(){var a=m+1;return m++,a},o=a.jsPlumbInstance=function(d){this.version="2.7.9",this.Defaults={Anchor:"Bottom",Anchors:[null,null],ConnectionsDetachable:!0,ConnectionOverlays:[],Connector:"Bezier",Container:null,DoNotThrowErrors:!1,DragOptions:{},DropOptions:{},Endpoint:"Dot",EndpointOverlays:[],Endpoints:[null,null],EndpointStyle:{fill:"#456"},EndpointStyles:[null,null],EndpointHoverStyle:null,EndpointHoverStyles:[null,null],HoverPaintStyle:null,LabelStyle:{color:"black"},LogEnabled:!1,Overlays:[],MaxConnections:1,PaintStyle:{"stroke-width":4,stroke:"#456"},ReattachConnections:!1,RenderMode:"svg",Scope:"jsPlumb_DefaultScope"},d&&p.extend(this.Defaults,d),this.logEnabled=this.Defaults.LogEnabled,this._connectionTypes={},this._endpointTypes={},b.EventGenerator.apply(this);var f=this,g=n(),h=f.bind,j={},l=1,m=function(a){if(null==a)return null;if(3===a.nodeType||8===a.nodeType)return{el:a,text:!0};var c=f.getElement(a);return{el:c,id:b.isString(a)&&null==c?a:Y(c)}};this.getInstanceIndex=function(){return g},this.setZoom=function(a,b){return l=a,f.fire("zoom",l),b&&f.repaintEverything(),!0},this.getZoom=function(){return l};for(var o in this.Defaults)j[o]=this.Defaults[o];var q,r=[];this.unbindContainer=function(){if(null!=q&&r.length>0)for(var a=0;ae;e++)d.overlays.push(d.sourceEndpoint.connectorOverlays[e])}d.sourceEndpoint&&d.sourceEndpoint.scope&&(d.scope=d.sourceEndpoint.scope),!d["pointer-events"]&&d.sourceEndpoint&&d.sourceEndpoint.connectorPointerEvents&&(d["pointer-events"]=d.sourceEndpoint.connectorPointerEvents);var h=function(a,b,c){return f.addEndpoint(a,N(b,{anchor:d.anchors?d.anchors[c]:d.anchor,endpoint:d.endpoints?d.endpoints[c]:d.endpoint,paintStyle:d.endpointStyles?d.endpointStyles[c]:d.endpointStyle,hoverPaintStyle:d.endpointHoverStyles?d.endpointHoverStyles[c]:d.endpointHoverStyle}))},i=function(a,b,c,e){if(d[a]&&!d[a].endpoint&&!d[a+"Endpoint"]&&!d.newConnection){var f=Y(d[a]),g=c[f];if(g=g?g[e]:null){if(!g.enabled)return!1;var i=null!=g.endpoint&&g.endpoint._jsPlumb?g.endpoint:h(d[a],g.def,b);if(i.isFull())return!1;d[a+"Endpoint"]=i,!d.scope&&g.def.scope&&(d.scope=g.def.scope),g.uniqueEndpoint?g.endpoint?i.finalEndpoint=g.endpoint:(g.endpoint=i,i.setDeleteOnEmpty(!1)):i.setDeleteOnEmpty(!0),0===b&&g.def.connectorOverlays&&(d.overlays=d.overlays||[],Array.prototype.push.apply(d.overlays,g.def.connectorOverlays))}}};return i("source",0,this.sourceEndpointDefinitions,d.type||"default")!==!1&&i("target",1,this.targetEndpointDefinitions,d.type||"default")!==!1?(d.sourceEndpoint&&d.targetEndpoint&&(M(d.sourceEndpoint,d.targetEndpoint)||(d=null)),d):void 0}.bind(f),P=function(a){var b=f.Defaults.ConnectionType||f.getDefaultConnectionType();a._jsPlumb=f,a.newConnection=P,a.newEndpoint=R,a.endpointsByUUID=w,a.endpointsByElement=v,a.finaliseConnection=Q,a.id="con_"+H();var c=new b(a);return c.isDetachable()&&(c.endpoints[0].initDraggable("_jsPlumbSource"),c.endpoints[1].initDraggable("_jsPlumbTarget")),c},Q=f.finaliseConnection=function(a,b,c,d){if(b=b||{},a.suspendedEndpoint||u.push(a),a.pending=null,a.endpoints[0].isTemporarySource=!1,d!==!1&&f.anchorManager.newConnection(a),J(a.source),!b.doNotFireConnectionEvent&&b.fireEvent!==!1){var e={connection:a,source:a.source,target:a.target,sourceId:a.sourceId,targetId:a.targetId,sourceEndpoint:a.endpoints[0],targetEndpoint:a.endpoints[1]};f.fire("connection",e,c)}},R=function(a,b){var c=f.Defaults.EndpointType||p.Endpoint,d=p.extend({},a);d._jsPlumb=f,d.newConnection=P,d.newEndpoint=R,d.endpointsByUUID=w,d.endpointsByElement=v,d.fireDetachEvent=_,d.elementId=b||Y(d.source);var e=new c(d);return e.id="ep_"+H(),sa(d.elementId,d.source),p.headless||f.getDragManager().endpointAdded(d.source,b),e},S=function(a,b,c){var d=v[a];if(d&&d.length)for(var e=0,f=d.length;f>e;e++){for(var g=0,h=d[e].connections.length;h>g;g++){var i=b(d[e].connections[g]);if(i)return}c&&c(d[e])}},T=function(a,b){return p.each(a,function(a){f.isDragSupported(a)&&(A[f.getAttribute(a,"id")]=b,f.setElementDraggable(a,b))})},U=function(a,b,c){b="block"===b;var d=null;c&&(d=function(a){a.setVisible(b,!0,!0)});var e=m(a);S(e.id,function(a){if(b&&c){var d=a.sourceId===e.id?1:0;a.endpoints[d].isVisible()&&a.setVisible(!0)}else a.setVisible(b)},d)},V=function(a){var b;return p.each(a,function(a){var c=f.getAttribute(a,"id");return b=null==A[c]?!1:A[c],b=!b,A[c]=b,f.setDraggable(a,b),b}.bind(this)),b},W=function(a,b){var c=null;b&&(c=function(a){var b=a.isVisible();a.setVisible(!b)}),S(a,function(a){var b=a.isVisible();a.setVisible(!b)},c)},X=function(a){var b=y[a];return b?{o:b,s:C[a]}:ta({elId:a})},Y=function(a,c,d){if(b.isString(a))return a;if(null==a)return null;var e=f.getAttribute(a,"id");return e&&"undefined"!==e||(2===arguments.length&&void 0!==arguments[1]?e=c:(1===arguments.length||3===arguments.length&&!arguments[2])&&(e="jsPlumb_"+g+"_"+H()),d||f.setAttribute(a,"id",e)),e};this.setConnectionBeingDragged=function(a){B=a},this.isConnectionBeingDragged=function(){return B},this.getManagedElements=function(){return x},this.connectorClass="jtk-connector",this.connectorOutlineClass="jtk-connector-outline",this.connectedClass="jtk-connected",this.hoverClass="jtk-hover",this.endpointClass="jtk-endpoint",this.endpointConnectedClass="jtk-endpoint-connected",this.endpointFullClass="jtk-endpoint-full",this.endpointDropAllowedClass="jtk-endpoint-drop-allowed",this.endpointDropForbiddenClass="jtk-endpoint-drop-forbidden",this.overlayClass="jtk-overlay",this.draggingClass="jtk-dragging",this.elementDraggingClass="jtk-element-dragging",this.sourceElementDraggingClass="jtk-source-element-dragging",this.targetElementDraggingClass="jtk-target-element-dragging",this.endpointAnchorClassPrefix="jtk-endpoint-anchor",this.hoverSourceClass="jtk-source-hover",this.hoverTargetClass="jtk-target-hover",this.dragSelectClass="jtk-drag-select",this.Anchors={},this.Connectors={svg:{}},this.Endpoints={svg:{}},this.Overlays={svg:{}},this.ConnectorRenderers={},this.SVG="svg",this.addEndpoint=function(a,c,d){d=d||{};var e=p.extend({},d);p.extend(e,c),e.endpoint=e.endpoint||f.Defaults.Endpoint,e.paintStyle=e.paintStyle||f.Defaults.EndpointStyle;for(var g=[],h=b.isArray(a)||null!=a.length&&!b.isString(a)?a:[a],i=0,j=h.length;j>i;i++){e.source=f.getElement(h[i]),qa(e.source);var k=Y(e.source),l=R(e,k),m=sa(k,e.source).info.o;b.addToList(v,k,l),D||l.paint({anchorLoc:l.anchor.compute({xy:[m.left,m.top],wh:C[k],element:l,timestamp:E}),timestamp:E}),g.push(l)}return 1===g.length?g[0]:g},this.addEndpoints=function(a,c,d){for(var e=[],g=0,h=c.length;h>g;g++){var i=f.addEndpoint(a,c[g],d);b.isArray(i)?Array.prototype.push.apply(e,i):e.push(i)}return e},this.animate=function(a,c,d){if(!this.animationSupported)return!1;d=d||{};var e=f.getElement(a),g=Y(e),h=p.animEvents.step,i=p.animEvents.complete;d[h]=b.wrap(d[h],function(){f.revalidate(g)}),d[i]=b.wrap(d[i],function(){f.revalidate(g)}),f.doAnimate(e,c,d)},this.checkCondition=function(a,c){var d=f.getListener(a),e=!0;if(d&&d.length>0){var g=Array.prototype.slice.call(arguments,1);try{for(var h=0,i=d.length;i>h;h++)e=e&&d[h].apply(d[h],g)}catch(j){b.log(f,"cannot check condition ["+a+"]"+j)}}return e},this.connect=function(a,c){var d,e=O(a,c);if(e){if(null==e.source&&null==e.sourceEndpoint)return void b.log("Cannot establish connection - source does not exist");if(null==e.target&&null==e.targetEndpoint)return void b.log("Cannot establish connection - target does not exist");qa(e.source),d=P(e),Q(d,e)}return d};var Z=[{el:"source",elId:"sourceId",epDefs:"sourceEndpointDefinitions"},{el:"target",elId:"targetId",epDefs:"targetEndpointDefinitions"}],$=function(a,b,c,d){var e,f,g,h=Z[c],i=a[h.elId],j=(a[h.el],a.endpoints[c]),k={index:c,originalSourceId:0===c?i:a.sourceId,newSourceId:a.sourceId,originalTargetId:1===c?i:a.targetId,newTargetId:a.targetId,connection:a};if(b.constructor===p.Endpoint)e=b,e.addConnection(a),b=e.element;else if(f=Y(b),g=this[h.epDefs][f],f===a[h.elId])e=null;else if(g)for(var l in g){if(!g[l].enabled)return;e=null!=g[l].endpoint&&g[l].endpoint._jsPlumb?g[l].endpoint:this.addEndpoint(b,g[l].def),g[l].uniqueEndpoint&&(g[l].endpoint=e),e.addConnection(a)}else e=a.makeEndpoint(0===c,b,f);return null!=e&&(j.detachFromConnection(a),a.endpoints[c]=e,a[h.el]=e.element,a[h.elId]=e.elementId,k[0===c?"newSourceId":"newTargetId"]=e.elementId,aa(k),d||a.repaint()),k.element=b,k}.bind(this);this.setSource=function(a,b,c){var d=$(a,b,0,c);this.anchorManager.sourceChanged(d.originalSourceId,d.newSourceId,a,d.el)},this.setTarget=function(a,b,c){var d=$(a,b,1,c);this.anchorManager.updateOtherEndpoint(d.originalSourceId,d.originalTargetId,d.newTargetId,a)},this.deleteEndpoint=function(a,b,c){var d="string"==typeof a?w[a]:a;return d&&f.deleteObject({endpoint:d,dontUpdateHover:b,deleteAttachedObjects:c}),f},this.deleteEveryEndpoint=function(){var a=f.setSuspendDrawing(!0);for(var b in v){var c=v[b];if(c&&c.length)for(var d=0,e=c.length;e>d;d++)f.deleteEndpoint(c[d],!0)}v={},x={},w={},y={},z={},f.anchorManager.reset();var g=f.getDragManager();return g&&g.reset(),a||f.setSuspendDrawing(!1),f};var _=function(a,b,c){var d=f.Defaults.ConnectionType||f.getDefaultConnectionType(),e=a.constructor===d,g=e?{connection:a,source:a.source,target:a.target,sourceId:a.sourceId,targetId:a.targetId,sourceEndpoint:a.endpoints[0],targetEndpoint:a.endpoints[1]}:a;b&&f.fire("connectionDetached",g,c),f.fire("internal.connectionDetached",g,c),f.anchorManager.connectionDetached(g)},aa=f.fireMoveEvent=function(a,b){f.fire("connectionMoved",a,b)};this.unregisterEndpoint=function(a){a._jsPlumb.uuid&&(w[a._jsPlumb.uuid]=null),f.anchorManager.deleteEndpoint(a);for(var b in v){var c=v[b];if(c){for(var d=[],e=0,g=c.length;g>e;e++)c[e]!==a&&d.push(c[e]);v[b]=d}v[b].length<1&&delete v[b]}};var ba="isDetachAllowed",ca="beforeDetach",da="checkCondition";this.deleteConnection=function(a,c){return null!=a&&(c=c||{},c.force||b.functionChain(!0,!1,[[a.endpoints[0],ba,[a]],[a.endpoints[1],ba,[a]],[a,ba,[a]],[f,da,[ca,a]]]))?(a.setHover(!1),_(a,!a.pending&&c.fireEvent!==!1,c.originalEvent),a.endpoints[0].detachFromConnection(a),a.endpoints[1].detachFromConnection(a),b.removeWithFunction(u,function(b){return a.id===b.id}),a.cleanup(),a.destroy(),!0):!1},this.deleteEveryConnection=function(a){a=a||{};var b=u.length,c=0;return f.batch(function(){for(var d=0;b>d;d++)c+=f.deleteConnection(u[0],a)?1:0}),c},this.deleteConnectionsForElement=function(a,b){b=b||{},a=f.getElement(a);var c=Y(a),d=v[c];if(d&&d.length)for(var e=0,g=d.length;g>e;e++)d[e].deleteEveryConnection(b);return f},this.deleteObject=function(a){var c={endpoints:{},connections:{},endpointCount:0,connectionCount:0},d=a.deleteAttachedObjects!==!1,e=function(b){null!=b&&null==c.connections[b.id]&&(a.dontUpdateHover||null==b._jsPlumb||b.setHover(!1),c.connections[b.id]=b,c.connectionCount++)},g=function(b){if(null!=b&&null==c.endpoints[b.id]&&(a.dontUpdateHover||null==b._jsPlumb||b.setHover(!1),c.endpoints[b.id]=b,c.endpointCount++,d))for(var f=0;fe;e++)a[e][b].apply(a[e],c);return d(a)},fa=function(a,b,c){for(var d=[],e=0,f=a.length;f>e;e++)d.push([a[e][b].apply(a[e],c),a[e]]);return d},ga=function(a,b,c){return function(){return ea(a,b,arguments,c)}},ha=function(a,b){return function(){return fa(a,b,arguments)}},ia=function(a,b){var c=[];if(a)if("string"==typeof a){if("*"===a)return a;c.push(a)}else if(b)c=a;else if(a.length)for(var d=0,e=a.length;e>d;d++)c.push(m(a[d]).id);else c.push(m(a).id);return c},ja=function(a,b,c){return"*"===a?!0:a.length>0?-1!==a.indexOf(b):!c};this.getConnections=function(a,b){a?a.constructor===String&&(a={scope:a}):a={};for(var c=a.scope||f.getDefaultScope(),d=ia(c,!0),e=ia(a.source),g=ia(a.target),h=!b&&d.length>1?{}:[],i=function(a,c){if(!b&&d.length>1){var e=h[a];null==e&&(e=h[a]=[]),e.push(c)}else h.push(c)},j=0,k=u.length;k>j;j++){var l=u[j],m=l.proxies&&l.proxies[0]?l.proxies[0].originalEp.elementId:l.sourceId,n=l.proxies&&l.proxies[1]?l.proxies[1].originalEp.elementId:l.targetId;ja(d,l.scope)&&ja(e,m)&&ja(g,n)&&i(l.scope,l)}return h};var ka=function(a,b){return function(c){for(var d=0,e=a.length;e>d;d++)c(a[d]);return b(a)}},la=function(a){return function(b){return a[b]}},ma=function(a,b){var c,d,e={length:a.length,each:ka(a,b),get:la(a)},f=["setHover","removeAllOverlays","setLabel","addClass","addOverlay","removeOverlay","removeOverlays","showOverlay","hideOverlay","showOverlays","hideOverlays","setPaintStyle","setHoverPaintStyle","setSuspendEvents","setParameter","setParameters","setVisible","repaint","addType","toggleType","removeType","removeClass","setType","bind","unbind"],g=["getLabel","getOverlay","isHover","getParameter","getParameters","getPaintStyle","getHoverPaintStyle","isVisible","hasType","getType","isSuspendEvents"];for(c=0,d=f.length;d>c;c++)e[f[c]]=ga(a,f[c],b);for(c=0,d=g.length;d>c;c++)e[g[c]]=ha(a,g[c]);return e},na=function(a){var b=ma(a,na);return p.extend(b,{setDetachable:ga(a,"setDetachable",na),setReattach:ga(a,"setReattach",na),setConnector:ga(a,"setConnector",na),"delete":function(){for(var b=0,c=a.length;c>b;b++)f.deleteConnection(a[b])},isDetachable:ha(a,"isDetachable"),isReattach:ha(a,"isReattach")})},oa=function(a){var b=ma(a,oa);return p.extend(b,{setEnabled:ga(a,"setEnabled",oa),setAnchor:ga(a,"setAnchor",oa),isEnabled:ha(a,"isEnabled"),deleteEveryConnection:function(){for(var b=0,c=a.length;c>b;b++)a[b].deleteEveryConnection()},"delete":function(){for(var b=0,c=a.length;c>b;b++)f.deleteEndpoint(a[b]); +}})};this.select=function(a){return a=a||{},a.scope=a.scope||"*",na(a.connections||f.getConnections(a,!0))},this.selectEndpoints=function(a){a=a||{},a.scope=a.scope||"*";var b=!a.element&&!a.source&&!a.target,c=b?"*":ia(a.element),d=b?"*":ia(a.source),e=b?"*":ia(a.target),f=ia(a.scope,!0),g=[];for(var h in v){var i=ja(c,h,!0),j=ja(d,h,!0),k="*"!==d,l=ja(e,h,!0),m="*"!==e;if(i||j||l)a:for(var n=0,o=v[h].length;o>n;n++){var p=v[h][n];if(ja(f,p.scope,!0)){var q=k&&d.length>0&&!p.isSource,r=m&&e.length>0&&!p.isTarget;if(q||r)continue a;g.push(p)}}}return oa(g)},this.getAllConnections=function(){return u},this.getDefaultScope=function(){return F},this.getEndpoint=K,this.getEndpoints=function(a){return v[m(a).id]||[]},this.getDefaultEndpointType=function(){return p.Endpoint},this.getDefaultConnectionType=function(){return p.Connection},this.getId=Y,this.appendElement=I;var pa=!1;this.isHoverSuspended=function(){return pa},this.setHoverSuspended=function(a){pa=a},this.hide=function(a,b){return U(a,"none",b),f},this.idstamp=H;var qa=function(a){if(!q&&a){var b=f.getElement(a);b.offsetParent&&f.setContainer(b.offsetParent)}},ra=function(){f.Defaults.Container&&f.setContainer(f.Defaults.Container)},sa=f.manage=function(a,b,c){return x[a]||(x[a]={el:b,endpoints:[],connections:[]},x[a].info=ta({elId:a,timestamp:E}),c||f.fire("manageElement",{id:a,info:x[a].info,el:b})),x[a]},ta=this.updateOffset=function(a){var b,c=a.timestamp,d=a.recalc,e=a.offset,g=a.elId;return D&&!c&&(c=E),!d&&c&&c===z[g]?{o:a.offset||y[g],s:C[g]}:(d||!e&&null==y[g]?(b=x[g]?x[g].el:null,null!=b&&(C[g]=f.getSize(b),y[g]=f.getOffset(b),z[g]=c)):(y[g]=e||y[g],null==C[g]&&(b=x[g].el,null!=b&&(C[g]=f.getSize(b))),z[g]=c),y[g]&&!y[g].right&&(y[g].right=y[g].left+C[g][0],y[g].bottom=y[g].top+C[g][1],y[g].width=C[g][0],y[g].height=C[g][1],y[g].centerx=y[g].left+y[g].width/2,y[g].centery=y[g].top+y[g].height/2),{o:y[g],s:C[g]})};this.init=function(){t||(ra(),f.anchorManager=new a.jsPlumb.AnchorManager({jsPlumbInstance:f}),t=!0,f.fire("ready",f))}.bind(this),this.log=s,this.jsPlumbUIComponent=k,this.makeAnchor=function(){var c,d=function(b,c){if(a.jsPlumb.Anchors[b])return new a.jsPlumb.Anchors[b](c);if(!f.Defaults.DoNotThrowErrors)throw{msg:"jsPlumb: unknown anchor type '"+b+"'"}};if(0===arguments.length)return null;var e=arguments[0],g=arguments[1],h=(arguments[2],null);if(e.compute&&e.getOrientation)return e;if("string"==typeof e)h=d(arguments[0],{elementId:g,jsPlumbInstance:f});else if(b.isArray(e))if(b.isArray(e[0])||b.isString(e[0]))2===e.length&&b.isObject(e[1])?b.isString(e[0])?(c=a.jsPlumb.extend({elementId:g,jsPlumbInstance:f},e[1]),h=d(e[0],c)):(c=a.jsPlumb.extend({elementId:g,jsPlumbInstance:f,anchors:e[0]},e[1]),h=new a.jsPlumb.DynamicAnchor(c)):h=new p.DynamicAnchor({anchors:e,selector:null,elementId:g,jsPlumbInstance:f});else{var i={x:e[0],y:e[1],orientation:e.length>=4?[e[2],e[3]]:[0,0],offsets:e.length>=6?[e[4],e[5]]:[0,0],elementId:g,jsPlumbInstance:f,cssClass:7===e.length?e[6]:null};h=new a.jsPlumb.Anchor(i),h.clone=function(){return new a.jsPlumb.Anchor(i)}}return h.id||(h.id="anchor_"+H()),h},this.makeAnchors=function(c,d,e){for(var g=[],h=0,i=c.length;i>h;h++)"string"==typeof c[h]?g.push(a.jsPlumb.Anchors[c[h]]({elementId:d,jsPlumbInstance:e})):b.isArray(c[h])&&g.push(f.makeAnchor(c[h],d,e));return g},this.makeDynamicAnchor=function(b,c){return new a.jsPlumb.DynamicAnchor({anchors:b,selector:c,elementId:null,jsPlumbInstance:f})},this.targetEndpointDefinitions={},this.sourceEndpointDefinitions={};var ua=function(a,b,c,d,e){for(var f=a.target||a.srcElement,g=!1,h=d.getSelector(b,c),i=0;i0&&a>=c.def.maxConnections},element:c.el,elementId:c.id,isSource:g,isTarget:h,addClass:function(a){f.addClass(c.el,a)},removeClass:function(a){f.removeClass(c.el,a)},onDrop:function(a){var b=a.endpoints[0];b.anchor.unlock()},isDropAllowed:function(){return i.isDropAllowed.apply(i,arguments)},isRedrop:function(a){return null!=a.suspendedElement&&null!=a.suspendedEndpoint&&a.suspendedEndpoint.element===c.el},getEndpoint:function(b){var e=c.def.endpoint;if(null==e||null==e._jsPlumb){var g=f.deriveEndpointAndAnchorSpec(b.getType().join(" "),!0),h=g.endpoints?a.jsPlumb.extend(d,{endpoint:c.def.def.endpoint||g.endpoints[1]}):d;g.anchors&&(h=a.jsPlumb.extend(h,{anchor:c.def.def.anchor||g.anchors[1]})),e=f.addEndpoint(c.el,h),e._mtNew=!0}if(d.uniqueEndpoint&&(c.def.endpoint=e),e.setDeleteOnEmpty(!0),b.isDetachable()&&e.initDraggable(),null!=e.anchor.positionFinder){var i=f.getUIPosition(arguments,f.getZoom()),j=f.getOffset(c.el),k=f.getSize(c.el),l=null==i?[0,0]:e.anchor.positionFinder(i,j,k,e.anchor.constructorParams);e.anchor.x=l[0],e.anchor.y=l[1]}return e},maybeCleanup:function(a){a._mtNew&&0===a.connections.length?f.deleteObject({endpoint:a}):delete a._mtNew}}),l=a.jsPlumb.dragEvents.drop;return e.scope=e.scope||d.scope||f.Defaults.Scope,e[l]=b.wrap(e[l],j,!0),e.rank=d.rank||0,h&&(e[a.jsPlumb.dragEvents.over]=function(){return!0}),d.allowLoopback===!1&&(e.canDrop=function(a){var b=a.getDragElement()._jsPlumbRelatedElement;return b!==c.el}),f.initDroppable(c.el,e,"internal"),j};this.makeTarget=function(b,c,d){var e=a.jsPlumb.extend({_jsPlumb:this},d);a.jsPlumb.extend(e,c);for(var g=e.maxConnections||-1,h=function(b){var c=m(b),d=c.id,h=a.jsPlumb.extend({},e.dropOptions||{}),i=e.connectionType||"default";this.targetEndpointDefinitions[d]=this.targetEndpointDefinitions[d]||{},qa(d),c.el._isJsPlumbGroup&&null==h.rank&&(h.rank=-1);var j={def:a.jsPlumb.extend({},e),uniqueEndpoint:e.uniqueEndpoint,maxConnections:g,enabled:!0};e.createEndpoint&&(j.uniqueEndpoint=!0,j.endpoint=f.addEndpoint(b,j.def),j.endpoint.setDeleteOnEmpty(!1)),c.def=j,this.targetEndpointDefinitions[d][i]=j,va(c,e,h,e.isSource===!0,!0),c.el._katavorioDrop[c.el._katavorioDrop.length-1].targetDef=j}.bind(this),i=b.length&&b.constructor!==String?b:[b],j=0,k=i.length;k>j;j++)h(i[j]);return this},this.unmakeTarget=function(a,b){var c=m(a);return f.destroyDroppable(c.el,"internal"),b||delete this.targetEndpointDefinitions[c.id],this},this.makeSource=function(c,d,e){var g=a.jsPlumb.extend({_jsPlumb:this},e);a.jsPlumb.extend(g,d);var h=g.connectionType||"default",i=f.deriveEndpointAndAnchorSpec(h);g.endpoint=g.endpoint||i.endpoints[0],g.anchor=g.anchor||i.anchors[0];for(var j=g.maxConnections||-1,k=g.onMaxConnections,n=function(d){var e=d.id,i=this.getElement(d.el);this.sourceEndpointDefinitions[e]=this.sourceEndpointDefinitions[e]||{},qa(e);var m={def:a.jsPlumb.extend({},g),uniqueEndpoint:g.uniqueEndpoint,maxConnections:j,enabled:!0};g.createEndpoint&&(m.uniqueEndpoint=!0,m.endpoint=f.addEndpoint(c,m.def),m.endpoint.setDeleteOnEmpty(!1)),this.sourceEndpointDefinitions[e][h]=m,d.def=m;var n=a.jsPlumb.dragEvents.stop,o=a.jsPlumb.dragEvents.drag,p=a.jsPlumb.extend({},g.dragOptions||{}),q=p.drag,r=p.stop,s=null,t=!1;p.scope=p.scope||g.scope,p[o]=b.wrap(p[o],function(){q&&q.apply(this,arguments),t=!1}),p[n]=b.wrap(p[n],function(){if(r&&r.apply(this,arguments),this.currentlyDragging=!1,null!=s._jsPlumb){var a=g.anchor||this.Defaults.Anchor,b=s.anchor,c=s.connections[0],d=this.makeAnchor(a,e,this),h=s.element;if(null!=d.positionFinder){var i=f.getOffset(h),j=this.getSize(h),k={left:i.left+b.x*j[0],top:i.top+b.y*j[1]},l=d.positionFinder(k,i,j,d.constructorParams);d.x=l[0],d.y=l[1]}s.setAnchor(d,!0),s.repaint(),this.repaint(s.elementId),null!=c&&this.repaint(c.targetId)}}.bind(this));var u=function(c){if(3!==c.which&&2!==c.button){var m=this.sourceEndpointDefinitions[e][h];if(m.enabled){if(e=this.getId(this.getElement(d.el)),g.filter){var n=b.isString(g.filter)?ua(c,d.el,g.filter,this,g.filterExclude):g.filter(c,d.el);if(n===!1)return}var o=this.select({source:e}).length;if(m.maxConnections>=0&&o>=m.maxConnections)return k&&k({element:d.el,maxConnections:j},c),!1;var q=a.jsPlumb.getPositionOnElement(c,i,l),r={};a.jsPlumb.extend(r,g),r.isTemporarySource=!0,r.anchor=[q[0],q[1],0,0],r.dragOptions=p,m.def.scope&&(r.scope=m.def.scope),s=this.addEndpoint(e,r),t=!0,s.setDeleteOnEmpty(!0),m.uniqueEndpoint&&(m.endpoint?s.finalEndpoint=m.endpoint:(m.endpoint=s,s.setDeleteOnEmpty(!1)));var u=function(){f.off(s.canvas,"mouseup",u),f.off(d.el,"mouseup",u),t&&(t=!1,f.deleteEndpoint(s))};f.on(s.canvas,"mouseup",u),f.on(d.el,"mouseup",u);var v={};if(m.def.extract)for(var w in m.def.extract){var x=(c.srcElement||c.target).getAttribute(w);x&&(v[m.def.extract[w]]=x)}f.trigger(s.canvas,"mousedown",c,v),b.consume(c)}}}.bind(this);this.on(d.el,"mousedown",u),m.trigger=u,g.filter&&(b.isString(g.filter)||b.isFunction(g.filter))&&f.setDragFilter(d.el,g.filter);var v=a.jsPlumb.extend({},g.dropOptions||{});va(d,g,v,!0,g.isTarget===!0)}.bind(this),o=c.length&&c.constructor!==String?c:[c],p=0,q=o.length;q>p;p++)n(m(o[p]));return this},this.unmakeSource=function(a,b,c){var d=m(a);f.destroyDroppable(d.el,"internal");var e=this.sourceEndpointDefinitions[d.id];if(e)for(var g in e)if(null==b||b===g){var h=e[g].trigger;h&&f.off(d.el,"mousedown",h),c||delete this.sourceEndpointDefinitions[d.id][g]}return this},this.unmakeEverySource=function(){for(var a in this.sourceEndpointDefinitions)f.unmakeSource(a,null,!0);return this.sourceEndpointDefinitions={},this};var wa=function(a,c,d){c=b.isArray(c)?c:[c];var e=Y(a);d=d||"default";for(var f=0;fl;l++)i=m(c[l]),k[i.id]&&k[i.id][g]&&(h[l]=k[i.id][g].enabled,j=e?!h[l]:d,k[i.id][g].enabled=j,f[j?"removeClass":"addClass"](i.el,"jtk-"+a+"-disabled"))}else{i=m(c);var o=i.id;k[o]&&k[o][g]&&(h=k[o][g].enabled,j=e?!h:d,k[o][g].enabled=j,f[j?"removeClass":"addClass"](i.el,"jtk-"+a+"-disabled"))}return h}.bind(this),za=function(a,c){return b.isString(a)||!a.length?c.apply(this,[a]):a.length?c.apply(this,[a[0]]):void 0}.bind(this);this.toggleSourceEnabled=function(a,b){return ya("source",a,null,!0,b),this.isSourceEnabled(a,b)},this.setSourceEnabled=function(a,b,c){return ya("source",a,b,null,c)},this.isSource=function(a,b){return b=b||"default",za(a,function(a){var c=this.sourceEndpointDefinitions[m(a).id];return null!=c&&null!=c[b]}.bind(this))},this.isSourceEnabled=function(a,b){return b=b||"default",za(a,function(a){var c=this.sourceEndpointDefinitions[m(a).id];return c&&c[b]&&c[b].enabled===!0}.bind(this))},this.toggleTargetEnabled=function(a,b){return ya("target",a,null,!0,b),this.isTargetEnabled(a,b)},this.isTarget=function(a,b){return b=b||"default",za(a,function(a){var c=this.targetEndpointDefinitions[m(a).id];return null!=c&&null!=c[b]}.bind(this))},this.isTargetEnabled=function(a,b){return b=b||"default",za(a,function(a){var c=this.targetEndpointDefinitions[m(a).id];return c&&c[b]&&c[b].enabled===!0}.bind(this))},this.setTargetEnabled=function(a,b,c){return ya("target",a,b,null,c)},this.ready=function(a){f.bind("ready",a)};var Aa=function(a,b){if("object"==typeof a&&a.length)for(var c=0,d=a.length;d>c;c++)b(a[c]);else b(a);return f};this.repaint=function(a,b,c){return Aa(a,function(a){J(a,b,c)})},this.revalidate=function(a,b,c){return Aa(a,function(a){var d=c?a:f.getId(a);f.updateOffset({elId:d,recalc:!0,timestamp:b});var e=f.getDragManager();e&&e.updateOffsets(d),f.repaint(a)})},this.repaintEverything=function(){var a,b=c();for(a in v)f.updateOffset({elId:a,recalc:!0,timestamp:b});for(a in v)J(a,null,b);return this},this.removeAllEndpoints=function(a,b,c){c=c||[];var d=function(a){var e,g,h=m(a),i=v[h.id];if(i)for(c.push(h),e=0,g=i.length;g>e;e++)f.deleteEndpoint(i[e],!1);if(delete v[h.id],b&&h.el&&3!==h.el.nodeType&&8!==h.el.nodeType)for(e=0,g=h.el.childNodes.length;g>e;e++)d(h.el.childNodes[e])};return d(a),this};var Ba=function(a,b){f.removeAllEndpoints(a.id,!0,b);for(var c=f.getDragManager(),d=function(a){c&&c.elementRemoved(a.id),f.anchorManager.clearFor(a.id),f.anchorManager.removeFloatingConnection(a.id),f.isSource(a.el)&&f.unmakeSource(a.el),f.isTarget(a.el)&&f.unmakeTarget(a.el),f.destroyDraggable(a.el),f.destroyDroppable(a.el),delete f.floatingConnections[a.id],delete x[a.id],delete y[a.id],a.el&&(f.removeElement(a.el),a.el._jsPlumb=null)},e=1;e0;)d(e.el.childNodes[0]);b||Ba(e,c)}};return f.batch(function(){d(a,!0)},b===!1),f},this.reset=function(a){f.silently(function(){pa=!1,f.removeAllGroups(),f.removeGroupManager(),f.deleteEveryEndpoint(),a||f.unbind(),this.targetEndpointDefinitions={},this.sourceEndpointDefinitions={},u.length=0,this.doReset&&this.doReset()}.bind(this))};var Ca=function(a){a.canvas&&a.canvas.parentNode&&a.canvas.parentNode.removeChild(a.canvas),a.cleanup(),a.destroy()};this.clear=function(){f.select().each(Ca),f.selectEndpoints().each(Ca),v={},w={}},this.setDefaultScope=function(a){return F=a,f},this.setDraggable=T,this.deriveEndpointAndAnchorSpec=function(a,b){for(var c=((b?"":"default ")+a).split(/[\s]/),d=null,e=null,g=null,h=null,i=0;ih;h++)v[c][h].setElementId(c),v[c][h].setReferenceElement(a);delete v[e],this.sourceEndpointDefinitions[c]=this.sourceEndpointDefinitions[e],delete this.sourceEndpointDefinitions[e],this.targetEndpointDefinitions[c]=this.targetEndpointDefinitions[e],delete this.targetEndpointDefinitions[e],this.anchorManager.changeId(e,c);var j=this.getDragManager();j&&j.changeId(e,c),x[c]=x[e],delete x[e];var k=function(b,d,e){for(var f=0,g=b.length;g>f;f++)b[f].endpoints[d].setElementId(c),b[f].endpoints[d].setReferenceElement(a),b[f][e+"Id"]=c,b[f][e]=a};k(f,0,"source"),k(g,1,"target"),this.repaint(c)},this.setDebugLog=function(a){s=a},this.setSuspendDrawing=function(a,b){var c=D;return D=a,E=a?(new Date).getTime():null,b&&this.repaintEverything(),c},this.isSuspendDrawing=function(){return D},this.getSuspendedAt=function(){return E},this.batch=function(a,c){var d=this.isSuspendDrawing();d||this.setSuspendDrawing(!0);try{a()}catch(e){b.log("Function run while suspended failed",e)}d||this.setSuspendDrawing(!1,!c)},this.doWhileSuspended=this.batch,this.getCachedData=X,this.timestamp=c,this.show=function(a,b){return U(a,"block",b),f},this.toggleVisible=W,this.toggleDraggable=V,this.addListener=this.bind;var Da=[];this.registerFloatingConnection=function(a,c,d){Da[a.id]=c,b.addToList(v,a.id,d)},this.getFloatingConnectionFor=function(a){return Da[a]}};b.extend(a.jsPlumbInstance,b.EventGenerator,{setAttribute:function(a,b,c){this.setAttribute(a,b,c)},getAttribute:function(b,c){return this.getAttribute(a.jsPlumb.getElement(b),c)},convertToFullOverlaySpec:function(a){return b.isString(a)&&(a=[a,{}]),a[1].id=a[1].id||b.uuid(),a},registerConnectionType:function(b,c){if(this._connectionTypes[b]=a.jsPlumb.extend({},c),c.overlays){for(var d={},e=0;e0?a.touches:a.changedTouches&&a.changedTouches.length>0?a.changedTouches:a.targetTouches&&a.targetTouches.length>0?a.targetTouches:[a]},i=function(a){var b={},c=[],d={},e={},f={};this.register=function(g){var h=a.getId(g),i=a.getOffset(g);b[h]||(b[h]=g,c.push(g),d[h]={});var j=function(b){if(b)for(var c=0;c0){var l=a.getOffset(g);d[h][k]={id:k,offset:{left:l.left-i.left,top:l.top-i.top}},f[k]=h}j(b.childNodes[c])}};j(g)},this.updateOffsets=function(b,c){if(null!=b){c=c||{};var e=jsPlumb.getElement(b),g=a.getId(e),h=d[g],i=a.getOffset(e);if(h)for(var j in h)if(h.hasOwnProperty(j)){var k=jsPlumb.getElement(j),l=c[j]||a.getOffset(k);if(null==k.offsetParent&&null!=d[g][j])continue;d[g][j]={id:j,offset:{left:l.left-i.left,top:l.top-i.top}},f[j]=g}}},this.endpointAdded=function(c,g){g=g||a.getId(c);var h=document.body,i=c.parentNode;for(e[g]=e[g]?e[g]+1:1;null!=i&&i!==h;){var j=a.getId(i,null,!0);if(j&&b[j]){var k=a.getOffset(i);if(null==d[j][g]){var l=a.getOffset(c);d[j][g]={id:g,offset:{left:l.left-k.left,top:l.top-k.top}},f[g]=j}break}i=i.parentNode}},this.endpointDeleted=function(a){if(e[a.elementId]&&(e[a.elementId]--,e[a.elementId]<=0))for(var b in d)d.hasOwnProperty(b)&&d[b]&&(delete d[b][a.elementId],delete f[a.elementId])},this.changeId=function(a,b){d[b]=d[a],d[a]={},f[b]=f[a],f[a]=null},this.getElementsForDraggable=function(a){return d[a]},this.elementRemoved=function(a){var b=f[a];b&&(delete d[b][a],delete f[a])},this.reset=function(){b={},c=[],d={},e={}},this.dragEnded=function(b){if(null!=b.offsetParent){var c=a.getId(b),d=f[c];d&&this.updateOffsets(d)}},this.setParent=function(b,c,e,g,h){var i=f[c];d[g]||(d[g]={});var j=a.getOffset(e),k=h||a.getOffset(b);i&&d[i]&&delete d[i][c],d[g][c]={id:c,offset:{left:k.left-j.left,top:k.top-j.top}},f[c]=g},this.clearParent=function(a,b){var c=f[b];c&&(delete d[c][b],delete f[b])},this.revalidateParent=function(b,c,d){var e=f[c];if(e){var g={};g[c]=d,this.updateOffsets(e,g),a.revalidate(e)}},this.getDragAncestor=function(b){var c=jsPlumb.getElement(b),d=a.getId(c),e=f[d];return e?jsPlumb.getElement(e):null}},j=function(a){return null==a?null:a.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},k=function(a,b,c){b=j(b),"undefined"!=typeof a.className.baseVal?a.className.baseVal=b:a.className=b;try{for(var d=a.classList;d.length>0;)d.remove(d.item(0));for(var e=0;e0||a.scrollLeft>0)&&(d.left-=a.scrollLeft,d.top-=a.scrollTop)}.bind(this);null!=e;)d.left+=e.offsetLeft,d.top+=e.offsetTop,f(e),e=b?e.offsetParent:e.offsetParent===c?null:e.offsetParent;if(null!=c&&!b&&(c.scrollTop>0||c.scrollLeft>0)){var g=null!=a.offsetParent?this.getStyle(a.offsetParent,"position"):"static",h=this.getStyle(a,"position");"absolute"!==h&&"fixed"!==h&&"absolute"!==g&&"fixed"!==g&&(d.left-=c.scrollLeft,d.top-=c.scrollTop)}return d},getPositionOnElement:function(a,b,c){var d="undefined"!=typeof b.getBoundingClientRect?b.getBoundingClientRect():{left:0,top:0,width:0,height:0},e=document.body,f=document.documentElement,g=window.pageYOffset||f.scrollTop||e.scrollTop,h=window.pageXOffset||f.scrollLeft||e.scrollLeft,i=f.clientTop||e.clientTop||0,j=f.clientLeft||e.clientLeft||0,k=0,l=0,m=d.top+g-i+k*c,n=d.left+h-j+l*c,o=jsPlumb.pageLocation(a),p=d.width||b.offsetWidth*c,q=d.height||b.offsetHeight*c,r=(o[0]-n)/p,s=(o[1]-m)/q;return[r,s]},getAbsolutePosition:function(a){var b=function(b){var c=a.style[b];return c?parseFloat(c.substring(0,c.length-2)):void 0};return[b("left"),b("top")]},setAbsolutePosition:function(a,b,c,d){c?this.animate(a,{left:"+="+(b[0]-c[0]),top:"+="+(b[1]-c[1])},d):(a.style.left=b[0]+"px",a.style.top=b[1]+"px")},getSize:function(a){return[a.offsetWidth,a.offsetHeight]},getWidth:function(a){return a.offsetWidth},getHeight:function(a){return a.offsetHeight},getRenderMode:function(){return"svg"}})}.call("undefined"!=typeof window?window:this),function(){"use strict";var a=this,b=a.jsPlumb,c=a.jsPlumbUtil,d="__label",e=function(a,c){var e={cssClass:c.cssClass,labelStyle:a.labelStyle,id:d,component:a,_jsPlumb:a._jsPlumb.instance},f=b.extend(e,c);return new(b.Overlays[a._jsPlumb.instance.getRenderMode()].Label)(f)},f=function(a,d){var e=null;if(c.isArray(d)){var f=d[0],g=b.extend({component:a,_jsPlumb:a._jsPlumb.instance},d[1]);3===d.length&&b.extend(g,d[2]),e=new(b.Overlays[a._jsPlumb.instance.getRenderMode()][f])(g)}else e=d.constructor===String?new(b.Overlays[a._jsPlumb.instance.getRenderMode()][d])({component:a,_jsPlumb:a._jsPlumb.instance}):d;return e.id=e.id||c.uuid(),a.cacheTypeItem("overlay",e,e.id),a._jsPlumb.overlays[e.id]=e,e};b.OverlayCapableJsPlumbUIComponent=function(b){a.jsPlumbUIComponent.apply(this,arguments),this._jsPlumb.overlays={},this._jsPlumb.overlayPositions={},b.label&&(this.getDefaultType().overlays[d]=["Label",{label:b.label,location:b.labelLocation||this.defaultLabelLocation||.5,labelStyle:b.labelStyle||this._jsPlumb.instance.Defaults.LabelStyle,id:d}]),this.setListenerComponent=function(a){if(this._jsPlumb)for(var b in this._jsPlumb.overlays)this._jsPlumb.overlays[b].setListenerComponent(a)}},b.OverlayCapableJsPlumbUIComponent.applyType=function(a,b){if(b.overlays){var c,d={};for(c in b.overlays){var e=a._jsPlumb.overlays[b.overlays[c][1].id];if(e)e.updateFrom(b.overlays[c][1]),d[b.overlays[c][1].id]=!0;else{var f=a.getCachedTypeItem("overlay",b.overlays[c][1].id);null!=f?(f.reattach(a._jsPlumb.instance,a),f.setVisible(!0),f.updateFrom(b.overlays[c][1]),a._jsPlumb.overlays[f.id]=f):f=a.addOverlay(b.overlays[c],!0),d[f.id]=!0}}for(c in a._jsPlumb.overlays)null==d[a._jsPlumb.overlays[c].id]&&a.removeOverlay(a._jsPlumb.overlays[c].id,!0)}},c.extend(b.OverlayCapableJsPlumbUIComponent,a.jsPlumbUIComponent,{setHover:function(a,b){if(this._jsPlumb&&!this._jsPlumb.instance.isConnectionBeingDragged())for(var c in this._jsPlumb.overlays)this._jsPlumb.overlays[c][a?"addClass":"removeClass"](this._jsPlumb.instance.hoverClass)},addOverlay:function(a,b){var c=f(this,a);return b||this.repaint(),c},getOverlay:function(a){return this._jsPlumb.overlays[a]},getOverlays:function(){return this._jsPlumb.overlays},hideOverlay:function(a){var b=this.getOverlay(a);b&&b.hide()},hideOverlays:function(){for(var a in this._jsPlumb.overlays)this._jsPlumb.overlays[a].hide()},showOverlay:function(a){var b=this.getOverlay(a);b&&b.show()},showOverlays:function(){for(var a in this._jsPlumb.overlays)this._jsPlumb.overlays[a].show()},removeAllOverlays:function(a){for(var b in this._jsPlumb.overlays)this._jsPlumb.overlays[b].cleanup&&this._jsPlumb.overlays[b].cleanup();this._jsPlumb.overlays={},this._jsPlumb.overlayPositions=null,a||this.repaint()},removeOverlay:function(a,b){var c=this._jsPlumb.overlays[a];c&&(c.setVisible(!1),!b&&c.cleanup&&c.cleanup(),delete this._jsPlumb.overlays[a],this._jsPlumb.overlayPositions&&delete this._jsPlumb.overlayPositions[a])},removeOverlays:function(){for(var a=0,b=arguments.length;b>a;a++)this.removeOverlay(arguments[a])},moveParent:function(a){if(this.bgCanvas&&(this.bgCanvas.parentNode.removeChild(this.bgCanvas),a.appendChild(this.bgCanvas)),this.canvas&&this.canvas.parentNode){this.canvas.parentNode.removeChild(this.canvas),a.appendChild(this.canvas);for(var b in this._jsPlumb.overlays)if(this._jsPlumb.overlays[b].isAppendedAtTopLevel){var c=this._jsPlumb.overlays[b].getElement();c.parentNode.removeChild(c),a.appendChild(c)}}},getLabel:function(){var a=this.getOverlay(d);return null!=a?a.getLabel():null},getLabelOverlay:function(){return this.getOverlay(d)},setLabel:function(a){var b=this.getOverlay(d);if(b)a.constructor===String||a.constructor===Function?b.setLabel(a):(a.label&&b.setLabel(a.label),a.location&&b.setLocation(a.location));else{var c=a.constructor===String||a.constructor===Function?{label:a}:a;b=e(this,c),this._jsPlumb.overlays[d]=b}this._jsPlumb.instance.isSuspendDrawing()||this.repaint()},cleanup:function(a){for(var b in this._jsPlumb.overlays)this._jsPlumb.overlays[b].cleanup(a),this._jsPlumb.overlays[b].destroy(a);a&&(this._jsPlumb.overlays={},this._jsPlumb.overlayPositions=null)},setVisible:function(a){this[a?"showOverlays":"hideOverlays"]()},setAbsoluteOverlayPosition:function(a,b){this._jsPlumb.overlayPositions[a.id]=b},getAbsoluteOverlayPosition:function(a){return this._jsPlumb.overlayPositions?this._jsPlumb.overlayPositions[a.id]:null},_clazzManip:function(a,b,c){if(!c)for(var d in this._jsPlumb.overlays)this._jsPlumb.overlays[d][a+"Class"](b)},addClass:function(a,b){this._clazzManip("add",a,b)},removeClass:function(a,b){this._clazzManip("remove",a,b)}})}.call("undefined"!=typeof window?window:this),function(){"use strict";var a=this,b=a.jsPlumb,c=a.jsPlumbUtil,d=function(a,b,c){var d=!1;return{drag:function(){if(d)return d=!1,!0;if(b.element){var e=c.getUIPosition(arguments,c.getZoom());null!=e&&c.setPosition(b.element,e),c.repaint(b.element,e),a.paint({anchorPoint:a.anchor.getCurrentLocation({element:a})})}},stopDrag:function(){d=!0}}},e=function(a,b,c,d){var e=b.createElement("div",{position:"absolute"});b.appendElement(e);var f=b.getId(e);b.setPosition(e,c),e.style.width=d[0]+"px",e.style.height=d[1]+"px",b.manage(f,e,!0),a.id=f,a.element=e},f=function(a,c,d,e,f,g,h,i){var j=new b.FloatingAnchor({reference:c,referenceCanvas:e,jsPlumbInstance:g});return h({paintStyle:a,endpoint:d,anchor:j,source:f,scope:i})},g=["connectorStyle","connectorHoverStyle","connectorOverlays","connector","connectionType","connectorClass","connectorHoverClass"],h=function(a,b){var c=0;if(null!=b)for(var d=0;d0)for(var b=0;b0?"add":"remove")+"Class"](i.endpointConnectedClass),this[(this.isFull()?"add":"remove")+"Class"](i.endpointFullClass)},this.detachFromConnection=function(a,b,c){b=null==b?this.connections.indexOf(a):b,b>=0&&(this.connections.splice(b,1),this[(this.connections.length>0?"add":"remove")+"Class"](i.endpointConnectedClass),this[(this.isFull()?"add":"remove")+"Class"](i.endpointFullClass)),!c&&m&&0===this.connections.length&&i.deleteObject({endpoint:this,fireEvent:!1,deleteAttachedObjects:c!==!0})},this.deleteEveryConnection=function(a){for(var b=this.connections.length,c=0;b>c;c++)i.deleteConnection(this.connections[0],a)},this.detachFrom=function(a,b,c){for(var d=[],e=0;ef;f++)i.deleteConnection(d[0]);return this},this.getElement=function(){return this.element},this.setElement=function(d){var e=this._jsPlumb.instance.getId(d),f=this.elementId;return c.removeWithFunction(a.endpointsByElement[this.elementId],function(a){return a.id===this.id}.bind(this)),this.element=b.getElement(d),this.elementId=i.getId(this.element),i.anchorManager.rehomeEndpoint(this,f,this.element),i.dragManager.endpointAdded(this.element),c.addToList(a.endpointsByElement,e,this),this},this.makeInPlaceCopy=function(){var b=this.anchor.getCurrentLocation({element:this}),c=this.anchor.getOrientation(this),d=this.anchor.getCssClass(),e={bind:function(){},compute:function(){return[b[0],b[1]]},getCurrentLocation:function(){return[b[0],b[1]]},getOrientation:function(){return c},getCssClass:function(){return d}};return k({dropOptions:a.dropOptions,anchor:e,source:this.element,paintStyle:this.getPaintStyle(),endpoint:a.hideOnDrag?"Blank":this.endpoint,_transient:!0,scope:this.scope,reference:this})},this.connectorSelector=function(){return this.connections[0]},this.setStyle=this.setPaintStyle,this.paint=function(a){a=a||{};var b=a.timestamp,c=!(a.recalc===!1);if(!b||this.timestamp!==b){var d=i.updateOffset({elId:this.elementId,timestamp:b}),e=a.offset?a.offset.o:d.o;if(null!=e){var f=a.anchorPoint,g=a.connectorPaintStyle;if(null==f){var j=a.dimensions||d.s,k={xy:[e.left,e.top],wh:j,element:this,timestamp:b};if(c&&this.anchor.isDynamic&&this.connections.length>0){var l=h(this,a.elementWithPrecedence),m=l.endpoints[0]===this?1:0,n=0===m?l.sourceId:l.targetId,o=i.getCachedData(n),p=o.o,q=o.s;k.index=0===m?1:0,k.connection=l,k.txy=[p.left,p.top],k.twh=q,k.tElement=l.endpoints[m]}else this.connections.length>0&&(k.connection=this.connections[0]);f=this.anchor.compute(k)}this.endpoint.compute(f,this.anchor.getOrientation(this),this._jsPlumb.paintStyleInUse,g||this.paintStyleInUse),this.endpoint.paint(this._jsPlumb.paintStyleInUse,this.anchor),this.timestamp=b;for(var r in this._jsPlumb.overlays)if(this._jsPlumb.overlays.hasOwnProperty(r)){var s=this._jsPlumb.overlays[r];s.isVisible()&&(this._jsPlumb.overlayPlacements[r]=s.draw(this.endpoint,this._jsPlumb.paintStyleInUse),s.paint(this._jsPlumb.overlayPlacements[r]))}}}},this.getTypeDescriptor=function(){return"endpoint"},this.isVisible=function(){return this._jsPlumb.visible},this.repaint=this.paint;var p=!1;this.initDraggable=function(){if(!p&&b.isDragSupported(this.element)){var g,h={id:null,element:null},m=null,n=!1,o=null,q=d(this,h,i),r=a.dragOptions||{},s={},t=b.dragEvents.start,u=b.dragEvents.stop,v=b.dragEvents.drag,w=b.dragEvents.beforeStart,x=function(a){g=a.e.payload||{}},y=function(c){m=this.connectorSelector();var d=!0;this.isEnabled()||(d=!1),null!=m||this.isSource||this.isTemporarySource||(d=!1),!this.isSource||!this.isFull()||null!=m&&this.dragAllowedWhenFull||(d=!1),null==m||m.isDetachable(this)||(d=!1);var l=i.checkCondition(null==m?"beforeDrag":"beforeStartDetach",{endpoint:this,source:this.element,sourceId:this.elementId,connection:m});if(l===!1?d=!1:"object"==typeof l?b.extend(l,g||{}):l=g||{},d===!1)return i.stopDrag&&i.stopDrag(this.canvas),q.stopDrag(),!1;for(var p=0;p0}.bind(this),i.initDraggable(this.canvas,r,"internal"),this.canvas._jsPlumbRelatedElement=this.element,p=!0}};var q=a.endpoint||this._jsPlumb.instance.Defaults.Endpoint||b.Defaults.Endpoint;this.setEndpoint(q,!0);var r=a.anchor?a.anchor:a.anchors?a.anchors:i.Defaults.Anchor||"Top";this.setAnchor(r,!0);var s=["default",a.type||""].join(" ");this.addType(s,a.data,!0),this.canvas=this.endpoint.canvas,this.canvas._jsPlumb=this,this.initDraggable();var t=function(d,e,f,g){if(b.isDropSupported(this.element)){var h=a.dropOptions||i.Defaults.DropOptions||b.Defaults.DropOptions;h=b.extend({},h),h.scope=h.scope||this.scope;var j=b.dragEvents.drop,k=b.dragEvents.over,l=b.dragEvents.out,m=this,n=i.EndpointDropHandler({getEndpoint:function(){return m},jsPlumb:i,enabled:function(){return null!=f?f.isEnabled():!0},isFull:function(){return f.isFull()},element:this.element,elementId:this.elementId,isSource:this.isSource,isTarget:this.isTarget,addClass:function(a){m.addClass(a)},removeClass:function(a){m.removeClass(a)},isDropAllowed:function(){return m.isDropAllowed.apply(m,arguments)},reference:g,isRedrop:function(a,b){return a.suspendedEndpoint&&b.reference&&a.suspendedEndpoint.id===b.reference.id}});h[j]=c.wrap(h[j],n,!0),h[k]=c.wrap(h[k],function(){var a=b.getDragObject(arguments),c=i.getAttribute(b.getElement(a),"dragId"),d=i.getFloatingConnectionFor(c);if(null!=d){var e=i.getFloatingAnchorIndex(d),f=this.isTarget&&0!==e||d.suspendedEndpoint&&this.referenceEndpoint&&this.referenceEndpoint.id===d.suspendedEndpoint.id;if(f){var g=i.checkCondition("checkDropAllowed",{sourceEndpoint:d.endpoints[e],targetEndpoint:this,connection:d});this[(g?"add":"remove")+"Class"](i.endpointDropAllowedClass),this[(g?"remove":"add")+"Class"](i.endpointDropForbiddenClass),d.endpoints[e].anchor.over(this.anchor,this)}}}.bind(this)),h[l]=c.wrap(h[l],function(){var a=b.getDragObject(arguments),c=null==a?null:i.getAttribute(b.getElement(a),"dragId"),d=c?i.getFloatingConnectionFor(c):null;if(null!=d){var e=i.getFloatingAnchorIndex(d),f=this.isTarget&&0!==e||d.suspendedEndpoint&&this.referenceEndpoint&&this.referenceEndpoint.id===d.suspendedEndpoint.id;f&&(this.removeClass(i.endpointDropAllowedClass),this.removeClass(i.endpointDropForbiddenClass),d.endpoints[e].anchor.out())}}.bind(this)),i.initDroppable(d,h,"internal",e)}}.bind(this);return this.anchor.isFloating||t(this.canvas,!(a._transient||this.anchor.isFloating),this,a.reference),this},c.extend(b.Endpoint,b.OverlayCapableJsPlumbUIComponent,{setVisible:function(a,b,c){if(this._jsPlumb.visible=a,this.canvas&&(this.canvas.style.display=a?"block":"none"),this[a?"showOverlays":"hideOverlays"](),!b)for(var d=0;dc[0][0],d===!1?-1:1}},o=function(a,b){var c=a[0][0]<0?-Math.PI-a[0][0]:Math.PI-a[0][0],d=b[0][0]<0?-Math.PI-b[0][0]:Math.PI-b[0][0];return c>d?1:-1},p={top:function(a,b){return a[0]>b[0]?1:-1},right:n(!0),bottom:n(!0),left:o},q=function(a,b){return a.sort(b)},r=function(a,b){var c=k.getCachedData(a),d=c.s,f=c.o,h=function(b,c,d,f,h,i,j){if(f.length>0)for(var k=q(f,p[b]),l="right"===b||"top"===b,n=m(b,c,d,k,h,i,l),o=function(a,b){e[a.id]=[b[0],b[1],b[2],b[3]],g[a.id]=j},r=0;r-1&&(h[d].splice(i,1),b.addToList(h,e,[f,f.endpoints[0],f.endpoints[0].anchor.constructor===c.DynamicAnchor])),f.updateConnectedClass()},this.sourceChanged=function(a,d,e,f){if(a!==d){e.sourceId=d,e.source=f,b.removeWithFunction(h[a],function(a){return a[0].id===e.id});var g=b.findWithFunction(h[e.targetId],function(a){return a[0].id===e.id});g>-1&&(h[e.targetId][g][0]=e,h[e.targetId][g][1]=e.endpoints[0],h[e.targetId][g][2]=e.endpoints[0].anchor.constructor===c.DynamicAnchor),b.addToList(h,d,[e,e.endpoints[1],e.endpoints[1].anchor.constructor===c.DynamicAnchor]),e.endpoints[1].anchor.isContinuous&&(e.source===e.target?e._jsPlumb.instance.removeElement(e.endpoints[1].canvas):null==e.endpoints[1].canvas.parentNode&&e._jsPlumb.instance.appendElement(e.endpoints[1].canvas)),e.updateConnectedClass()}},this.rehomeEndpoint=function(a,b,c){var e=d[b]||[],f=k.getId(c);if(f!==b){var g=e.indexOf(a);if(g>-1){var h=e.splice(g,1)[0];i.add(h,f)}}for(var j=0;jb.dist?1:0});for(var o=k[0].source,p=k[0].target,q=0;q0?this.anchors[0]:null,f=e,g=this,h=function(a,b,c,d,e){var f=d[0]+a.x*e[0],g=d[1]+a.y*e[1],h=d[0]+e[0]/2,i=d[1]+e[1]/2;return Math.sqrt(Math.pow(b-f,2)+Math.pow(c-g,2))+Math.sqrt(Math.pow(h-f,2)+Math.pow(i-g,2))},i=a.selector||function(a,b,c,d,e){for(var f=c[0]+d[0]/2,g=c[1]+d[1]/2,i=-1,j=1/0,k=0;kl&&(i=k+0,j=l)}return e[i]};this.compute=function(a){var b=a.xy,c=a.wh,d=a.txy,h=a.twh;this.timestamp=a.timestamp;var j=g.getUserDefinedLocation();return null!=j?j:this.isLocked()||null==d||null==h?e.compute(a):(a.timestamp=null,e=i(b,c,d,h,this.anchors),this.x=e.x,this.y=e.y,e!==f&&this.fire("anchorChanged",e),f=e,e.compute(a))},this.getCurrentLocation=function(a){return this.getUserDefinedLocation()||(null!=e?e.getCurrentLocation(a):null)},this.getOrientation=function(a){return null!=e?e.getOrientation(a):[0,0]},this.over=function(a,b){null!=e&&e.over(a,b)},this.out=function(){null!=e&&e.out()},this.setAnchor=function(a){e=a},this.getCssClass=function(){return e&&e.getCssClass()||""},this.setAnchorCoordinates=function(a){var b=jsPlumbUtil.findWithFunction(this.anchors,function(b){return b.x===a[0]&&b.y===a[1]});return-1!==b?(this.setAnchor(this.anchors[b]),!0):!1}},b.extend(c.DynamicAnchor,c.Anchor);var e=function(a,b,d,e,f,g){c.Anchors[f]=function(c){var h=c.jsPlumbInstance.makeAnchor([a,b,d,e,0,0],c.elementId,c.jsPlumbInstance);return h.type=f,g&&g(h,c),h}};e(.5,0,0,-1,"TopCenter"),e(.5,1,0,1,"BottomCenter"),e(0,.5,-1,0,"LeftMiddle"),e(1,.5,1,0,"RightMiddle"),e(.5,0,0,-1,"Top"),e(.5,1,0,1,"Bottom"),e(0,.5,-1,0,"Left"),e(1,.5,1,0,"Right"),e(.5,.5,0,0,"Center"),e(1,0,0,-1,"TopRight"),e(1,1,0,1,"BottomRight"),e(0,0,0,-1,"TopLeft"),e(0,1,0,1,"BottomLeft"),c.Defaults.DynamicAnchors=function(a){return a.jsPlumbInstance.makeAnchors(["TopCenter","RightMiddle","BottomCenter","LeftMiddle"],a.elementId,a.jsPlumbInstance)},c.Anchors.AutoDefault=function(a){var b=a.jsPlumbInstance.makeDynamicAnchor(c.Defaults.DynamicAnchors(a));return b.type="AutoDefault",b};var f=function(a,b){c.Anchors[a]=function(c){var d=c.jsPlumbInstance.makeAnchor(["Continuous",{faces:b}],c.elementId,c.jsPlumbInstance);return d.type=a,d}};c.Anchors.Continuous=function(a){return a.jsPlumbInstance.continuousAnchorFactory.get(a)},f("ContinuousLeft",["left"]),f("ContinuousTop",["top"]),f("ContinuousBottom",["bottom"]),f("ContinuousRight",["right"]),e(0,0,0,0,"Assign",function(a,b){var c=b.position||"Fixed";a.positionFinder=c.constructor===String?b.jsPlumbInstance.AnchorPositionFinders[c]:c,a.constructorParams=b}),a.jsPlumbInstance.prototype.AnchorPositionFinders={Fixed:function(a,b,c){return[(a.left-b.left)/c[0],(a.top-b.top)/c[1]]},Grid:function(a,b,c,d){var e=a.left-b.left,f=a.top-b.top,g=c[0]/d.grid[0],h=c[1]/d.grid[1],i=Math.floor(e/g),j=Math.floor(f/h);return[(i*g+g/2)/c[0],(j*h+h/2)/c[1]]}},c.Anchors.Perimeter=function(a){a=a||{};var b=a.anchorCount||60,c=a.shape;if(!c)throw new Error("no shape supplied to Perimeter Anchor type");var d=function(){for(var a=.5,c=2*Math.PI/b,d=0,e=[],f=0;b>f;f++){var g=a+a*Math.sin(d),h=a+a*Math.cos(d);e.push([g,h,0,0]),d+=c}return e},e=function(a){for(var c=b/a.length,d=[],e=function(a,e,f,g,h){c=b*h;for(var i=(f-a)/c,j=(g-e)/c,k=0;c>k;k++)d.push([a+i*k,e+j*k,0,0])},f=0;f0?a:c+a:a*c;return d.pointOnLine({x:g,y:i},{x:h,y:j},e)}return{x:h,y:j}}return{x:g,y:i}},this.gradientAtPoint=function(a){return e},this.pointAlongPathFrom=function(a,b,c){var e=this.pointOnPath(a,c),f=0>=b?{x:g,y:i}:{x:h,y:j};return 0>=b&&Math.abs(b)>1&&(b*=-1),d.pointOnLine(e,f,b)};var l=function(a,b,c){return c>=Math.min(a,b)&&c<=Math.max(a,b)},m=function(a,b,c){return Math.abs(c-a)a-b?b:k>c-a?c:a};this.pointOnPath=function(b,c){if(0===b)return{x:this.x1,y:this.y1,theta:this.startAngle};if(1===b)return{x:this.x2,y:this.y2,theta:this.endAngle};c&&(b/=j);var d=e(this,b),f=a.cx+a.r*Math.cos(d),g=a.cy+a.r*Math.sin(d);return{x:l(f),y:l(g),theta:d}},this.gradientAtPoint=function(b,c){var e=this.pointOnPath(b,c),f=d.normal([a.cx,a.cy],[e.x,e.y]);return this.anticlockwise||f!==1/0&&f!==-(1/0)||(f*=-1),f},this.pointAlongPathFrom=function(b,c,d){var e=this.pointOnPath(b,d),f=c/h*2*Math.PI,g=this.anticlockwise?-1:1,i=e.theta+g*f,j=a.cx+this.radius*Math.cos(i),k=a.cy+this.radius*Math.sin(i);return{x:j,y:k}}},Bezier:function(c){this.curve=[{x:c.x1,y:c.y1},{x:c.cp1x,y:c.cp1y},{x:c.cp2x,y:c.cp2y},{x:c.x2,y:c.y2}];b.Segments.AbstractSegment.apply(this,arguments);this.bounds={minX:Math.min(c.x1,c.x2,c.cp1x,c.cp2x),minY:Math.min(c.y1,c.y2,c.cp1y,c.cp2y),maxX:Math.max(c.x1,c.x2,c.cp1x,c.cp2x),maxY:Math.max(c.y1,c.y2,c.cp1y,c.cp2y)},this.type="Bezier";var d=function(b,c,d){return d&&(c=a.jsBezier.locationAlongCurveFrom(b,c>0?0:1,c)),c};this.pointOnPath=function(b,c){return b=d(this.curve,b,c),a.jsBezier.pointOnCurve(this.curve,b)},this.gradientAtPoint=function(b,c){return b=d(this.curve,b,c),a.jsBezier.gradientAtPoint(this.curve,b)},this.pointAlongPathFrom=function(b,c,e){return b=d(this.curve,b,e),a.jsBezier.pointAlongCurveFrom(this.curve,b,c)},this.getLength=function(){return a.jsBezier.getLength(this.curve)},this.getBounds=function(){return this.bounds}}},b.SegmentRenderer={getPath:function(a){return{Straight:function(){var b=a.getCoordinates();return"M "+b.x1+" "+b.y1+" L "+b.x2+" "+b.y2},Bezier:function(){var b=a.params;return"M "+b.x1+" "+b.y1+" C "+b.cp1x+" "+b.cp1y+" "+b.cp2x+" "+b.cp2y+" "+b.x2+" "+b.y2},Arc:function(){var b=a.params,c=a.sweep>Math.PI?1:0,d=a.anticlockwise?0:1;return"M"+a.x1+" "+a.y1+" A "+a.radius+" "+b.r+" 0 "+c+","+d+" "+a.x2+" "+a.y2}}[a.type]()}};var e=function(){this.resetBounds=function(){this.bounds={minX:1/0,minY:1/0,maxX:-(1/0),maxY:-(1/0)}},this.resetBounds()};b.Connectors.AbstractConnector=function(a){e.apply(this,arguments);var f=[],g=0,h=[],i=[],j=a.stub||0,k=c.isArray(j)?j[0]:j,l=c.isArray(j)?j[1]:j,m=a.gap||0,n=c.isArray(m)?m[0]:m,o=c.isArray(m)?m[1]:m,p=null,q=null;this.getPathData=function(){for(var a="",c=0;c0?a/g:(g+a)/g);for(var c=h.length-1,d=1,e=0;e=a){c=e,d=1===a?1:0===a?0:(a-h[e][0])/i[e];break}return{segment:f[c],proportion:d,index:c}},t=function(a,c,d){if(d.x1!==d.x2||d.y1!==d.y2){var e=new b.Segments[c](d);f.push(e),g+=e.getLength(),a.updateBounds(e)}},u=function(){g=f.length=h.length=i.length=0};this.setSegments=function(a){p=[],g=0;for(var b=0;bp?0:1,r=[1,0][q];g=[],h=[],g[q]=a.sourcePos[q]>a.targetPos[q]?-1:1,h[q]=a.sourcePos[q]>a.targetPos[q]?1:-1,g[r]=0,h[r]=0}var s=c?m+n*g[0]:n*g[0],t=e?p+n*g[1]:n*g[1],u=c?o*h[0]:m+o*h[0],v=e?o*h[1]:p+o*h[1],w=g[0]*h[0]+g[1]*h[1],x={sx:s,sy:t,tx:u,ty:v,lw:f,xSpan:Math.abs(u-s),ySpan:Math.abs(v-t),mx:(s+u)/2,my:(t+v)/2,so:g,to:h,x:i,y:j,w:m,h:p,segment:b,startStubX:s+g[0]*k,startStubY:t+g[1]*k,endStubX:u+h[0]*l,endStubY:v+h[1]*l,isXGreaterThanStubTimes2:Math.abs(s-u)>k+l,isYGreaterThanStubTimes2:Math.abs(t-v)>k+l,opposite:-1===w,perpendicular:0===w,orthogonal:1===w,sourceAxis:0===g[0]?"y":"x",points:[i,j,m,p,s,t,u,v],stubs:[k,l]};return x.anchorOrientation=x.opposite?"opposite":x.orthogonal?"orthogonal":"perpendicular",x};this.getSegments=function(){return f},this.updateBounds=function(a){var b=a.getBounds();this.bounds.minX=Math.min(this.bounds.minX,b.minX),this.bounds.maxX=Math.max(this.bounds.maxX,b.maxX),this.bounds.minY=Math.min(this.bounds.minY,b.minY),this.bounds.maxY=Math.max(this.bounds.maxY,b.maxY)};return this.pointOnPath=function(a,b){var c=s(a,b);return c.segment&&c.segment.pointOnPath(c.proportion,!1)||[0,0]},this.gradientAtPoint=function(a,b){var c=s(a,b);return c.segment&&c.segment.gradientAtPoint(c.proportion,!1)||0},this.pointAlongPathFrom=function(a,b,c){var d=s(a,c);return d.segment&&d.segment.pointAlongPathFrom(d.proportion,b,!1)||[0,0]},this.compute=function(a){q=v.call(this,a),u(),this._compute(q,a),this.x=q.points[0],this.y=q.points[1],this.w=q.points[2],this.h=q.points[3],this.segment=q.segment,r()},{addSegment:t,prepareCompute:v,sourceStub:k,targetStub:l,maxStub:Math.max(k,l),sourceGap:n,targetGap:o,maxGap:Math.max(n,o)}},c.extend(b.Connectors.AbstractConnector,e),b.Endpoints.AbstractEndpoint=function(a){e.apply(this,arguments);var b=this.compute=function(a,b,c,d){var e=this._compute.apply(this,arguments);return this.x=e[0],this.y=e[1],this.w=e[2],this.h=e[3],this.bounds.minX=this.x,this.bounds.minY=this.y,this.bounds.maxX=this.x+this.w,this.bounds.maxY=this.y+this.h,e};return{compute:b,cssClass:a.cssClass}},c.extend(b.Endpoints.AbstractEndpoint,e),b.Endpoints.Dot=function(a){this.type="Dot";b.Endpoints.AbstractEndpoint.apply(this,arguments);a=a||{},this.radius=a.radius||10,this.defaultOffset=.5*this.radius,this.defaultInnerRadius=this.radius/3,this._compute=function(a,b,c,d){this.radius=c.radius||this.radius;var e=a[0]-this.radius,f=a[1]-this.radius,g=2*this.radius,h=2*this.radius;if(c.stroke){var i=c.strokeWidth||1;e-=i,f-=i,g+=2*i,h+=2*i}return[e,f,g,h,this.radius]}},c.extend(b.Endpoints.Dot,b.Endpoints.AbstractEndpoint),b.Endpoints.Rectangle=function(a){this.type="Rectangle";b.Endpoints.AbstractEndpoint.apply(this,arguments);a=a||{},this.width=a.width||20,this.height=a.height||20,this._compute=function(a,b,c,d){var e=c.width||this.width,f=c.height||this.height,g=a[0]-e/2,h=a[1]-f/2;return[g,h,e,f]}},c.extend(b.Endpoints.Rectangle,b.Endpoints.AbstractEndpoint);var f=function(a){b.jsPlumbUIComponent.apply(this,arguments),this._jsPlumb.displayElements=[]};c.extend(f,b.jsPlumbUIComponent,{getDisplayElements:function(){return this._jsPlumb.displayElements},appendDisplayElement:function(a){this._jsPlumb.displayElements.push(a)}}),b.Endpoints.Image=function(d){this.type="Image",f.apply(this,arguments),b.Endpoints.AbstractEndpoint.apply(this,arguments);var e=d.onload,g=d.src||d.url,h=d.cssClass?" "+d.cssClass:"";this._jsPlumb.img=new Image,this._jsPlumb.ready=!1,this._jsPlumb.initialized=!1,this._jsPlumb.deleted=!1,this._jsPlumb.widthToUse=d.width,this._jsPlumb.heightToUse=d.height,this._jsPlumb.endpoint=d.endpoint,this._jsPlumb.img.onload=function(){null!=this._jsPlumb&&(this._jsPlumb.ready=!0,this._jsPlumb.widthToUse=this._jsPlumb.widthToUse||this._jsPlumb.img.width,this._jsPlumb.heightToUse=this._jsPlumb.heightToUse||this._jsPlumb.img.height,e&&e(this))}.bind(this),this._jsPlumb.endpoint.setImage=function(a,b){var c=a.constructor===String?a:a.src;e=b,this._jsPlumb.img.src=c,null!=this.canvas&&this.canvas.setAttribute("src",this._jsPlumb.img.src)}.bind(this),this._jsPlumb.endpoint.setImage(g,e),this._compute=function(a,b,c,d){return this.anchorPoint=a,this._jsPlumb.ready?[a[0]-this._jsPlumb.widthToUse/2,a[1]-this._jsPlumb.heightToUse/2,this._jsPlumb.widthToUse,this._jsPlumb.heightToUse]:[0,0,0,0]},this.canvas=b.createElement("img",{position:"absolute",margin:0,padding:0,outline:0},this._jsPlumb.instance.endpointClass+h),this._jsPlumb.widthToUse&&this.canvas.setAttribute("width",this._jsPlumb.widthToUse),this._jsPlumb.heightToUse&&this.canvas.setAttribute("height",this._jsPlumb.heightToUse),this._jsPlumb.instance.appendElement(this.canvas),this.actuallyPaint=function(a,b,d){if(!this._jsPlumb.deleted){this._jsPlumb.initialized||(this.canvas.setAttribute("src",this._jsPlumb.img.src),this.appendDisplayElement(this.canvas),this._jsPlumb.initialized=!0);var e=this.anchorPoint[0]-this._jsPlumb.widthToUse/2,f=this.anchorPoint[1]-this._jsPlumb.heightToUse/2;c.sizeElement(this.canvas,e,f,this._jsPlumb.widthToUse,this._jsPlumb.heightToUse)}},this.paint=function(b,c){null!=this._jsPlumb&&(this._jsPlumb.ready?this.actuallyPaint(b,c):a.setTimeout(function(){this.paint(b,c)}.bind(this),200))}},c.extend(b.Endpoints.Image,[f,b.Endpoints.AbstractEndpoint],{cleanup:function(a){a&&(this._jsPlumb.deleted=!0,this.canvas&&this.canvas.parentNode.removeChild(this.canvas),this.canvas=null)}}),b.Endpoints.Blank=function(a){b.Endpoints.AbstractEndpoint.apply(this,arguments);this.type="Blank",f.apply(this,arguments),this._compute=function(a,b,c,d){return[a[0],a[1],10,0]};var d=a.cssClass?" "+a.cssClass:"";this.canvas=b.createElement("div",{display:"block",width:"1px",height:"1px",background:"transparent",position:"absolute"},this._jsPlumb.instance.endpointClass+d),this._jsPlumb.instance.appendElement(this.canvas),this.paint=function(a,b){c.sizeElement(this.canvas,this.x,this.y,this.w,this.h)}},c.extend(b.Endpoints.Blank,[b.Endpoints.AbstractEndpoint,f],{cleanup:function(){this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}}),b.Endpoints.Triangle=function(a){this.type="Triangle",b.Endpoints.AbstractEndpoint.apply(this,arguments);var c=this;a=a||{},a.width=a.width||55,a.height=a.height||55,this.width=a.width,this.height=a.height,this._compute=function(a,b,d,e){var f=d.width||c.width,g=d.height||c.height,h=a[0]-f/2,i=a[1]-g/2;return[h,i,f,g]}};var g=b.Overlays.AbstractOverlay=function(a){this.visible=!0,this.isAppendedAtTopLevel=!0,this.component=a.component,this.loc=null==a.location?.5:a.location,this.endpointLoc=null==a.endpointLocation?[.5,.5]:a.endpointLocation,this.visible=a.visible!==!1};g.prototype={cleanup:function(a){a&&(this.component=null,this.canvas=null,this.endpointLoc=null)},reattach:function(a,b){},setVisible:function(a){this.visible=a,this.component.repaint()},isVisible:function(){return this.visible},hide:function(){this.setVisible(!1)},show:function(){this.setVisible(!0)},incrementLocation:function(a){this.loc+=a,this.component.repaint()},setLocation:function(a){this.loc=a,this.component.repaint()},getLocation:function(){return this.loc},updateFrom:function(){}},b.Overlays.Arrow=function(a){this.type="Arrow",g.apply(this,arguments),this.isAppendedAtTopLevel=!1,a=a||{};var e=this;this.length=a.length||20,this.width=a.width||20,this.id=a.id;var f=(a.direction||1)<0?-1:1,h=a.paintStyle||{"stroke-width":1},i=a.foldback||.623;this.computeMaxSize=function(){return 1.5*e.width},this.elementCreated=function(c,d){if(this.path=c,a.events)for(var e in a.events)b.on(c,e,a.events[e])},this.draw=function(a,b){var e,g,j,k,l;if(a.pointAlongPathFrom){if(c.isString(this.loc)||this.loc>1||this.loc<0){ +var m=parseInt(this.loc,10),n=this.loc<0?1:0;e=a.pointAlongPathFrom(n,m,!1),g=a.pointAlongPathFrom(n,m-f*this.length/2,!1),j=d.pointOnLine(e,g,this.length)}else if(1===this.loc){if(e=a.pointOnPath(this.loc),g=a.pointAlongPathFrom(this.loc,-this.length),j=d.pointOnLine(e,g,this.length),-1===f){var o=j;j=e,e=o}}else if(0===this.loc){if(j=a.pointOnPath(this.loc),g=a.pointAlongPathFrom(this.loc,this.length),e=d.pointOnLine(j,g,this.length),-1===f){var p=j;j=e,e=p}}else e=a.pointAlongPathFrom(this.loc,f*this.length/2),g=a.pointOnPath(this.loc),j=d.pointOnLine(e,g,this.length);k=d.perpendicularLineTo(e,j,this.width),l=d.pointOnLine(e,j,i*this.length);var q={hxy:e,tail:k,cxy:l},r=h.stroke||b.stroke,s=h.fill||b.stroke,t=h.strokeWidth||b.strokeWidth;return{component:a,d:q,"stroke-width":t,stroke:r,fill:s,minX:Math.min(e.x,k[0].x,k[1].x),maxX:Math.max(e.x,k[0].x,k[1].x),minY:Math.min(e.y,k[0].y,k[1].y),maxY:Math.max(e.y,k[0].y,k[1].y)}}return{component:a,minX:0,maxX:0,minY:0,maxY:0}}},c.extend(b.Overlays.Arrow,g,{updateFrom:function(a){this.length=a.length||this.length,this.width=a.width||this.width,this.direction=null!=a.direction?a.direction:this.direction,this.foldback=a.foldback||this.foldback}}),b.Overlays.PlainArrow=function(a){a=a||{};var c=b.extend(a,{foldback:1});b.Overlays.Arrow.call(this,c),this.type="PlainArrow"},c.extend(b.Overlays.PlainArrow,b.Overlays.Arrow),b.Overlays.Diamond=function(a){a=a||{};var c=a.length||40,d=b.extend(a,{length:c/2,foldback:2});b.Overlays.Arrow.call(this,d),this.type="Diamond"},c.extend(b.Overlays.Diamond,b.Overlays.Arrow);var h=function(a,b){return(null==a._jsPlumb.cachedDimensions||b)&&(a._jsPlumb.cachedDimensions=a.getDimensions()),a._jsPlumb.cachedDimensions},i=function(a){b.jsPlumbUIComponent.apply(this,arguments),g.apply(this,arguments);var d=this.fire;this.fire=function(){d.apply(this,arguments),this.component&&this.component.fire.apply(this.component,arguments)},this.detached=!1,this.id=a.id,this._jsPlumb.div=null,this._jsPlumb.initialised=!1,this._jsPlumb.component=a.component,this._jsPlumb.cachedDimensions=null,this._jsPlumb.create=a.create,this._jsPlumb.initiallyInvisible=a.visible===!1,this.getElement=function(){if(null==this._jsPlumb.div){var c=this._jsPlumb.div=b.getElement(this._jsPlumb.create(this._jsPlumb.component));c.style.position="absolute",c.className=this._jsPlumb.instance.overlayClass+" "+(this.cssClass?this.cssClass:a.cssClass?a.cssClass:""),this._jsPlumb.instance.appendElement(c),this._jsPlumb.instance.getId(c),this.canvas=c;var d="translate(-50%, -50%)";c.style.webkitTransform=d,c.style.mozTransform=d,c.style.msTransform=d,c.style.oTransform=d,c.style.transform=d,c._jsPlumb=this,a.visible===!1&&(c.style.display="none")}return this._jsPlumb.div},this.draw=function(a,b,d){var e=h(this);if(null!=e&&2===e.length){var f={x:0,y:0};if(d)f={x:d[0],y:d[1]};else if(a.pointOnPath){var g=this.loc,i=!1;(c.isString(this.loc)||this.loc<0||this.loc>1)&&(g=parseInt(this.loc,10),i=!0),f=a.pointOnPath(g,i)}else{var j=this.loc.constructor===Array?this.loc:this.endpointLoc;f={x:j[0]*a.w,y:j[1]*a.h}}var k=f.x-e[0]/2,l=f.y-e[1]/2;return{component:a,d:{minx:k,miny:l,td:e,cxy:f},minX:k,maxX:k+e[0],minY:l,maxY:l+e[1]}}return{minX:0,maxX:0,minY:0,maxY:0}}};c.extend(i,[b.jsPlumbUIComponent,g],{getDimensions:function(){return[1,1]},setVisible:function(a){this._jsPlumb.div&&(this._jsPlumb.div.style.display=a?"block":"none",a&&this._jsPlumb.initiallyInvisible&&(h(this,!0),this.component.repaint(),this._jsPlumb.initiallyInvisible=!1))},clearCachedDimensions:function(){this._jsPlumb.cachedDimensions=null},cleanup:function(a){a?null!=this._jsPlumb.div&&(this._jsPlumb.div._jsPlumb=null,this._jsPlumb.instance.removeElement(this._jsPlumb.div)):(this._jsPlumb&&this._jsPlumb.div&&this._jsPlumb.div.parentNode&&this._jsPlumb.div.parentNode.removeChild(this._jsPlumb.div),this.detached=!0)},reattach:function(a,b){null!=this._jsPlumb.div&&a.getContainer().appendChild(this._jsPlumb.div),this.detached=!1},computeMaxSize:function(){var a=h(this);return Math.max(a[0],a[1])},paint:function(a,b){this._jsPlumb.initialised||(this.getElement(),a.component.appendDisplayElement(this._jsPlumb.div),this._jsPlumb.initialised=!0,this.detached&&this._jsPlumb.div.parentNode.removeChild(this._jsPlumb.div)),this._jsPlumb.div.style.left=a.component.x+a.d.minx+"px",this._jsPlumb.div.style.top=a.component.y+a.d.miny+"px"}}),b.Overlays.Custom=function(a){this.type="Custom",i.apply(this,arguments)},c.extend(b.Overlays.Custom,i),b.Overlays.GuideLines=function(){var a=this;a.length=50,a.strokeWidth=5,this.type="GuideLines",g.apply(this,arguments),b.jsPlumbUIComponent.apply(this,arguments),this.draw=function(b,c){var e=b.pointAlongPathFrom(a.loc,a.length/2),f=b.pointOnPath(a.loc),g=d.pointOnLine(e,f,a.length),h=d.perpendicularLineTo(e,g,40),i=d.perpendicularLineTo(g,e,20);return{connector:b,head:e,tail:g,headLine:i,tailLine:h,minX:Math.min(e.x,g.x,i[0].x,i[1].x),minY:Math.min(e.y,g.y,i[0].y,i[1].y),maxX:Math.max(e.x,g.x,i[0].x,i[1].x),maxY:Math.max(e.y,g.y,i[0].y,i[1].y)}}},b.Overlays.Label=function(a){this.labelStyle=a.labelStyle;this.cssClass=null!=this.labelStyle?this.labelStyle.cssClass:null;var c=b.extend({create:function(){return b.createElement("div")}},a);if(b.Overlays.Custom.call(this,c),this.type="Label",this.label=a.label||"",this.labelText=null,this.labelStyle){var d=this.getElement();if(this.labelStyle.font=this.labelStyle.font||"12px sans-serif",d.style.font=this.labelStyle.font,d.style.color=this.labelStyle.color||"black",this.labelStyle.fill&&(d.style.background=this.labelStyle.fill),this.labelStyle.borderWidth>0){var e=this.labelStyle.borderStyle?this.labelStyle.borderStyle:"black";d.style.border=this.labelStyle.borderWidth+"px solid "+e}this.labelStyle.padding&&(d.style.padding=this.labelStyle.padding)}},c.extend(b.Overlays.Label,b.Overlays.Custom,{cleanup:function(a){a&&(this.div=null,this.label=null,this.labelText=null,this.cssClass=null,this.labelStyle=null)},getLabel:function(){return this.label},setLabel:function(a){this.label=a,this.labelText=null,this.clearCachedDimensions(),this.update(),this.component.repaint()},getDimensions:function(){return this.update(),i.prototype.getDimensions.apply(this,arguments)},update:function(){if("function"==typeof this.label){var a=this.label(this);this.getElement().innerHTML=a.replace(/\r\n/g,"
")}else null==this.labelText&&(this.labelText=this.label,this.getElement().innerHTML=this.labelText.replace(/\r\n/g,"
"))},updateFrom:function(a){null!=a.label&&this.setLabel(a.label)}})}.call("undefined"!=typeof window?window:this),function(){"use strict";var a=this,b=a.jsPlumb,c=function(b){var c=b._mottle;return c||(c=b._mottle=new a.Mottle),c};b.extend(a.jsPlumbInstance.prototype,{getEventManager:function(){return c(this)},on:function(a,b,c){return this.getEventManager().on.apply(this,arguments),this},off:function(a,b,c){return this.getEventManager().off.apply(this,arguments),this}})}.call("undefined"!=typeof window?window:this),function(){"use strict";var a=this,b=a.jsPlumbUtil,c=a.jsPlumbInstance,d="jtk-group-collapsed",e="jtk-group-expanded",f="[jtk-group-content]",g="elementDraggable",h="stop",i="revert",j="_groupManager",k="_jsPlumbGroup",l="_jsPlumbGroupDrag",m="group:addMember",n="group:removeMember",o="group:add",p="group:remove",q="group:expand",r="group:collapse",s="groupDragStop",t="connectionMoved",u="internal.connectionDetached",v="removeAll",w="orphanAll",x="show",y="hide",z=function(a){function c(a){delete a.proxies;var c,d=i[a.id];null!=d&&(c=function(b){return b.id===a.id},b.removeWithFunction(d.connections.source,c),b.removeWithFunction(d.connections.target,c),delete i[a.id]),d=j[a.id],null!=d&&(c=function(b){return b.id===a.id},b.removeWithFunction(d.connections.source,c),b.removeWithFunction(d.connections.target,c),delete j[a.id])}function f(b,c){for(var d=b.getMembers(),e=0;e0&&h0&&j0?a[0]:v},x=d.ghost===!0,y=x||d.constrain===!0,z=d.revert!==!1,A=d.orphan===!0,B=d.prune===!0,C=d.dropOverride===!0,D=d.proxied!==!1,E=[];if(this.connections={source:[],target:[],internal:[]},this.getAnchor=function(a,b){return d.anchor||"Continuous"},this.getEndpoint=function(a,b){return d.endpoint||["Dot",{radius:10}]},this.collapsed=!1,d.draggable!==!1){var F={stop:function(a){c.fire(s,jsPlumb.extend(a,{group:u}))},scope:l};d.dragOptions&&a.jsPlumb.extend(F,d.dragOptions),c.draggable(d.el,F)}d.droppable!==!1&&c.droppable(d.el,{drop:function(a){var b=a.drag.el;if(!b._isJsPlumbGroup){var d=b._jsPlumbGroup;if(d!==u){if(null!=d&&d.overrideDrop(b,u))return;c.getGroupManager().addToGroup(u,b,!1)}}}});var G=function(a,b){for(var c=null==a.nodeType?a:[a],d=0;dd;d++)u.remove(E[0],a,b,!0);E.length=0,c.getGroupManager().updateConnectionsForGroup(u)},this.orphanAll=function(){for(var a=0;aa?-1:0===a?0:1}),n=function(a){return[m(a[2]-a[0]),m(a[3]-a[1])]},o=function(a,b,c,d){if(j!==b||k!==c){var e=null==j?d.sx:j,f=null==k?d.sy:k,g=e===b?"v":"h";j=b,k=c,a.push([e,f,b,c,g])}},p=function(a){return Math.sqrt(Math.pow(a[0]-a[2],2)+Math.pow(a[1]-a[3],2))},q=function(a){var b=[];return b.push.apply(b,a),b},r=function(a,b,c){for(var f,h,i,j=null,k=0;k0&&j[4]!==f[4]){var m=Math.min(p(j),p(f)),o=Math.min(l,m/2);j[2]-=h[0]*o,j[3]-=h[1]*o,f[0]+=i[0]*o,f[1]+=i[1]*o;var r=h[1]===i[0]&&1===i[0]||h[1]===i[0]&&0===i[0]&&h[0]!==i[1]||h[1]===i[0]&&-1===i[0],s=f[1]>j[3]?1:-1,t=f[0]>j[2]?1:-1,u=s===t,v=u&&r||!u&&!r?f[0]:j[2],w=u&&r||!u&&!r?j[3]:f[1];g.addSegment(a,d,{x1:j[0],y1:j[1],x2:j[2],y2:j[3]}),g.addSegment(a,e,{r:o,x1:j[2],y1:j[3],x2:f[0],y2:f[1],cx:v,cy:w,ac:r})}else{var x=j[2]===j[0]?0:j[2]>j[0]?c.lw/2:-(c.lw/2),y=j[3]===j[1]?0:j[3]>j[1]?c.lw/2:-(c.lw/2);g.addSegment(a,d,{x1:j[0]-x,y1:j[1]-y,x2:j[2]+x,y2:j[3]+y})}j=f}null!=f&&g.addSegment(a,d,{x1:f[0],y1:f[1],x2:f[2],y2:f[3]})};this._compute=function(a,b){c=[],j=null,k=null,f=null;var d=function(){return[a.startStubX,a.startStubY,a.endStubX,a.endStubY]},e={perpendicular:d,orthogonal:d,opposite:function(b){var c=a,d="x"===b?0:1,e={x:function(){return 1===c.so[d]&&(c.startStubX>c.endStubX&&c.tx>c.startStubX||c.sx>c.endStubX&&c.tx>c.sx)||-1===c.so[d]&&(c.startStubXc.endStubY&&c.ty>c.startStubY||c.sy>c.endStubY&&c.ty>c.sy)||-1===c.so[d]&&(c.startStubYj[b][0],p=e[b][m][0],q=e[b][m][1],r=d[b][m][n];return c.segment===r[3]||c.segment===r[2]&&o?f[b]:c.segment===r[2]&&p>q?g[b]:c.segment===r[2]&&q>=p||c.segment===r[1]&&!o?i[b]:c.segment===r[0]||c.segment===r[1]&&o?h[b]:void 0},orthogonal:function(b,c,d,e,f){var g=a,h={x:-1===g.so[0]?Math.min(c,e):Math.max(c,e),y:-1===g.so[1]?Math.min(c,e):Math.max(c,e)}[b];return{x:[[h,d],[h,f],[e,f]],y:[[d,h],[f,h],[f,e]]}[b]},opposite:function(c,d,e,f){var h=a,i={x:"y",y:"x"}[c],j={x:"height",y:"width"}[c],k=h["is"+c.toUpperCase()+"GreaterThanStubTimes2"];if(b.sourceEndpoint.elementId===b.targetEndpoint.elementId){var l=e+(1-b.sourceEndpoint.anchor[i])*b.sourceInfo[j]+g.maxStub;return{x:[[d,l],[f,l]],y:[[l,d],[l,f]]}[c]}return!k||1===h.so[m]&&d>f||-1===h.so[m]&&f>d?{x:[[d,v],[f,v]],y:[[u,d],[u,f]]}[c]:1===h.so[m]&&f>d||-1===h.so[m]&&d>f?{x:[[u,h.sy],[u,h.ty]],y:[[h.sx,v],[h.tx,v]]}[c]:void 0}},y=x[a.anchorOrientation](a.sourceAxis,p,q,s,t);if(y)for(var z=0;z=a&&b>=d?1:c>=a&&d>=b?2:a>=c&&d>=b?3:4},e=function(a,b,c,d,e,f,g,h,i){return i>=h?[a,b]:1===c?d[3]<=0&&e[3]>=1?[a+(d[2]<.5?-1*f:f),b]:d[2]>=1&&e[2]<=0?[a,b+(d[3]<.5?-1*g:g)]:[a+-1*f,b+-1*g]:2===c?d[3]>=1&&e[3]<=0?[a+(d[2]<.5?-1*f:f),b]:d[2]>=1&&e[2]<=0?[a,b+(d[3]<.5?-1*g:g)]:[a+f,b+-1*g]:3===c?d[3]>=1&&e[3]<=0?[a+(d[2]<.5?-1*f:f),b]:d[2]<=0&&e[2]>=1?[a,b+(d[3]<.5?-1*g:g)]:[a+-1*f,b+-1*g]:4===c?d[3]<=0&&e[3]>=1?[a+(d[2]<.5?-1*f:f),b]:d[2]<=0&&e[2]>=1?[a,b+(d[3]<.5?-1*g:g)]:[a+f,b+-1*g]:void 0},f=function(a){a=a||{},this.type="StateMachine";var c,f=b.Connectors.AbstractBezierConnector.apply(this,arguments),g=a.curviness||10,h=a.margin||5,i=a.proximityLimit||80;a.orientation&&"clockwise"===a.orientation;this._computeBezier=function(a,b,j,k,l,m){var n=b.sourcePos[0]c?a.insertBefore(b,a.childNodes[c]):a.appendChild(b)};c.svg={node:t,attr:s,pos:u};var z=function(a){var d=a.pointerEventsSpec||"all",e={};b.jsPlumbUIComponent.apply(this,a.originalArgs),this.canvas=null,this.path=null,this.svg=null,this.bgCanvas=null;var f=a.cssClass+" "+(a.originalArgs[0].cssClass||""),g={style:"",width:0,height:0,"pointer-events":d,position:"absolute"};this.svg=t("svg",g),a.useDivWrapper?(this.canvas=b.createElement("div",{position:"absolute"}),c.sizeElement(this.canvas,0,0,1,1),this.canvas.className=f):(s(this.svg,{"class":f}),this.canvas=this.svg),a._jsPlumb.appendElement(this.canvas,a.originalArgs[0].parent),a.useDivWrapper&&this.canvas.appendChild(this.svg);var h=[this.canvas];return this.getDisplayElements=function(){return h},this.appendDisplayElement=function(a){h.push(a)},this.paint=function(b,d,f){if(null!=b){var g,h=[this.x,this.y],i=[this.w,this.h];null!=f&&(f.xmin<0&&(h[0]+=f.xmin),f.ymin<0&&(h[1]+=f.ymin),i[0]=f.xmax+(f.xmin<0?-f.xmin:0),i[1]=f.ymax+(f.ymin<0?-f.ymin:0)),a.useDivWrapper?(c.sizeElement(this.canvas,h[0],h[1],i[0],i[1]),h[0]=0,h[1]=0,g=u([0,0])):g=u([h[0],h[1]]),e.paint.apply(this,arguments),s(this.svg,{style:g,width:i[0]||0,height:i[1]||0})}},{renderer:e}};c.extend(z,b.jsPlumbUIComponent,{cleanup:function(a){a||null==this.typeId?(this.canvas&&(this.canvas._jsPlumb=null),this.svg&&(this.svg._jsPlumb=null),this.bgCanvas&&(this.bgCanvas._jsPlumb=null),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.bgCanvas&&this.bgCanvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.svg=null,this.canvas=null,this.path=null,this.group=null):(this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.bgCanvas&&this.bgCanvas.parentNode&&this.bgCanvas.parentNode.removeChild(this.bgCanvas))},reattach:function(a){var b=a.getContainer();this.canvas&&null==this.canvas.parentNode&&b.appendChild(this.canvas),this.bgCanvas&&null==this.bgCanvas.parentNode&&b.appendChild(this.bgCanvas)},setVisible:function(a){this.canvas&&(this.canvas.style.display=a?"block":"none")}}),b.ConnectorRenderers.svg=function(a){var c=this,d=z.apply(this,[{cssClass:a._jsPlumb.connectorClass,originalArgs:arguments,pointerEventsSpec:"none",_jsPlumb:a._jsPlumb}]);d.renderer.paint=function(d,e,f){var g=c.getSegments(),h="",i=[0,0];if(f.xmin<0&&(i[0]=-f.xmin),f.ymin<0&&(i[1]=-f.ymin),g.length>0){h=c.getPathData();var j={d:h,transform:"translate("+i[0]+","+i[1]+")","pointer-events":a["pointer-events"]||"visibleStroke"},k=null,l=[c.x,c.y,c.w,c.h];if(d.outlineStroke){var m=d.outlineWidth||1,n=d.strokeWidth+2*m;k=b.extend({},d),delete k.gradient,k.stroke=d.outlineStroke,k.strokeWidth=n,null==c.bgPath?(c.bgPath=t("path",j),b.addClass(c.bgPath,b.connectorOutlineClass),y(c.svg,c.bgPath,0)):s(c.bgPath,j),x(c.svg,c.bgPath,k,l,c)}null==c.path?(c.path=t("path",j),y(c.svg,c.path,d.outlineStroke?1:0)):s(c.path,j),x(c.svg,c.path,d,l,c)}}},c.extend(b.ConnectorRenderers.svg,z);var A=b.SvgEndpoint=function(a){var c=z.apply(this,[{cssClass:a._jsPlumb.endpointClass,originalArgs:arguments,pointerEventsSpec:"all",useDivWrapper:!0,_jsPlumb:a._jsPlumb}]);c.renderer.paint=function(a){var c=b.extend({},a);c.outlineStroke&&(c.stroke=c.outlineStroke),null==this.node?(this.node=this.makeNode(c),this.svg.appendChild(this.node)):null!=this.updateNode&&this.updateNode(this.node),x(this.svg,this.node,c,[this.x,this.y,this.w,this.h],this),u(this.node,[this.x,this.y])}.bind(this)};c.extend(A,z),b.Endpoints.svg.Dot=function(){b.Endpoints.Dot.apply(this,arguments),A.apply(this,arguments),this.makeNode=function(a){return t("circle",{cx:this.w/2,cy:this.h/2,r:this.radius})},this.updateNode=function(a){s(a,{cx:this.w/2,cy:this.h/2,r:this.radius})}},c.extend(b.Endpoints.svg.Dot,[b.Endpoints.Dot,A]),b.Endpoints.svg.Rectangle=function(){b.Endpoints.Rectangle.apply(this,arguments),A.apply(this,arguments),this.makeNode=function(a){return t("rect",{width:this.w,height:this.h})},this.updateNode=function(a){s(a,{width:this.w,height:this.h})}},c.extend(b.Endpoints.svg.Rectangle,[b.Endpoints.Rectangle,A]),b.Endpoints.svg.Image=b.Endpoints.Image,b.Endpoints.svg.Blank=b.Endpoints.Blank,b.Overlays.svg.Label=b.Overlays.Label,b.Overlays.svg.Custom=b.Overlays.Custom;var B=function(a,c){a.apply(this,c),b.jsPlumbUIComponent.apply(this,c),this.isAppendedAtTopLevel=!1;this.path=null,this.paint=function(a,b){if(a.component.svg&&b){null==this.path&&(this.path=t("path",{"pointer-events":"all"}),a.component.svg.appendChild(this.path),this.elementCreated&&this.elementCreated(this.path,a.component),this.canvas=a.component.svg); +var e=c&&1===c.length?c[0].cssClass||"":"",f=[0,0];b.xmin<0&&(f[0]=-b.xmin),b.ymin<0&&(f[1]=-b.ymin),s(this.path,{d:d(a.d),"class":e,stroke:a.stroke?a.stroke:null,fill:a.fill?a.fill:null,transform:"translate("+f[0]+","+f[1]+")"})}};var d=function(a){return isNaN(a.cxy.x)||isNaN(a.cxy.y)?"":"M"+a.hxy.x+","+a.hxy.y+" L"+a.tail[0].x+","+a.tail[0].y+" L"+a.cxy.x+","+a.cxy.y+" L"+a.tail[1].x+","+a.tail[1].y+" L"+a.hxy.x+","+a.hxy.y};this.transfer=function(a){a.canvas&&this.path&&this.path.parentNode&&(this.path.parentNode.removeChild(this.path),a.canvas.appendChild(this.path))}};c.extend(B,[b.jsPlumbUIComponent,b.Overlays.AbstractOverlay],{cleanup:function(a){null!=this.path&&(a?this._jsPlumb.instance.removeElement(this.path):this.path.parentNode&&this.path.parentNode.removeChild(this.path))},reattach:function(a,b){this.path&&b.canvas&&b.canvas.appendChild(this.path)},setVisible:function(a){null!=this.path&&(this.path.style.display=a?"block":"none")}}),b.Overlays.svg.Arrow=function(){B.apply(this,[b.Overlays.Arrow,arguments])},c.extend(b.Overlays.svg.Arrow,[b.Overlays.Arrow,B]),b.Overlays.svg.PlainArrow=function(){B.apply(this,[b.Overlays.PlainArrow,arguments])},c.extend(b.Overlays.svg.PlainArrow,[b.Overlays.PlainArrow,B]),b.Overlays.svg.Diamond=function(){B.apply(this,[b.Overlays.Diamond,arguments])},c.extend(b.Overlays.svg.Diamond,[b.Overlays.Diamond,B]),b.Overlays.svg.GuideLines=function(){var a,c,d=null,e=this;b.Overlays.GuideLines.apply(this,arguments),this.paint=function(b,g){null==d&&(d=t("path"),b.connector.svg.appendChild(d),e.attachListeners(d,b.connector),e.attachListeners(d,e),a=t("path"),b.connector.svg.appendChild(a),e.attachListeners(a,b.connector),e.attachListeners(a,e),c=t("path"),b.connector.svg.appendChild(c),e.attachListeners(c,b.connector),e.attachListeners(c,e));var h=[0,0];g.xmin<0&&(h[0]=-g.xmin),g.ymin<0&&(h[1]=-g.ymin),s(d,{d:f(b.head,b.tail),stroke:"red",fill:null,transform:"translate("+h[0]+","+h[1]+")"}),s(a,{d:f(b.tailLine[0],b.tailLine[1]),stroke:"blue",fill:null,transform:"translate("+h[0]+","+h[1]+")"}),s(c,{d:f(b.headLine[0],b.headLine[1]),stroke:"green",fill:null,transform:"translate("+h[0]+","+h[1]+")"})};var f=function(a,b){return"M "+a.x+","+a.y+" L"+b.x+","+b.y}},c.extend(b.Overlays.svg.GuideLines,b.Overlays.GuideLines)}.call("undefined"!=typeof window?window:this),function(){"use strict";var a=this,b=a.jsPlumb,c=a.jsPlumbUtil,d=a.Katavorio,e=a.Biltong,f=function(a,c){c=c||"main";var f="_katavorio_"+c,g=a[f],h=a.getEventManager();return g||(g=new d({bind:h.on,unbind:h.off,getSize:b.getSize,getConstrainingRectangle:function(a){return[a.parentNode.scrollWidth,a.parentNode.scrollHeight]},getPosition:function(b,c){var d=a.getOffset(b,c,b._katavorioDrag?b.offsetParent:null);return[d.left,d.top]},setPosition:function(a,b){a.style.left=b[0]+"px",a.style.top=b[1]+"px"},addClass:b.addClass,removeClass:b.removeClass,intersects:e.intersects,indexOf:function(a,b){return a.indexOf(b)},scope:a.getDefaultScope(),css:{noSelect:a.dragSelectClass,droppable:"jtk-droppable",draggable:"jtk-draggable",drag:"jtk-drag",selected:"jtk-drag-selected",active:"jtk-drag-active",hover:"jtk-drag-hover",ghostProxy:"jtk-ghost-proxy"}}),g.setZoom(a.getZoom()),a[f]=g,a.bind("zoom",g.setZoom)),g},g=function(a,b){var d=function(d){if(null!=b[d]){if(c.isString(b[d])){var e=b[d].match(/-=/)?-1:1,f=b[d].substring(2);return a[d]+e*f}return b[d]}return a[d]};return[d("left"),d("top")]};b.extend(a.jsPlumbInstance.prototype,{animationSupported:!0,getElement:function(a){return null==a?null:(a="string"==typeof a?a:null!=a.length&&null==a.enctype?a[0]:a,"string"==typeof a?document.getElementById(a):a)},removeElement:function(a){f(this).elementRemoved(a),this.getEventManager().remove(a)},doAnimate:function(a,c,d){d=d||{};var e=this.getOffset(a),f=g(e,c),h=f[0]-e.left,i=f[1]-e.top,j=d.duration||250,k=15,l=j/k,m=k/j*h,n=k/j*i,o=0,p=setInterval(function(){b.setPosition(a,{left:e.left+m*(o+1),top:e.top+n*(o+1)}),null!=d.step&&d.step(o,Math.ceil(l)),o++,o>=l&&(window.clearInterval(p),null!=d.complete&&d.complete())},k)},destroyDraggable:function(a,b){f(this,b).destroyDraggable(a)},unbindDraggable:function(a,b,c,d){f(this,d).destroyDraggable(a,b,c)},destroyDroppable:function(a,b){f(this,b).destroyDroppable(a)},unbindDroppable:function(a,b,c,d){f(this,d).destroyDroppable(a,b,c)},initDraggable:function(a,b,c){f(this,c).draggable(a,b)},initDroppable:function(a,b,c){f(this,c).droppable(a,b)},isAlreadyDraggable:function(a){return null!=a._katavorioDrag},isDragSupported:function(a,b){return!0},isDropSupported:function(a,b){return!0},isElementDraggable:function(a){return a=b.getElement(a),a._katavorioDrag&&a._katavorioDrag.isEnabled()},getDragObject:function(a){return a[0].drag.getDragElement()},getDragScope:function(a){return a._katavorioDrag&&a._katavorioDrag.scopes.join(" ")||""},getDropEvent:function(a){return a[0].e},getUIPosition:function(a,b){var c=a[0].el;if(null==c.offsetParent)return null;var d=a[0].finalPos||a[0].pos,e={left:d[0],top:d[1]};if(c._katavorioDrag&&c.offsetParent!==this.getContainer()){var f=this.getOffset(c.offsetParent);e.left+=f.left,e.top+=f.top}return e},setDragFilter:function(a,b,c){a._katavorioDrag&&a._katavorioDrag.setFilter(b,c)},setElementDraggable:function(a,c){a=b.getElement(a),a._katavorioDrag&&a._katavorioDrag.setEnabled(c)},setDragScope:function(a,b){a._katavorioDrag&&a._katavorioDrag.k.setDragScope(a,b)},setDropScope:function(a,b){a._katavorioDrop&&a._katavorioDrop.length>0&&a._katavorioDrop[0].k.setDropScope(a,b)},addToPosse:function(a,c){var d=Array.prototype.slice.call(arguments,1),e=f(this);b.each(a,function(a){a=[b.getElement(a)],a.push.apply(a,d),e.addToPosse.apply(e,a)})},setPosse:function(a,c){var d=Array.prototype.slice.call(arguments,1),e=f(this);b.each(a,function(a){a=[b.getElement(a)],a.push.apply(a,d),e.setPosse.apply(e,a)})},removeFromPosse:function(a,c){var d=Array.prototype.slice.call(arguments,1),e=f(this);b.each(a,function(a){a=[b.getElement(a)],a.push.apply(a,d),e.removeFromPosse.apply(e,a)})},removeFromAllPosses:function(a){var c=f(this);b.each(a,function(a){c.removeFromAllPosses(b.getElement(a))})},setPosseState:function(a,c,d){var e=f(this);b.each(a,function(a){e.setPosseState(b.getElement(a),c,d)})},dragEvents:{start:"start",stop:"stop",drag:"drag",step:"step",over:"over",out:"out",drop:"drop",complete:"complete",beforeStart:"beforeStart"},animEvents:{step:"step",complete:"complete"},stopDrag:function(a){a._katavorioDrag&&a._katavorioDrag.abort()},addToDragSelection:function(a){f(this).select(a)},removeFromDragSelection:function(a){f(this).deselect(a)},clearDragSelection:function(){f(this).deselectAll()},trigger:function(a,b,c,d){this.getEventManager().trigger(a,b,c,d)},doReset:function(){for(var a in this)0===a.indexOf("_katavorio_")&&this[a].reset()}});var h=function(a){var b=function(){/complete|loaded|interactive/.test(document.readyState)&&"undefined"!=typeof document.body&&null!=document.body?a():setTimeout(b,9)};b()};h(b.init)}.call("undefined"!=typeof window?window:this); /*! * System Runtime * @@ -909,4 +913,4 @@ b.Overlays.svg.Diamond=function(){B.apply(this,[b.Overlays.Diamond,arguments])}, * See the License for the specific language governing permissions and * limitations under the License. */ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).runtime=e()}}(function(){var define,module,exports;return function o(i,s,d){function c(t,e){if(!s[t]){if(!i[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(l)return l(t,!0);var r=new Error("Cannot find module '"+t+"'");throw r.code="MODULE_NOT_FOUND",r}var a=s[t]={exports:{}};i[t][0].call(a.exports,function(e){return c(i[t][1][e]||e)},a,a.exports,o,i,s,d)}return s[t].exports}for(var l="function"==typeof require&&require,e=0;e"),(-1!==(s=(s=t.substring(0,a)).replace("=>","")).indexOf("(")?s.split("(")[1].replace(")","").trim():s.trim()).split(",").forEach(function(e){o.push(e.trim())}),0===(i=t.substring(a+2,t.length).trim()).indexOf("{")&&(i=i.substring(1,i.lastIndexOf("}")).trim()),-1===i.indexOf("\n")&&(c=!0),d&&c&&-1===i.indexOf("return ")&&(i="return "+i)):(a=t.indexOf("{"),(s=t.substring(0,a)).split("(")[1].replace(")","").trim().split(",").forEach(function(e){o.push(e.trim())}),i=(i=t.substring(a+1)).substring(0,i.lastIndexOf("}")).trim()),i=i.replace(/_this/g,"this"),""===o[0]&&(o=[]),r&&(o.push("$component"),o.push("$db"),o.push("$metamodel"),o.push("$workflow"),o.push("$behavior"),o.push("$state"),o.push("$log"),o.push("$helper")),m.isOnNode()&&o.push("require"),""!==o[0]?new Function("__action","return function "+l+" ("+o.join(", ")+") { return new Function('"+o.join("', '")+"', __action).apply(this, arguments) };")(i):new Function("__action","return function "+l+" () { return new Function(__action).apply(this, arguments) };")(i)}n.add=function(e,t,n,r,a,o){var i=m.generateId(),s=n.toString();return void 0===a&&(a=!1),void 0===r&&(r=!1),n=l(t,s,0,r),c[i]=n,d._Behavior.insert({_id:i,component:e,state:t,action:s,useCoreAPI:r,core:a,context:o}),i},n.remove=function(e){(e=e||{}).behaviorId=e.behaviorId||"",e.componentId=e.componentId||"",e.state=e.state||"",e.componentId&&(e.behaviorId?(d._Behavior.remove({_id:e.behaviorId,component:e.componentId,state:e.state}),delete c[e.behaviorId]):(e.state?d._Behavior.remove({component:e.componentId,state:e.state}):d._Behavior.remove({component:e.componentId})).forEach(function(e){delete c[e]}))},n.removeFromMemory=function(e){delete c[e]},n.getActions=function(e,t){var n=[],r=null;return d._Behavior.find({component:e,state:t}).forEach(function(e){void 0===(r=c[e[a.ID]])&&(r=l(e.state,e.action,e.core,e.useCoreAPI),c[e[a.ID]]=r),n.push({useCoreAPI:e.useCoreAPI,context:e.context,action:r})}),n},n.clear=function(){c={}},n.get=function(e){return c[e]}},{"./db.js":4,"./helper.js":5,"./mson.js":8}],3:[function(e,t,g){"use strict";var v=e("./workflow.js"),b=e("./db.js"),_=e("./metamodel.js"),O=e("./behavior.js"),I=e("./helper.js"),k=e("./log.js"),c=e("./state.js"),l=e("./mson.js"),h={};function S(a){var s,d,c,l,m,r=[],u=[],p=!1;function y(){var t=0,e=0,n=r.length;for(u.forEach(function(e){r[t]=m?I.getRuntime().require(e):e,t+=1}),e=t;et[r]?1===n[r]?1:-1:0})),t},e}function d(e,t,n){var r=!0,a="";e:for(a in t)switch(!0){case"$eq"===a:if(t[a]instanceof RegExp){if(null===n[e].toString().match(t[a])){r=!1;break e}}else if(n[e]!==t[a]){r=!1;break e}break;case"$gt"===a:if(n[e]<=t[a]){r=!1;break e}break;case"$gte"===a:if(n[e]=t[a]){r=!1;break e}break;case"$lte"===a:if(n[e]>t[a]){r=!1;break e}break;case"$ne"===a:if(n[e]===t[a]){r=!1;break e}break;case"$in"===a:if(Array.isArray(t[a])&&-1===t[a].indexOf(n[e])){r=!1;break e}break;case"$nin"===a:if(Array.isArray(t[a])&&-1!==t[a].indexOf(n[e])){r=!1;break e}}return r}function c(e,t){var n=!0,r=!1,a="",o=0,i=0;e:for(a in e){if(void 0===t[a]){n=!1;break}switch(!0){case e[a]instanceof RegExp:if(Array.isArray(t[a])&&!Array.isArray(e[a])){for(i=t[a].length,o=0;o"===e:break;case"string"==typeof t&&"boolean"===t:r=n?{name:e,type:"boolean",mandatory:!1,default:!1}:{type:"boolean",readOnly:!1,mandatory:!1,default:!1};break;case"string"==typeof t&&"string"===t:r=n?{name:e,type:"string",mandatory:!1,default:""}:{type:"string",readOnly:!1,mandatory:!1,default:""};break;case"string"==typeof t&&"number"===t:r=n?{name:e,type:"number",mandatory:!1,default:0}:{type:"number",readOnly:!1,mandatory:!1,default:0};break;case"string"==typeof t&&"object"===t:r=n?{name:e,type:"object",mandatory:!1,default:{}}:{type:"object",readOnly:!1,mandatory:!1,default:{}};break;case"string"==typeof t&&"array"===t:r=n?{name:e,type:"array",mandatory:!1,default:[]}:{type:"array",readOnly:!1,mandatory:!1,default:[]};break;case"string"==typeof t&&"date"===t:r=n?{name:e,type:"date",mandatory:!1,default:"1970-01-01T00:00:00.000Z"}:{type:"date",readOnly:!1,mandatory:!1,default:"1970-01-01T00:00:00.000Z"};break;case"string"==typeof t&&"any"===t:r=n?{name:e,type:"any",mandatory:!1,default:null}:{type:"any",readOnly:!1,mandatory:!1,default:""};break;case"string"==typeof t:o={},(a=h._Type.find({name:t})).length&&a[0].value&&(o=a[0].value[0]),h._Schema.find({_name:t}).length&&(o=""),r=n?{name:e,type:t,mandatory:!1,default:o}:{type:t,readOnly:!1,mandatory:!1,default:o};break;case"array"==typeof t&&"boolean"==typeof t[0]:r=n?{name:e,type:["boolean"],mandatory:!1,default:[]}:{type:["boolean"],readOnly:!1,mandatory:!1,default:[]};break;case"array"==typeof t&&"string"==typeof t[0]:r=n?{name:e,type:["string"],mandatory:!1,default:""}:{type:["string"],readOnly:!1,mandatory:!1,default:""};break;case"array"==typeof t&&"number"==typeof t[0]:r=n?{name:e,type:["number"],mandatory:!1,default:[]}:{type:["number"],readOnly:!1,mandatory:!1,default:[]};break;case"array"==typeof t&&"object"==typeof t[0]:r=n?{name:e,type:["object"],mandatory:!1,default:[]}:{type:["object"],readOnly:!1,mandatory:!1,default:[]};break;case"array"==typeof t&&"date"==typeof t[0]:r=n?{name:e,type:["date"],mandatory:!1,default:[]}:{type:["date"],readOnly:!1,mandatory:!1,default:[]};break;case"array"==typeof t&&"any"==typeof t[0]:r=n?{name:e,type:["any"],mandatory:!1,default:[]}:{type:["any"],readOnly:!1,mandatory:!1,default:[]};break;case"array"==typeof t:r=n?{name:e,type:t,mandatory:!1,default:[]}:{type:t,readOnly:!1,mandatory:!1,default:[]}}return r}function m(e){var t="",n="",r={};for(t in e=JSON.parse(JSON.stringify(e)))if(e.hasOwnProperty(t)&&0!==t.indexOf("_"))switch(!0){case"string"==typeof e[t]:e[t]=l(t,e[t],!1);break;case"object"==typeof e[t]&&void 0===e[t]["=>"]:e[t]=C(e[t],l(t,e[t].type||"any",!1));break;case"object"==typeof e[t]&&void 0!==e[t]["=>"]:for(n in r={params:[],result:"any"},e[t])"string"==typeof e[t][n]&&("=>"===n?r.result=e[t][n]:r.params.push(l(n,e[t][n],!0))),"object"==typeof e[t][n]&&r.params.push(C(e[t][n]),l(n,e[t][n].type||"any",!0));e[t]=r}return e}g.schema=function(e,t){var n,r,a,o=null,i="",s={},d=[];return void 0===t||0===Object.keys(t).length?"string"==typeof e?(t={},i=t[_.NAME]=e):(t=JSON.parse(JSON.stringify(e)),i=t[_.NAME]):(t=JSON.parse(JSON.stringify(t)),t[_.NAME]=e,i=t[_.NAME]),void 0===t[_.ID]&&(t[_.ID]=c.generateId()),void 0===t[_.INHERIT]&&(t[_.INHERIT]=["_Component"]),t[_.INHERIT]=(n=t[_.INHERIT],r=[],a={},n.forEach(function(e){var t=e.trim();void 0===a[t]&&(a[t]=t,r.push(t))}),r),g.isValidObject(t,_.SCHEMA_DEFINITION,!1)?(d=h._Schema.find({_name:i})).length?(s=C(t,d[0]),h._Schema.update({_name:i},s),o=d[0][_.ID]):o=h._Schema.insert(t)[0]:v.invalidSchema(t[_.NAME]),o},g.model=function(e,t){var n=null,r="",a={},o=[];return void 0===t||0===Object.keys(t).length?t=JSON.parse(JSON.stringify(e)):(t=JSON.parse(JSON.stringify(t)),t[_.NAME]=e,t=m(t)),r=t[_.NAME],void 0===t[_.ID]&&(t[_.ID]=c.generateId()),g.isValidObject(t,_.MODEL_DEFINITION,!1)?(o=h._Model.find({_name:r})).length?(a=C(t,o[0]),h._Model.update({_name:r},a),n=o[0][_.ID]):n=h._Model.insert(t)[0]:v.invalidModel(t[_.NAME]),n},g.type=function(e,t){var n=null,r="",a={};return void 0===t||0===Object.keys(t).length?r=(a=JSON.parse(JSON.stringify(e))).name:(Array.isArray(t)?(t=JSON.parse(JSON.stringify(t)),a.value=t,a.name=e,a.type=typeof t[0]||"any"):(t=JSON.parse(JSON.stringify(t)),a.schema=m(t),a.name=e,a.type="object"),r=a.name),void 0===a[_.ID]&&(a[_.ID]=c.generateId()),g.isValidObject(a,_.TYPE_DEFINITION)?n=h._Type.insert(a)[0]:v.invalidTypeDefinition(r),n},g.init=function(){g.clear(),h.collection("_Logger"),h.collection("_Schema"),h.collection("_Model"),h.collection("_GeneratedModel"),h.collection("_ClassInfo"),h.collection("_Behavior"),h.collection("_State"),h.collection("_Type"),h.collection("_Message"),h.collection("_Channel"),h.collection("_Log")},g.clear=function(){O={inheritance:{},inheritanceTree:{},schemas:{},compiledSchemas:{},models:{},generatedModels:{},states:{},type:{}}},g.create=function(){v.modelCreationBegin(),function(){var e,t,n,r=null,a={},o=null,i="",s="",d=0,c=0;for(O.inheritance={},O.inheritanceTree={},O.schemas={},O.compiledSchemas={},O.models={},O.generatedModels={},O.states={},O.type={},c=(e=h._Schema.find({})).length,d=0;d","")).indexOf("(")?c.split("(")[1].replace(")","").trim():c.trim()).split(","))[0]&&(l=[]),a=l.length,o=g.isProperty(t,e),i=g.isLink(t,e),s=g.isCollection(t,e),!0){case s:m=[2,2];break;case o:m="array"===g.getModelPathType(e,t)?[2,2]:[1,1];break;case i:m=[1,1];break;default:m=k(e,t)}return m[0]<=a&&a<=m[1]&&(u=!0),u},h.checkInput=function(e){var t,n,r,a,o=(e=e||{}).component||null,i=e.methodName||"",s=e.args||"",d=[],c=[],l="",m=s.length,u=0,p=null,y=!0;switch(l="Function"===o.constructor.name?o.name:o.constructor.name,n=g.isProperty(i,l),r=g.isLink(i,l),a=g.isCollection(i,l),t=function(e,t){var n=null,r=[],a=[],o=0,i=0;if(g.getModel(e)?n=g.getModel(e)[t]:O.unknownModel(e),n){if(r=n.params)for(o=r.length,i=0;i"),(-1!==(s=(s=t.substring(0,a)).replace("=>","")).indexOf("(")?s.split("(")[1].replace(")","").trim():s.trim()).split(",").forEach(function(e){o.push(e.trim())}),0===(i=t.substring(a+2,t.length).trim()).indexOf("{")&&(i=i.substring(1,i.lastIndexOf("}")).trim()),-1===i.indexOf("\n")&&(c=!0),d&&c&&-1===i.indexOf("return ")&&(i="return "+i)):(a=t.indexOf("{"),(s=t.substring(0,a)).split("(")[1].replace(")","").trim().split(",").forEach(function(e){o.push(e.trim())}),i=(i=t.substring(a+1)).substring(0,i.lastIndexOf("}")).trim()),i=i.replace(/_this/g,"this"),""===o[0]&&(o=[]),r&&(o.push("$component"),o.push("$db"),o.push("$metamodel"),o.push("$workflow"),o.push("$behavior"),o.push("$state"),o.push("$log"),o.push("$helper")),m.isOnNode()&&o.push("require"),""!==o[0]?new Function("__action","return function "+l+" ("+o.join(", ")+") { return new Function('"+o.join("', '")+"', __action).apply(this, arguments) };")(i):new Function("__action","return function "+l+" () { return new Function(__action).apply(this, arguments) };")(i)}n.add=function(e,t,n,r,a,o){var i=m.generateId(),s=n.toString();return void 0===a&&(a=!1),void 0===r&&(r=!1),n=l(t,s,0,r),c[i]=n,d._Behavior.insert({_id:i,component:e,state:t,action:s,useCoreAPI:r,core:a,context:o}),i},n.remove=function(e){(e=e||{}).behaviorId=e.behaviorId||"",e.componentId=e.componentId||"",e.state=e.state||"",e.componentId&&(e.behaviorId?(d._Behavior.remove({_id:e.behaviorId,component:e.componentId,state:e.state}),delete c[e.behaviorId]):(e.state?d._Behavior.remove({component:e.componentId,state:e.state}):d._Behavior.remove({component:e.componentId})).forEach(function(e){delete c[e]}))},n.removeFromMemory=function(e){delete c[e]},n.getActions=function(e,t){var n=[],r=null;return d._Behavior.find({component:e,state:t}).forEach(function(e){void 0===(r=c[e[a.ID]])&&(r=l(e.state,e.action,e.core,e.useCoreAPI),c[e[a.ID]]=r),n.push({useCoreAPI:e.useCoreAPI,context:e.context,action:r})}),n},n.clear=function(){c={}},n.get=function(e){return c[e]}},{"./db.js":4,"./helper.js":5,"./mson.js":8}],3:[function(e,t,g){"use strict";var v=e("./workflow.js"),b=e("./db.js"),_=e("./metamodel.js"),O=e("./behavior.js"),I=e("./helper.js"),k=e("./log.js"),c=e("./state.js"),l=e("./mson.js"),h={};function S(a){var s,d,c,l,m,r=[],u=[],p=!1;function y(){var t=0,e=0,n=r.length;for(u.forEach(function(e){r[t]=m?I.getRuntime().require(e):e,t+=1}),e=t;et[r]?1===n[r]?1:-1:0})),t},e}function d(e,t,n){var r=!0,a="";e:for(a in t)switch(!0){case"$eq"===a:if(t[a]instanceof RegExp){if(null===n[e].toString().match(t[a])){r=!1;break e}}else if(n[e]!==t[a]){r=!1;break e}break;case"$gt"===a:if(n[e]<=t[a]){r=!1;break e}break;case"$gte"===a:if(n[e]=t[a]){r=!1;break e}break;case"$lte"===a:if(n[e]>t[a]){r=!1;break e}break;case"$ne"===a:if(n[e]===t[a]){r=!1;break e}break;case"$in"===a:if(Array.isArray(t[a])&&-1===t[a].indexOf(n[e])){r=!1;break e}break;case"$nin"===a:if(Array.isArray(t[a])&&-1!==t[a].indexOf(n[e])){r=!1;break e}}return r}function c(e,t){var n=!0,r=!1,a="",o=0,i=0;e:for(a in e){if(void 0===t[a]){n=!1;break}switch(!0){case e[a]instanceof RegExp:if(Array.isArray(t[a])&&!Array.isArray(e[a])){for(i=t[a].length,o=0;o"===e:break;case"string"==typeof t&&"boolean"===t:r=n?{name:e,type:"boolean",mandatory:!1,default:!1}:{type:"boolean",readOnly:!1,mandatory:!1,default:!1};break;case"string"==typeof t&&"string"===t:r=n?{name:e,type:"string",mandatory:!1,default:""}:{type:"string",readOnly:!1,mandatory:!1,default:""};break;case"string"==typeof t&&"number"===t:r=n?{name:e,type:"number",mandatory:!1,default:0}:{type:"number",readOnly:!1,mandatory:!1,default:0};break;case"string"==typeof t&&"object"===t:r=n?{name:e,type:"object",mandatory:!1,default:{}}:{type:"object",readOnly:!1,mandatory:!1,default:{}};break;case"string"==typeof t&&"array"===t:r=n?{name:e,type:"array",mandatory:!1,default:[]}:{type:"array",readOnly:!1,mandatory:!1,default:[]};break;case"string"==typeof t&&"date"===t:r=n?{name:e,type:"date",mandatory:!1,default:"1970-01-01T00:00:00.000Z"}:{type:"date",readOnly:!1,mandatory:!1,default:"1970-01-01T00:00:00.000Z"};break;case"string"==typeof t&&"any"===t:r=n?{name:e,type:"any",mandatory:!1,default:null}:{type:"any",readOnly:!1,mandatory:!1,default:""};break;case"string"==typeof t:o={},(a=h._Type.find({name:t})).length&&a[0].value&&(o=a[0].value[0]),h._Schema.find({_name:t}).length&&(o=""),r=n?{name:e,type:t,mandatory:!1,default:o}:{type:t,readOnly:!1,mandatory:!1,default:o};break;case"array"==typeof t&&"boolean"==typeof t[0]:r=n?{name:e,type:["boolean"],mandatory:!1,default:[]}:{type:["boolean"],readOnly:!1,mandatory:!1,default:[]};break;case"array"==typeof t&&"string"==typeof t[0]:r=n?{name:e,type:["string"],mandatory:!1,default:""}:{type:["string"],readOnly:!1,mandatory:!1,default:""};break;case"array"==typeof t&&"number"==typeof t[0]:r=n?{name:e,type:["number"],mandatory:!1,default:[]}:{type:["number"],readOnly:!1,mandatory:!1,default:[]};break;case"array"==typeof t&&"object"==typeof t[0]:r=n?{name:e,type:["object"],mandatory:!1,default:[]}:{type:["object"],readOnly:!1,mandatory:!1,default:[]};break;case"array"==typeof t&&"date"==typeof t[0]:r=n?{name:e,type:["date"],mandatory:!1,default:[]}:{type:["date"],readOnly:!1,mandatory:!1,default:[]};break;case"array"==typeof t&&"any"==typeof t[0]:r=n?{name:e,type:["any"],mandatory:!1,default:[]}:{type:["any"],readOnly:!1,mandatory:!1,default:[]};break;case"array"==typeof t:r=n?{name:e,type:t,mandatory:!1,default:[]}:{type:t,readOnly:!1,mandatory:!1,default:[]}}return r}function m(e){var t="",n="",r={};for(t in e=JSON.parse(JSON.stringify(e)))if(e.hasOwnProperty(t)&&0!==t.indexOf("_"))switch(!0){case"string"==typeof e[t]:e[t]=l(t,e[t],!1);break;case"object"==typeof e[t]&&void 0===e[t]["=>"]:e[t]=C(e[t],l(t,e[t].type||"any",!1));break;case"object"==typeof e[t]&&void 0!==e[t]["=>"]:for(n in r={params:[],result:"any"},e[t])"string"==typeof e[t][n]&&("=>"===n?r.result=e[t][n]:r.params.push(l(n,e[t][n],!0))),"object"==typeof e[t][n]&&r.params.push(C(e[t][n]),l(n,e[t][n].type||"any",!0));e[t]=r}return e}g.schema=function(e,t){var n,r,a,o=null,i="",s={},d=[];return void 0===t||0===Object.keys(t).length?"string"==typeof e?(t={},i=t[_.NAME]=e):(t=JSON.parse(JSON.stringify(e)),i=t[_.NAME]):(t=JSON.parse(JSON.stringify(t)),t[_.NAME]=e,i=t[_.NAME]),void 0===t[_.ID]&&(t[_.ID]=c.generateId()),void 0===t[_.INHERIT]&&(t[_.INHERIT]=["_Component"]),t[_.INHERIT]=(n=t[_.INHERIT],r=[],a={},n.forEach(function(e){var t=e.trim();void 0===a[t]&&(a[t]=t,r.push(t))}),r),g.isValidObject(t,_.SCHEMA_DEFINITION,!1)?(d=h._Schema.find({_name:i})).length?(s=C(t,d[0]),h._Schema.update({_name:i},s),o=d[0][_.ID]):o=h._Schema.insert(t)[0]:v.invalidSchema(t[_.NAME]),o},g.model=function(e,t){var n=null,r="",a={},o=[];return void 0===t||0===Object.keys(t).length?t=JSON.parse(JSON.stringify(e)):(t=JSON.parse(JSON.stringify(t)),t[_.NAME]=e,t=m(t)),r=t[_.NAME],void 0===t[_.ID]&&(t[_.ID]=c.generateId()),g.isValidObject(t,_.MODEL_DEFINITION,!1)?(o=h._Model.find({_name:r})).length?(a=C(t,o[0]),h._Model.update({_name:r},a),n=o[0][_.ID]):n=h._Model.insert(t)[0]:v.invalidModel(t[_.NAME]),n},g.type=function(e,t){var n=null,r="",a={};return void 0===t||0===Object.keys(t).length?r=(a=JSON.parse(JSON.stringify(e))).name:(Array.isArray(t)?(t=JSON.parse(JSON.stringify(t)),a.value=t,a.name=e,a.type=typeof t[0]||"any"):(t=JSON.parse(JSON.stringify(t)),a.schema=m(t),a.name=e,a.type="object"),r=a.name),void 0===a[_.ID]&&(a[_.ID]=c.generateId()),g.isValidObject(a,_.TYPE_DEFINITION)?n=h._Type.insert(a)[0]:v.invalidTypeDefinition(r),n},g.init=function(){g.clear(),h.collection("_Logger"),h.collection("_Schema"),h.collection("_Model"),h.collection("_GeneratedModel"),h.collection("_ClassInfo"),h.collection("_Behavior"),h.collection("_State"),h.collection("_Type"),h.collection("_Message"),h.collection("_Channel"),h.collection("_Log")},g.clear=function(){O={inheritance:{},inheritanceTree:{},schemas:{},compiledSchemas:{},models:{},generatedModels:{},states:{},type:{}}},g.create=function(){v.modelCreationBegin(),function(){var e,t,n,r=null,a={},o=null,i="",s="",d=0,c=0;for(O.inheritance={},O.inheritanceTree={},O.schemas={},O.compiledSchemas={},O.models={},O.generatedModels={},O.states={},O.type={},c=(e=h._Schema.find({})).length,d=0;d","")).indexOf("(")?c.split("(")[1].replace(")","").trim():c.trim()).split(","))[0]&&(l=[]),a=l.length,o=g.isProperty(t,e),i=g.isLink(t,e),s=g.isCollection(t,e),!0){case s:m=[2,2];break;case o:m="array"===g.getModelPathType(e,t)?[2,2]:[1,1];break;case i:m=[1,1];break;default:m=k(e,t)}return m[0]<=a&&a<=m[1]&&(u=!0),u},h.checkInput=function(e){var t,n,r,a,o=(e=e||{}).component||null,i=e.methodName||"",s=e.args||"",d=[],c=[],l="",m=s.length,u=0,p=null,y=!0;switch(l="Function"===o.constructor.name?o.name:o.constructor.name,n=g.isProperty(i,l),r=g.isLink(i,l),a=g.isCollection(i,l),t=function(e,t){var n=null,r=[],a=[],o=0,i=0;if(g.getModel(e)?n=g.getModel(e)[t]:O.unknownModel(e),n){if(r=n.params)for(o=r.length,i=0;i 1) { + return window.devicePixelRatio; + } else { + return 1; + } + } + + function svgXmlToImageElement(svgXml) { + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref$scale = _ref.scale, + scale = _ref$scale === undefined ? defaultScale() : _ref$scale, + _ref$mimeType = _ref.mimeType, + mimeType = _ref$mimeType === undefined ? "image/png" : _ref$mimeType, + _ref$quality = _ref.quality, + quality = _ref$quality === undefined ? 1 : _ref$quality; + + return new Promise(function (resolve, reject) { + var svgImage = new Image(); + + svgImage.onload = function () { + var canvas = document.createElement('canvas'); + canvas.width = svgImage.width * scale; + canvas.height = svgImage.height * scale; + + var context = canvas.getContext("2d"); + context.drawImage(svgImage, 0, 0, canvas.width, canvas.height); + + canvas.toBlob(function (blob) { + var image = new Image(); + image.src = URL.createObjectURL(blob); + image.width = svgImage.width; + image.height = svgImage.height; + + resolve(image); + }, mimeType, quality); + }; + + svgImage.onerror = function (e) { + var error; + + if ('error' in e) { + error = e.error; + } else { + error = new Error('Error loading SVG'); + } + + reject(error); + }; + + svgImage.src = 'data:image/svg+xml;base64,' + b64EncodeUnicode(svgXml); + }); + } + + function svgXmlToImageElementFabric(svgXml) { + var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref2$scale = _ref2.scale, + scale = _ref2$scale === undefined ? defaultScale() : _ref2$scale, + _ref2$mimeType = _ref2.mimeType, + mimeType = _ref2$mimeType === undefined ? 'image/png' : _ref2$mimeType, + _ref2$quality = _ref2.quality, + quality = _ref2$quality === undefined ? 1 : _ref2$quality; + + var multiplier = scale; + + var format = void 0; + if (mimeType == 'image/jpeg') { + format = 'jpeg'; + } else if (mimeType == 'image/png') { + format = 'png'; + } + + return new Promise(function (resolve, reject) { + fabric.loadSVGFromString(svgXml, function (objects, options) { + // If there's something wrong with the SVG, Fabric may return an empty array of objects. Graphviz appears to give us at least one element back even given an empty graph, so we will assume an error in this case. + if (objects.length == 0) { + reject(new Error('Error loading SVG with Fabric')); + } + + var element = document.createElement("canvas"); + element.width = options.width; + element.height = options.height; + + var canvas = new fabric.Canvas(element, { enableRetinaScaling: false }); + var obj = fabric.util.groupSVGElements(objects, options); + canvas.add(obj).renderAll(); + + var image = new Image(); + image.src = canvas.toDataURL({ format: format, multiplier: multiplier, quality: quality }); + image.width = options.width; + image.height = options.height; + + resolve(image); + }); + }); + } + + var Viz = function () { + function Viz() { + var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + workerURL = _ref3.workerURL, + worker = _ref3.worker, + Module = _ref3.Module, + render = _ref3.render; + + classCallCheck(this, Viz); + + if (typeof workerURL !== 'undefined') { + this.wrapper = new WorkerWrapper(new Worker(workerURL)); + } else if (typeof worker !== 'undefined') { + this.wrapper = new WorkerWrapper(worker); + } else if (typeof Module !== 'undefined' && typeof render !== 'undefined') { + this.wrapper = new ModuleWrapper(Module, render); + } else if (typeof Viz.Module !== 'undefined' && typeof Viz.render !== 'undefined') { + this.wrapper = new ModuleWrapper(Viz.Module, Viz.render); + } else { + throw new Error('Must specify workerURL or worker option, Module and render options, or include one of full.render.js or lite.render.js after viz.js.'); + } + } + + createClass(Viz, [{ + key: 'renderString', + value: function renderString(src) { + var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref4$format = _ref4.format, + format = _ref4$format === undefined ? 'svg' : _ref4$format, + _ref4$engine = _ref4.engine, + engine = _ref4$engine === undefined ? 'dot' : _ref4$engine, + _ref4$files = _ref4.files, + files = _ref4$files === undefined ? [] : _ref4$files, + _ref4$images = _ref4.images, + images = _ref4$images === undefined ? [] : _ref4$images, + _ref4$yInvert = _ref4.yInvert, + yInvert = _ref4$yInvert === undefined ? false : _ref4$yInvert; + + for (var i = 0; i < images.length; i++) { + files.push({ + path: images[i].path, + data: '\n\n' + }); + } + + return this.wrapper.render(src, { format: format, engine: engine, files: files, images: images, yInvert: yInvert }); + } + }, { + key: 'renderSVGElement', + value: function renderSVGElement(src) { + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + return this.renderString(src, _extends({}, options, { format: 'svg' })).then(function (str) { + var parser = new DOMParser(); + return parser.parseFromString(str, 'image/svg+xml').documentElement; + }); + } + }, { + key: 'renderImageElement', + value: function renderImageElement(src) { + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + var scale = options.scale, + mimeType = options.mimeType, + quality = options.quality; + + + return this.renderString(src, _extends({}, options, { format: 'svg' })).then(function (str) { + if ((typeof fabric === 'undefined' ? 'undefined' : _typeof(fabric)) === "object" && fabric.loadSVGFromString) { + return svgXmlToImageElementFabric(str, { scale: scale, mimeType: mimeType, quality: quality }); + } else { + return svgXmlToImageElement(str, { scale: scale, mimeType: mimeType, quality: quality }); + } + }); + } + }, { + key: 'renderJSONObject', + value: function renderJSONObject(src) { + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + var format = options.format; + + + if (format !== 'json' || format !== 'json0') { + format = 'json'; + } + + return this.renderString(src, _extends({}, options, { format: format })).then(function (str) { + return JSON.parse(str); + }); + } + }]); + return Viz; + }(); + + return Viz; + +}))); + +/* +Viz.js 2.0.0 (Graphviz 2.40.1, Emscripten 1.37.36) +*/ +(function(global) { +var Module = function(Module) { + Module = Module || {}; +var Module=typeof Module!=="undefined"?Module:{};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}Module["arguments"]=[];Module["thisProgram"]="./this.program";Module["quit"]=(function(status,toThrow){throw toThrow});Module["preRun"]=[];Module["postRun"]=[];var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;if(Module["ENVIRONMENT"]){if(Module["ENVIRONMENT"]==="WEB"){ENVIRONMENT_IS_WEB=true}else if(Module["ENVIRONMENT"]==="WORKER"){ENVIRONMENT_IS_WORKER=true}else if(Module["ENVIRONMENT"]==="NODE"){ENVIRONMENT_IS_NODE=true}else if(Module["ENVIRONMENT"]==="SHELL"){ENVIRONMENT_IS_SHELL=true}else{throw new Error("Module['ENVIRONMENT'] value is not valid. must be one of: WEB|WORKER|NODE|SHELL.")}}else{ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER}if(ENVIRONMENT_IS_NODE){var nodeFS;var nodePath;Module["read"]=function shell_read(filename,binary){var ret;ret=tryParseAsDataURI(filename);if(!ret){if(!nodeFS)nodeFS=require("fs");if(!nodePath)nodePath=require("path");filename=nodePath["normalize"](filename);ret=nodeFS["readFileSync"](filename)}return binary?ret:ret.toString()};Module["readBinary"]=function readBinary(filename){var ret=Module["read"](filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};if(process["argv"].length>1){Module["thisProgram"]=process["argv"][1].replace(/\\/g,"/")}Module["arguments"]=process["argv"].slice(2);if(typeof module!=="undefined"){module["exports"]=Module}process["on"]("uncaughtException",(function(ex){if(!(ex instanceof ExitStatus)){throw ex}}));process["on"]("unhandledRejection",(function(reason,p){process["exit"](1)}));Module["inspect"]=(function(){return"[Emscripten Module object]"})}else if(ENVIRONMENT_IS_SHELL){if(typeof read!="undefined"){Module["read"]=function shell_read(f){var data=tryParseAsDataURI(f);if(data){return intArrayToString(data)}return read(f)}}Module["readBinary"]=function readBinary(f){var data;data=tryParseAsDataURI(f);if(data){return data}if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){Module["arguments"]=scriptArgs}else if(typeof arguments!="undefined"){Module["arguments"]=arguments}if(typeof quit==="function"){Module["quit"]=(function(status,toThrow){quit(status)})}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){Module["read"]=function shell_read(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText}catch(err){var data=tryParseAsDataURI(url);if(data){return intArrayToString(data)}throw err}};if(ENVIRONMENT_IS_WORKER){Module["readBinary"]=function readBinary(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}catch(err){var data=tryParseAsDataURI(url);if(data){return data}throw err}}}Module["readAsync"]=function readAsync(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function xhr_onload(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}var data=tryParseAsDataURI(url);if(data){onload(data.buffer);return}onerror()};xhr.onerror=onerror;xhr.send(null)};if(typeof arguments!="undefined"){Module["arguments"]=arguments}Module["setWindowTitle"]=(function(title){document.title=title})}Module["print"]=typeof console!=="undefined"?console.log.bind(console):typeof print!=="undefined"?print:null;Module["printErr"]=typeof printErr!=="undefined"?printErr:typeof console!=="undefined"&&console.warn.bind(console)||Module["print"];Module.print=Module["print"];Module.printErr=Module["printErr"];for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=undefined;var STACK_ALIGN=16;function staticAlloc(size){assert(!staticSealed);var ret=STATICTOP;STATICTOP=STATICTOP+size+15&-16;return ret}function dynamicAlloc(size){assert(DYNAMICTOP_PTR);var ret=HEAP32[DYNAMICTOP_PTR>>2];var end=ret+size+15&-16;HEAP32[DYNAMICTOP_PTR>>2]=end;if(end>=TOTAL_MEMORY){var success=enlargeMemory();if(!success){HEAP32[DYNAMICTOP_PTR>>2]=ret;return 0}}return ret}function alignMemory(size,factor){if(!factor)factor=STACK_ALIGN;var ret=size=Math.ceil(size/factor)*factor;return ret}function getNativeTypeSize(type){switch(type){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:{if(type[type.length-1]==="*"){return 4}else if(type[0]==="i"){var bits=parseInt(type.substr(1));assert(bits%8===0);return bits/8}else{return 0}}}}function warnOnce(text){if(!warnOnce.shown)warnOnce.shown={};if(!warnOnce.shown[text]){warnOnce.shown[text]=1;Module.printErr(text)}}var jsCallStartIndex=1;var functionPointers=new Array(0);var funcWrappers={};function dynCall(sig,ptr,args){if(args&&args.length){return Module["dynCall_"+sig].apply(null,[ptr].concat(args))}else{return Module["dynCall_"+sig].call(null,ptr)}}var GLOBAL_BASE=8;var ABORT=0;var EXITSTATUS=0;function assert(condition,text){if(!condition){abort("Assertion failed: "+text)}}function getCFunc(ident){var func=Module["_"+ident];assert(func,"Cannot call unknown function "+ident+", make sure it is exported");return func}var JSfuncs={"stackSave":(function(){stackSave()}),"stackRestore":(function(){stackRestore()}),"arrayToC":(function(arr){var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}),"stringToC":(function(str){var ret=0;if(str!==null&&str!==undefined&&str!==0){var len=(str.length<<2)+1;ret=stackAlloc(len);stringToUTF8(str,ret,len)}return ret})};var toC={"string":JSfuncs["stringToC"],"array":JSfuncs["arrayToC"]};function ccall(ident,returnType,argTypes,args,opts){var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":tempI64=[value>>>0,(tempDouble=value,+Math_abs(tempDouble)>=+1?tempDouble>+0?(Math_min(+Math_floor(tempDouble/+4294967296),+4294967295)|0)>>>0:~~+Math_ceil((tempDouble- +(~~tempDouble>>>0))/+4294967296)>>>0:0)],HEAP32[ptr>>2]=tempI64[0],HEAP32[ptr+4>>2]=tempI64[1];break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;default:abort("invalid type for setValue: "+type)}}var ALLOC_STATIC=2;var ALLOC_NONE=4;function allocate(slab,types,allocator,ptr){var zeroinit,size;if(typeof slab==="number"){zeroinit=true;size=slab}else{zeroinit=false;size=slab.length}var singleType=typeof types==="string"?types:null;var ret;if(allocator==ALLOC_NONE){ret=ptr}else{ret=[typeof _malloc==="function"?_malloc:staticAlloc,stackAlloc,staticAlloc,dynamicAlloc][allocator===undefined?ALLOC_STATIC:allocator](Math.max(size,singleType?1:types.length))}if(zeroinit){var stop;ptr=ret;assert((ret&3)==0);stop=ret+(size&~3);for(;ptr>2]=0}stop=ret+size;while(ptr>0]=0}return ret}if(singleType==="i8"){if(slab.subarray||slab.slice){HEAPU8.set(slab,ret)}else{HEAPU8.set(new Uint8Array(slab),ret)}return ret}var i=0,type,typeSize,previousType;while(i>0];hasUtf|=t;if(t==0&&!length)break;i++;if(length&&i==length)break}if(!length)length=i;var ret="";if(hasUtf<128){var MAX_CHUNK=1024;var curr;while(length>0){curr=String.fromCharCode.apply(String,HEAPU8.subarray(ptr,ptr+Math.min(length,MAX_CHUNK)));ret=ret?ret+curr:curr;ptr+=MAX_CHUNK;length-=MAX_CHUNK}return ret}return UTF8ToString(ptr)}var UTF8Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(u8Array,idx){var endPtr=idx;while(u8Array[endPtr])++endPtr;if(endPtr-idx>16&&u8Array.subarray&&UTF8Decoder){return UTF8Decoder.decode(u8Array.subarray(idx,endPtr))}else{var u0,u1,u2,u3,u4,u5;var str="";while(1){u0=u8Array[idx++];if(!u0)return str;if(!(u0&128)){str+=String.fromCharCode(u0);continue}u1=u8Array[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}u2=u8Array[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u3=u8Array[idx++]&63;if((u0&248)==240){u0=(u0&7)<<18|u1<<12|u2<<6|u3}else{u4=u8Array[idx++]&63;if((u0&252)==248){u0=(u0&3)<<24|u1<<18|u2<<12|u3<<6|u4}else{u5=u8Array[idx++]&63;u0=(u0&1)<<30|u1<<24|u2<<18|u3<<12|u4<<6|u5}}}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}}}function UTF8ToString(ptr){return UTF8ArrayToString(HEAPU8,ptr)}function stringToUTF8Array(str,outU8Array,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){if(outIdx>=endIdx)break;outU8Array[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;outU8Array[outIdx++]=192|u>>6;outU8Array[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;outU8Array[outIdx++]=224|u>>12;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=2097151){if(outIdx+3>=endIdx)break;outU8Array[outIdx++]=240|u>>18;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=67108863){if(outIdx+4>=endIdx)break;outU8Array[outIdx++]=248|u>>24;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else{if(outIdx+5>=endIdx)break;outU8Array[outIdx++]=252|u>>30;outU8Array[outIdx++]=128|u>>24&63;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}}outU8Array[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}function lengthBytesUTF8(str){var len=0;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){++len}else if(u<=2047){len+=2}else if(u<=65535){len+=3}else if(u<=2097151){len+=4}else if(u<=67108863){len+=5}else{len+=6}}return len}var UTF16Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf-16le"):undefined;function allocateUTF8(str){var size=lengthBytesUTF8(str)+1;var ret=_malloc(size);if(ret)stringToUTF8Array(str,HEAP8,ret,size);return ret}function demangle(func){return func}function demangleAll(text){var regex=/__Z[\w\d_]+/g;return text.replace(regex,(function(x){var y=demangle(x);return x===y?x:x+" ["+y+"]"}))}function jsStackTrace(){var err=new Error;if(!err.stack){try{throw new Error(0)}catch(e){err=e}if(!err.stack){return"(no stack trace available)"}}return err.stack.toString()}function stackTrace(){var js=jsStackTrace();if(Module["extraStackTrace"])js+="\n"+Module["extraStackTrace"]();return demangleAll(js)}var PAGE_SIZE=16384;var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBufferViews(){Module["HEAP8"]=HEAP8=new Int8Array(buffer);Module["HEAP16"]=HEAP16=new Int16Array(buffer);Module["HEAP32"]=HEAP32=new Int32Array(buffer);Module["HEAPU8"]=HEAPU8=new Uint8Array(buffer);Module["HEAPU16"]=HEAPU16=new Uint16Array(buffer);Module["HEAPU32"]=HEAPU32=new Uint32Array(buffer);Module["HEAPF32"]=HEAPF32=new Float32Array(buffer);Module["HEAPF64"]=HEAPF64=new Float64Array(buffer)}var STATIC_BASE,STATICTOP,staticSealed;var STACK_BASE,STACKTOP,STACK_MAX;var DYNAMIC_BASE,DYNAMICTOP_PTR;STATIC_BASE=STATICTOP=STACK_BASE=STACKTOP=STACK_MAX=DYNAMIC_BASE=DYNAMICTOP_PTR=0;staticSealed=false;function abortOnCannotGrowMemory(){abort("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value "+TOTAL_MEMORY+", (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or (4) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ")}function enlargeMemory(){abortOnCannotGrowMemory()}var TOTAL_STACK=Module["TOTAL_STACK"]||5242880;var TOTAL_MEMORY=Module["TOTAL_MEMORY"]||16777216;if(TOTAL_MEMORY0){var callback=callbacks.shift();if(typeof callback=="function"){callback();continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){Module["dynCall_v"](func)}else{Module["dynCall_vi"](func,callback.arg)}}else{func(callback.arg===undefined?null:callback.arg)}}}var __ATPRERUN__=[];var __ATINIT__=[];var __ATMAIN__=[];var __ATEXIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function ensureInitRuntime(){if(runtimeInitialized)return;runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){callRuntimeCallbacks(__ATEXIT__);runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}function writeArrayToMemory(array,buffer){HEAP8.set(array,buffer)}function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}if(!Math["imul"]||Math["imul"](4294967295,5)!==-5)Math["imul"]=function imul(a,b){var ah=a>>>16;var al=a&65535;var bh=b>>>16;var bl=b&65535;return al*bl+(ah*bl+al*bh<<16)|0};Math.imul=Math["imul"];if(!Math["clz32"])Math["clz32"]=(function(x){x=x>>>0;for(var i=0;i<32;i++){if(x&1<<31-i)return i}return 32});Math.clz32=Math["clz32"];if(!Math["trunc"])Math["trunc"]=(function(x){return x<0?Math.ceil(x):Math.floor(x)});Math.trunc=Math["trunc"];var Math_abs=Math.abs;var Math_cos=Math.cos;var Math_sin=Math.sin;var Math_tan=Math.tan;var Math_acos=Math.acos;var Math_asin=Math.asin;var Math_atan=Math.atan;var Math_atan2=Math.atan2;var Math_exp=Math.exp;var Math_log=Math.log;var Math_sqrt=Math.sqrt;var Math_ceil=Math.ceil;var Math_floor=Math.floor;var Math_pow=Math.pow;var Math_imul=Math.imul;var Math_fround=Math.fround;var Math_round=Math.round;var Math_min=Math.min;var Math_max=Math.max;var Math_clz32=Math.clz32;var Math_trunc=Math.trunc;var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function getUniqueRunDependency(id){return id}function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["preloadedImages"]={};Module["preloadedAudios"]={};var memoryInitializer=null;var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return String.prototype.startsWith?filename.startsWith(dataURIPrefix):filename.indexOf(dataURIPrefix)===0}var ASM_CONSTS=[(function($0,$1){var path=Pointer_stringify($0);var data=Pointer_stringify($1);FS.createPath("/",PATH.dirname(path));FS.writeFile(PATH.join("/",path),data)})];function _emscripten_asm_const_iii(code,a0,a1){return ASM_CONSTS[code](a0,a1)}STATIC_BASE=GLOBAL_BASE;STATICTOP=STATIC_BASE+176352;__ATINIT__.push();memoryInitializer="data:application/octet-stream;base64,AAAAAAAA8D8AAAAAAADwPwAAAAAAAPA/AAAAAAAA8D8AAAAAAADwPwAAAAAAAPA/AAAAAAAA8D8AAAAAAADwPwAAAAAAAPA/AAAAAAAA8D8AAAAAAADwPwAAAAAAAPA/ACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAIMEAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSQAAAAAAAAFJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFJAAAAAAAAAUkAAIMEAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSQAAAAAAAAFJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFJAAAAAAAAAUkACEAAAAAAAAAAAAAAAABBAWC8AAAgAAAABAAAAAAAAAAIQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAICWQAAAAAAAgJZABJDDAAAAAAAAAAAAAAAQQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWEAAAAAAAABYQAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABYQAAAAAAAAFhAAAAAAAAAAAAAAAAAAAAQQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUkAAAAAAAABSQAAgAwIAAAAAAAAAAAAAEEAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAAABCQAAAAAAAAEJAAAAAAAAgg0AAAAAAAMCIQAAAAAAAAFJAAAAAAAAAUkAAAAAAAAAAAAAAAAAAAEJAAAAAAAAAQkAAAAAAACCDQAAAAAAAwIhAAAAAAAAAUkAAAAAAAABSQACwwQAAAAAAAAAAAAAAEED4NQAAkwAAAAEAAAAAAAAAQAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFJAAAAAAAAAUkAAEAACAAAAAAAAAAAAABBAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABYQAAAAAAAAFhAALDBAAAAAAAAAAAAAAAAANQ5AAAQAAAAAQAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWEAAAAAAAABYQEAgPgMAAAAAAAAAAAAAEEDcOgAAegAAAAEAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFJAAAAAAAAAUkAAAAAAAAAAAAAAAAAAABBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSQAAAAAAAAFJAAQAAAAAAAAABAAAAAAAAAAAAAAAAAPA/AQAAAAAAAAACAAAAAAAAAAAAAAAAAPA/AgAAAAAAAAADAAAAAAAAAAAAAAAAAOA/AwAAAAAAAAAEAAAAAAAAAAAAAAAAAPA/BAAAAAAAAAAFAAAAAAAAADMzMzMzM/M/BQAAAAAAAAAGAAAAAAAAAJqZmZmZmek/BgAAAAAAAAAHAAAAAAAAAAAAAAAAAPA/BwAAAAAAAAAIAAAAAAAAAAAAAAAAAOA/CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAzMzMzMzPTvwAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAACARkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAACamZmZmZnZvwAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADMzMzMzM+M/AAAAAAAAAAAAAAAAAQAAAAUAAAAAAAAAAAAAAAAAAAB7FK5H4XrkvwAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAQAAABMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGiRSAAABAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAACAZkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAACAZkCamZmZmZnZvwAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAUAAAAAAAAAAAAAAACAZkB7FK5H4XrkvwAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAACARkAAAAAAAAAAAAAAAAAAAAAAGAAAAAAAAAABAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACQAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFQAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFgAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFwAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGQAAAAAAAAAAAQAAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABxSAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8L8AAAAAAAABAAAAAAAAAAAAAAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/WKg1zTtO1T8ldQKaCBvaPwAAAAAAAOA/AAAAAAAA4D8s1JrmHafqP2recYqO5Og/WKg1zTtO1T9YqDXNO07VP1ioNc07TtU/AAAAAAAA4D9d3EYDeAviPwAAAAAAANA/WKg1zTtO1T8AAAAAAADQP9O84xQdydE/AAAAAAAA4D8AAAAAAADgPwAAAAAAAOA/AAAAAAAA4D8AAAAAAADgPwAAAAAAAOA/AAAAAAAA4D8AAAAAAADgPwAAAAAAAOA/AAAAAAAA4D/TvOMUHcnRP9O84xQdydE/XdxGA3gL4j9d3EYDeAviP13cRgN4C+I/DXGsi9to3D9kXdxGA3jtP9JvXwfOGec/EHo2qz5X5T8QejarPlflP9JvXwfOGec/eAskKH6M4z+1FfvL7snhP9JvXwfOGec/0m9fB84Z5z9YqDXNO07VP4iFWtO849g/0m9fB84Z5z94CyQofozjP8RCrWnecew/0m9fB84Z5z/Sb18HzhnnP7UV+8vuyeE/0m9fB84Z5z8QejarPlflP7UV+8vuyeE/eAskKH6M4z/Sb18HzhnnP9JvXwfOGec/hjjWxW007j/Sb18HzhnnP9JvXwfOGec/eAskKH6M4z9YqDXNO07VP9O84xQdydE/WKg1zTtO1T+mCkYldQLePwAAAAAAAOA/WKg1zTtO1T8NcayL22jcPwAAAAAAAOA/DXGsi9to3D8AAAAAAADgPw1xrIvbaNw/WKg1zTtO1T8AAAAAAADgPwAAAAAAAOA/07zjFB3J0T/TvOMUHcnRPwAAAAAAAOA/07zjFB3J0T9q3nGKjuToPwAAAAAAAOA/AAAAAAAA4D8AAAAAAADgPwAAAAAAAOA/WKg1zTtO1T+IhVrTvOPYP9O84xQdydE/AAAAAAAA4D8AAAAAAADgP9JvXwfOGec/AAAAAAAA4D8AAAAAAADgPw1xrIvbaNw/9GxWfa623j8RNjy9UpbJP/RsVn2utt4/OwFNhA1P4T8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQP1ioNc07TtU/AAAAAAAA4D8AAAAAAADgPz7o2az6XMU/AAAAAAAA4D8AAAAAAADgPwAAAAAAAOA/AAAAAAAA4D+Cc0aU9gbHPw1xrIvbaNw/AAAAAAAA4D9YqDXNO07VP1ioNc07TtU/tRX7y+7J4T+1FfvL7snhPwAAAAAAANA/AAAAAAAA4D8AAAAAAADgPwAAAAAAAOA/AAAAAAAA0D8AAAAAAADQPwfwFkhQ/Nw/orQ3+MJk1j9YqDXNO07VPw1xrIvbaNw/DXGsi9to3D8AAAAAAADgPwAAAAAAAPA/AAAAAAAA8D8AAAAAAADQPw1xrIvbaNw/AAAAAAAA0D9YqDXNO07VP1ioNc07TtU/WKg1zTtO1T9YqDXNO07VP1ioNc07TtU/WKg1zTtO1T9YqDXNO07VP1ioNc07TtU/AAAAAAAA0D9YqDXNO07VP1ioNc07TtU/AAAAAAAA0D9YqDXNO07VP1ioNc07TtU/WKg1zTtO1T8AAAAAAADwPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/xEKtad5x7D8AAAAAAADQP3/ZPXlYqNE/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D94CyQofozjP9JvXwfOGec/xEKtad5x7D8T8kHPZtXTPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D8QejarPlflPwAAAAAAANA/AAAAAAAA0D8AAAAAAADQP9O84xQdydE/AAAAAAAA0D8AAAAAAADQP9O84xQdydE/AAAAAAAA4D/Sb18HzhnnPwAAAAAAAOA/AAAAAAAA0D8AAAAAAADQPwAAAAAAANA/AAAAAAAA0D9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP1HaG3xhMuM/UdobfGEy4z9R2ht8YTLjP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/9GxWfa621j+1FfvL7snhP7UV+8vuyeE/xEKtad5x7D8QejarPlflP/Xb14FzRsw/WKg1zTtO1T9YqDXNO07VP4iFWtO849g/AU2EDU+v4j/TvOMUHcnRP1ioNc07TtU/07zjFB3J0T/TvOMUHcnRP7UV+8vuyeE/tRX7y+7J4T+1FfvL7snhP7UV+8vuyeE/tRX7y+7J4T+1FfvL7snhP7UV+8vuyeE/tRX7y+7J4T+1FfvL7snhP7UV+8vuyeE/07zjFB3J0T/TvOMUHcnRPwFNhA1Pr+I/AU2EDU+v4j8BTYQNT6/iP7UV+8vuyeE/zF1LyAc98D8QejarPlflPxB6Nqs+V+U/0m9fB84Z5z/Sb18HzhnnPxB6Nqs+V+U/eAskKH6M4z9q3nGKjuToP9JvXwfOGec/07zjFB3J0T8AAAAAAADgPxB6Nqs+V+U/tRX7y+7J4T8s1JrmHafqP9JvXwfOGec/at5xio7k6D8QejarPlflP2recYqO5Og/0m9fB84Z5z8QejarPlflP3gLJCh+jOM/0m9fB84Z5z8QejarPlflP4Y41sVtNO4/EHo2qz5X5T8QejarPlflP3gLJCh+jOM/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/pgpGJXUC3j+1FfvL7snhP0i/fR04Z8w/tRX7y+7J4T+1FfvL7snhPwAAAAAAAOA/tRX7y+7J4T+1FfvL7snhP9O84xQdydE/tRX7y+7J4T+1FfvL7snhP0i/fR04Z8w/SL99HThnzD8AAAAAAADgP0i/fR04Z8w/LNSa5h2n6j+1FfvL7snhP7UV+8vuyeE/tRX7y+7J4T+1FfvL7snhP1ioNc07TtU/AAAAAAAA4D/TvOMUHcnRP7UV+8vuyeE/AAAAAAAA4D/Sb18HzhnnPwAAAAAAAOA/AAAAAAAA4D8AAAAAAADgPwKaCBueXtU/4L4OnDOi0D8Cmggbnl7VPwFNhA1Pr+I/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T9YqDXNO07VP7UV+8vuyeE/tRX7y+7J4T8+6Nms+lzFP7UV+8vuyeE/tRX7y+7J4T+1FfvL7snhP7UV+8vuyeE/HThnRGlvyD9YqDXNO07VP7UV+8vuyeE/WKg1zTtO1T9YqDXNO07VPwAAAAAAAOA/AAAAAAAA4D/TvOMUHcnRP7UV+8vuyeE/tRX7y+7J4T+1FfvL7snhP9O84xQdydE/07zjFB3J0T/nHafoSC7hP6K0N/jCZNY/SL99HThnzD9YqDXNO07VP1ioNc07TtU/tRX7y+7J4T8AAAAAAADwPwAAAAAAAPA/07zjFB3J0T94CyQofozjP9O84xQdydE/WKg1zTtO1T9YqDXNO07VP1ioNc07TtU/WKg1zTtO1T9YqDXNO07VP1ioNc07TtU/WKg1zTtO1T9YqDXNO07VP9O84xQdydE/WKg1zTtO1T9YqDXNO07VP9O84xQdydE/WKg1zTtO1T9YqDXNO07VP1ioNc07TtU/AAAAAAAA8D/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRPwAAAAAAAPA/07zjFB3J0T/qlbIMcazXP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/tRX7y+7J4T9q3nGKjuToPwAAAAAAAPA/mN2Th4Va1z/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/xEKtad5x7D/TvOMUHcnRP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/07zjFB3J0T9Iv30dOGfMP3gLJCh+jOM/hjjWxW007j94CyQofozjP9O84xQdydE/07zjFB3J0T/TvOMUHcnRP9O84xQdydE/UaBP5EnSDkC0yHa+nzo1wDoi36XUJdW/84I+R5ouij+f5Xlwd9b5v379EBssnOY/luzYCMTrzD/NzqJ3KuDQP7Djv0AQIO2/raHUXkTb2D87oXzmUZZ2P9NucPl6hHs/gczOoncq5L/Rrdf0oKDIP2rfNxmwP4Q/vsqQGV7/hD8clgZ+VMPEv6VJKej24iNAqdkDrcCQwT8IxJBBk2mJP/pEniRdM9C/AfCZNi3CXj8NnH0vz5SXP4m1+BQA44k/5alYRjTLsb+PAMnPoWemv1y1xvvMtIg/TaSPVDqzkD/mxwShYdagv8dpZxwT94K/Kn9r5S1wXL/kV2JUCJp1P9Hxh1VyBLc/ldQJaCI8M8BkIxCv63cQwKchqvBneMc/2v8Aa9WuwT9OKETAIVT3v6pIhbGFIPU/nWhXIeUn9j9NLsbAOo7NP1lrKLUX0dy/Az+qYb8nzD+mR1M9mX/aP7aBO1CnPK4/UUzeADPfub/1dpX/2gumP9SlNbwP9pQ/H60gvCzckD8oLPGAsskjQCNa4UwCirc/SKNlUZYpfz+7tIb3wZ6TPxeoe1NHfaC/ISuu4G2Uiz8zc9yE1h61v6B4hIn1/I8/aTUk7rH0kb+4zTN6Xr9qP5I+raI/NM2/frDnxk8+mL8HI5tQLcekPz4YwntYuZG/LXx9rUuNxj8AAABA+yH5PwAAAAAtRHQ+AAAAgJhG+DwAAABgUcx4OwAAAICDG/A5AAAAQCAlejgAAACAIoLjNgAAAAAd82k1tOgAAKAqAAADAAAAyCwAAAMAAACgLwAAAwAAAGgwAAADAAAAuDEAAAMAAAAwNQAAAwAAAGw4AAADAAAAfC4AAAMAAAA0OQAAAwAAADw6AAADAAAAyD4AAAMAAADsPAAAAAAAAIwsAAAAAAAAeC8AAAAAAADILwAAAAAAAJAxAAAAAAAA4DEAAAAAAABEOAAAAAAAABguAAAAAAAADDkAAAAAAAAUOgAAAAAAAKA+AAAAAAAAxDwAAAQAAADwPgAAAAAAAAAAAAAAAAAAAAAAAAEAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAACAAAAAQAAAAEAAAADAAAAAAAAAAAAAADQjQIA4I0CAPCNAgAAjgIAEI4CACCOAgAwjgIAQI4CAOCNAgDgjQIAII4CACCOAgAfAAAAPwAAAH8AAAAAAAAAHUsBAAEAAABgKwAAaAAAAAQAAADW7AAAAQAAANgrAACIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbukAAAEAAAAAAAAA4AAAAAAAAAB26QAAAQAAAAAAAADgAAAAAQAAAH3pAAABAAAAAAAAAKgAAAACAAAAh+kAAAEAAAAAAAAA4AAAAAMAAACR6QAAAQAAAAAAAADgAAAABAAAAJ/pAAABAAAAAAAAAOAAAAAFAAAAqekAAAEAAAAAAAAA4AAAAAYAAAC26QAAAQAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAA/////wAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA2+wAAAEAAAB8LQAAGAEAAAEAAADg7AAAAQAAAHwtAAAYAQAAAgAAAObsAAABAAAAfC0AABgBAAADAAAA7+wAAAEAAAB8LQAAGAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPnsAAABAAAAAAAAAHABAAABAAAAA+0AAAEAAAAAAAAAcAEAAAIAAAAO7QAAAQAAAAAAAAA4AQAAAwAAABztAAABAAAAAAAAADgBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAkAAAAAAAAAAAAAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAwAAAANAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAYAAAACAAAAAgAAAAcAAAACAAAAAAAAAPrcAQD/xQEAkMcBANDNAQDH1AEABtkBAIbcAQCX3AEAAAAAAGPtAAABAAAA4C4AAKgBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABn7QAAAQAAAAAAAADIAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAb+0AAAEAAADwLwAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAKfuAAABAAAAAAAAACACAAACAAAAse4AAAEAAAAAAAAAWAIAAAAAAAC67gAAAQAAAAAAAABYAgAAAwAAAMPuAAABAAAAAAAAAFgCAAAAAAAAze4AAAEAAAAAAAAAIAIAAAMAAADZ7gAAAQAAAAAAAAAgAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEAAAASAAAAAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAVAAAAFgAAABcAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAMAAAAJAAAAAwAAAAMAAAAKAAAABAAAAAAAAAD63AEA/8UBANDNAQCQxwEABtkBAMfUAQCX3AEAhtwBAAAAAAAAAAAAlvAAAP/////0MAAAkAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJnwAAD/////AAAAALACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABcUwEAAQAAAAgyAADoAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAGQAAABoAAAAAAAAABAAAAAAAAAAbAAAAHAAAAB0AAAAeAAAAAAAAAAAAAAAAAAAAAAAAAB8AAAAgAAAAIQAAACIAAAACAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAMAAAABQAAAAQAAAANAAAABQAAAAMAAACW9AAApPQAALr0AABlqAIAyPQAANf0AADc9AAA+vQAAGWoAgAM9QAAPPUAAGWoAgBa9QAAgvUAAJD1AAC/9QAA8/UAAAT2AAAp9gAATPYAAFL2AABu9gAAi/YAAKb2AADH9gAA4fYAAAP3AAAi9wAASPcAAGD3AACA9wAAnfcAAMH3AADN9wAAZagCANj3AAD+9wAAIvgAAEj4AABlqAIAfvgAAJb4AACj+AAA0vgAAM33AABlqAIA3/gAAOj4AAAJ+QAARPkAAI/5AADj+QAABfoAABr6AAAx+gAAR/oAAF/6AABlqAIAdfoAAJD6AAC0+gAA2PoAAP36AABlqAIAHvsAADj7AABK+wAAV/sAAGT7AAB4+wAAh/sAAI/7AACk+wAAsvsAAPD7AAD7+wAAzfcAAGWoAgAB/AAADfwAABz8AABM9gAAZagCAC/8AABY/AAAdvwAAIb8AACX/AAAnvwAAK38AAC9/AAAAf0AAAj9AABM9gAAZagCABL9AAA+/QAASf0AAFL9AABb/QAAbP0AAH39AACR/QAAzfcAAGWoAgCd/QAArf0AALv9AADJ/QAA1v0AAOP9AAD5/QAAAv4AABH+AAAe/gAAL/4AAM33AABlqAIAOv4AAFn+AABlqAIAa/4AAHr+AACq/gAAtP4AAMH+AADO/gAA2/4AAOj+AADr/gAAZagCAO/+AABlqAIAEv8AAEP/AABy/wAAif8AAKT/AAC//wAAzfcAAGWoAgDb/wAAZagCAAMAAQAPAAEAIgABADUAAQBKAAEAXwABAGMAAQBM9gAAZagCAG8AAQBlqAIAfwABAI0AAQCZAAEApgABAMYAAQDcAAEAZagCAPAAAQA5AQEAfwEBAK8BAQDiAQEA6QEBABACAQA3AgEAZagCADwCAQAAAAAAAAAAAPorAQABAAAAAAAAAAgDAAABAAAAsAIBAAEAAAAAAAAACAMAAAIAAADzKwEAAQAAAAAAAABAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAjAAAAAAAAACQAAAAlAAAABgAAACYAAAAnAAAAKAAAACkAAAAqAAAAAAAAAAAAAAAAAAAAAAAAACsAAAAsAAAALQAAAC4AAAAEAAAALwAAAAAAAAAAAAAADgAAAAAAAAAPAAAABwAAAAUAAAAQAAAABgAAAAAAAAAXxQEAIcUBAHoVAQBmxQEAocUBAMPFAQDJxQEA+twBAPDFAQD/xQEAHMYBACfGAQBJxgEAf8YBALXGAQDwxgEAJscBAEjHAQBXxwEAiMcBAJDHAQBACQEASQkBAK3HAQBSCQEA98cBAFsJAQAByAEAZAkBAAvIAQBayAEAlcgBAHAJAQDQyAEA28gBACDJAQAuyQEAeMkBAIbJAQCUyQEAn8kBANDJAQAQygEAGMoBACDKAQBbygEAkcoBAJ3KAQB/FQEAqcoBALPKAQC+ygEA28oBABHLAQDQzQEA8s0BAP7NAQC90AEA7tABABrRAQBQ0QEAXdEBAH/RAQCh0QEAqtEBAPTRAQD+0QEAQ9IBAHnSAQCE0gEACdMBAB7TAQB4CQEAKNMBADLTAQBo0wEAqNMBALbTAQAK1AEAGdQBACjUAQB31AEAhxUBALfUAQDB1AEAx9QBAPPUAQAa1QEAK9UBADbVAQB71QEAwNUBAM/VAQDf1QEA8dUBAAHWAQAR1gEAHtYBACjWAQBe1gEAZ9YBAKfWAQC61gEAjBUBAMLWAQD41gEAH9cBAFXXAQB81wEAitcBAMDXAQAK2AEAVNgBAF/YAQCV2AEAmtgBALfYAQDU2AEA39gBAAbZAQAe2QEAVNkBAIrZAQCW2QEAvdkBAMjZAQD52QEAKtoBAHkgAQBR2gEAfdoBALPaAQDp2gEA89oBABDbAQBQ2wEAhtsBAJIVAQCe2wEAytsBAPHbAQAn3AEAZNwBAIbcAQCM3AEAl9wBAL7cAQAAAAAAX1MBAAEAAACANQAAeAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANEsAQABAAAAAAAAAJgDAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMgAAAAAAAAAzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAAAAABIAAAAIAAAABgAAABMAAAAHAAAAAAAAAAAAAACuCgEAAQAAAJQ4AADQAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsQoBAAEAAAAAAAAA8AMAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAA1AAAANgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAADcAAAAAAAAAAAAAABQAAAAAAAAAFQAAAAkAAAAHAAAAFgAAAAgAAAAAAAAAehUBAPrcAQD/xQEAfxUBABHLAQDQzQEAhxUBAPPUAQCn1gEAjBUBAN/YAQAG2QEAeSABAJIVAQCG3AEAl9wBAAAAAACXFQEAAQAAAFw5AAAoBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAmxUBAAEAAAAAAAAASAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAA5AAAAOgAAAAoAAAA7AAAAPAAAAD0AAAA+AAAAPwAAAAAAAAAAAAAAAAAAAAAAAABAAAAAQQAAAEIAAABDAAAAAAAAAAAAAAAAAAAAAAAAABcAAAAAAAAAGAAAAAsAAAAIAAAAGQAAAAkAAAAAAAAAZsUBAA8fAQD63AEA/8UBABzGAQAaHwEAIB8BACsfAQAyHwEAJ8YBAH/GAQA6HwEAQB8BAEsfAQAmxwEASMcBAJDHAQBSHwEA98cBAAvIAQCVyAEAXB8BACDJAQAuyQEAeMkBAGcfAQCGyQEAbx8BAHgfAQCGHwEAkB8BAFvKAQCZHwEAncoBAL7KAQDbygEAnx8BACLLAQBNywEAdssBAJnLAQDCywEA5csBAA7MAQAxzAEAWswBAH3MAQCmzAEAycwBAPLMAQAVzQEAPs0BAGHNAQCKzQEArc0BANDNAQCmHwEA8s0BALIfAQAa0QEAf9EBAEPSAQC/HwEAKNQBAMwfAQC31AEAx9QBANYfAQDz1AEAGtUBACvVAQDlHwEA9x8BADbVAQDA1QEAz9UBAN/VAQDx1QEAAdYBAAcgAQASIAEAHSABABHWAQCn1gEArNYBACIgAQArIAEANCABAEQgAQBLIAEA+NYBAB/XAQBV1wEAitcBAJrYAQC32AEAUyABAAbZAQBaIAEAltkBAGMgAQDI2QEAayABACraAQB5IAEAUdoBAH3aAQCAIAEAENsBAFDbAQCKIAEAhtsBAJ7bAQDx2wEAlCABAKIgAQAn3AEALtwBAGTcAQCG3AEAl9wBAL7cAQAAAAAAtCABAAEAAABkOgAAgAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALggAQABAAAAAAAAAKAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARAAAAEUAAAAAAAAAAAAAAEYAAABHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaAAAAAAAAABsAAAAMAAAACQAAABwAAAAKAAAAAAAAAEFCAABEZwEAQUkAAB5nAQBBUgAA8WYBAEFYAABZZwEAQiAAAJVpAQBCSQAApmkBAENCAADeZwEAQ08AAMxnAQBDWAAA62cBAEggAAAPaAEASEIAABloAQBISQAApWgBAEhYAAAoaAEASGIAAFloAQBIaQAAjGgBAEhyAAA+aAEASHgAAG9oAQBJIAAAt2kBAEtCAABwZwEAS0kAALhnAQBLUgAApGcBAEtYAACRZwEATkIAALdoAQBOSQAA/mgBAE5SAAAWaQEATlgAAOJoAQBQQQAAd2kBAFBCAAAzaQEAUEkAAGdpAQBQWAAAU2kBAFIgAABjawEAUyAAAIZpAQBaRAAA9GkBAAAAAAAAAAAAAQAAAAAAAABnKwEA/////xQ9AADYBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaysBAP////8AAAAA+AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwAAAHMrAQABAAAA2EIAAAAAAAAQAAAAeysBAAEAAADYQgAAAAAAABEAAACDKwEAAQAAANhCAAAAAAAAEQAAAIwrAQABAAAA2EIAAAAAAAARAAAAlCsBAAEAAADYQgAAAAAAABMAAACcKwEAAQAAANxCAAAAAAAAFAAAAKQrAQABAAAA3EIAAAAAAAAVAAAArCsBAAEAAADcQgAAAAAAABUAAAC1KwEAAQAAANxCAAAAAAAAFQAAAL0rAQABAAAA3EIAAAAAAAAWAAAAxSsBAAEAAADgQgAAAAAAABcAAADOKwEAAQAAAOBCAAAAAAAAGAAAANcrAQABAAAA4EIAAAAAAAAYAAAA4SsBAAEAAADgQgAAAAAAABgAAADqKwEAAQAAAOBCAAAAAAAAGQAAAPMrAQABAAAA5EIAAAAAAAAZAAAA+isBAAEAAADkQgAAAAAAABoAAAAALAEAAQAAAOhCAAAAAAAACgAAAAksAQABAAAA7EIAAAAAAAALAAAAESwBAAEAAADsQgAAAAAAAAwAAAAZLAEAAQAAAOxCAAAAAAAADAAAACIsAQABAAAA7EIAAAAAAAAMAAAAKiwBAAEAAADsQgAAAAAAAA4AAAAyLAEAAQAAAOxCAAAAAAAADgAAADksAQABAAAA7EIAAAAAAAANAAAAQSwBAAEAAADsQgAAAAAAAAUAAABJLAEAAQAAAOxCAAAAAAAABgAAAFEsAQABAAAA7EIAAAAAAAAHAAAAWSwBAAEAAADsQgAAAAAAAAcAAABiLAEAAQAAAOxCAAAAAAAABwAAAGosAQABAAAA7EIAAAAAAAAJAAAAciwBAAEAAADsQgAAAAAAAAkAAAB5LAEAAQAAAOxCAAAAAAAACAAAAIEsAQABAAAA7EIAAAAAAAAAAAAAiSwBAAEAAADwQgAAAAAAAAEAAACSLAEAAQAAAPBCAAAAAAAAAgAAAJssAQABAAAA8EIAAAAAAAACAAAApSwBAAEAAADwQgAAAAAAAAIAAACuLAEAAQAAAPBCAAAAAAAABAAAALcsAQABAAAA8EIAAAAAAAAEAAAAvywBAAEAAADwQgAAAAAAAAMAAADILAEAAQAAAPBCAAAAAAAAEgAAANEsAQABAAAA2EIAAAAAAAAbAAAA2SwBAAEAAAD0QgAAAAAAABwAAADhLAEAAQAAAPRCAAAAAAAAHQAAAOksAQABAAAA9EIAAAAAAAAdAAAA8iwBAAEAAAD0QgAAAAAAAB0AAAD6LAEAAQAAAPRCAAAAAAAAHgAAAAItAQABAAAA+EIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAOAAAADwAAABAAAAARAAAAEgAAABMAAAAUAAAAFQAAAG0wAQAEQwAAAQAAACBDAAAAAAAAAAAAAEgAAABJAAAAAQAAAAAAAAAdSwEAAAAAABRDAAAcQwAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAAAAAABAAAAAQAAAAEAAAABAAAAAgAAAAIAAAABAAAAAgAAAAQAAAAYAQAAMAEAALAAAACXOAEAnDgBAKA4AQCnOAEAqzgBAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAAAAAAdAAAAAAAAAAAAAAAeAAAAAAAAAAAAAAAfAAAAAAAAAAAAAAABAAAAQAAAANhDAADoQwAAAgAAAAQAAAD0QwAAAgAAAAgAAAACAAAABAAAAPxDAAAABAAACAAAAP////8AAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAANQAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAQAAAAAAAAACAAAAAAAAAAAAAAAAAAAA/////wAAAAAAAAAAAQAAAAAAAAACAAAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAwAAAAAAAAACAAAAAAAAAAAAAAAAAAAA/////wAAAAAAAAAAAwAAAAAAAAACAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAABAAAAAAAAAACAAAAAAAAAAkAAAALAAAACAAAAAoAAACARQAABEUAAGhFAAABAAAAAQAAAAUAAAAWAAAABgAAAEoAAAAhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAIAAAAAAAAAAIAAAAAAAAAAwAAAAIAAAADAAAABAAAAAAAAAAAAAAABAAAAAMAAAAJAAAACwAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAoAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIgAAAAsAAAAAAAAAAgAAAAAAAAAIAAAACAAAAAAAAAAAAAAAIwAAAAAAAAAAAAAAAAAAAAAAAAAQAAAA/////wAAAAAAAAAAJAAAAAAAAAAAAAAAAgAAAAAAAAABAAAAAAAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAgAAAAMAAAABAAAAAQAAAAIAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAACAAAAAQAAAAQAAAAFAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAABgAAAAEAAAABAAAABwAAAAgAAAAJAAAACgAAAAoAAAAKAAAACgAAAAoAAAAKAAAACgAAAAoAAAAKAAAACgAAAAEAAAABAAAACwAAAAEAAAAMAAAAAQAAAA0AAAAOAAAADwAAABAAAAARAAAAEgAAABMAAAAUAAAAFQAAABYAAAATAAAAEwAAABMAAAATAAAAFwAAABgAAAAZAAAAEwAAABoAAAAbAAAAHAAAAB0AAAATAAAAEwAAABMAAAATAAAAEwAAAAEAAAAeAAAAAQAAAAEAAAATAAAAAQAAAB8AAAAgAAAAIQAAACIAAAAjAAAAEwAAACQAAAAlAAAAJgAAABMAAAATAAAAEwAAABMAAAAnAAAAKAAAACkAAAATAAAAKgAAACsAAAAsAAAALQAAABMAAAATAAAAEwAAABMAAAATAAAAAQAAAAEAAAABAAAAAQAAAAEAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAAC4AAAATAAAAEwAAABMAAAAvAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAAwAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAABMAAAATAAAAEwAAAAAAAAABAAAAAQAAAAIAAAADAAAAAQAAAAQAAAABAAAABQAAAAEAAAAGAAAABwAAAAcAAAABAAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABgAAAAMAAAAGAAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABgAAAAYAAACAAAAAEXgBAO13AQBjQQEAHngBABZ4AQAkeAEAAAAAAGlFAQByRQEAeUUBAIdFAQCORQEAOngBAJVFAQCcRQEAAQAAAAgAAAD/////AAAAAAAAAAAlAAAAAAAAAAAAAAAAAAAAAAAAADpHAQAIAAAAAwAAAENHAQBHRwEACwAAAAYAAABcUwEAU0cBAAIAAAABAAAAVkcBAFpHAQAEAAAAAgAAAF9HAQBjRwEABAAAAAQAAABoRwEAbUcBAAUAAAAFAAAAc0cBAHdHAQAEAAAABwAAAHxHAQCARwEABQAAAAkAAACGRwEAikcBAAQAAAAKAAAAj0cBAJRHAQAEAAAADAAAAJlHAQBaTAEAAAAAAAEAAABiTAEAAQAAAAAAAAA4dwEAAQAAAAEAAAC11gEAAAAAAAAAAAAAAAAAAAAAAAAAAABGSwEAMQAAAAAAAAAAAAAAWXIBABAAAADw4gEAgAAAAD9LAQBAAAAAomUBABAAAABBSwEAQAAAAAAAAAAAAAAADUsBAAEAAAAUSwEAAgAAABlLAQADAAAAiWIBAAQAAADEYgEABQAAAB1LAQAGAAAAtdYBAAgAAAAhSwEAIQAAACVLAQAiAAAAKUsBACIAAAAtSwEAAQAAADJLAQAHAAAAOEsBACcAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAP////8AAAAAJgAAAAAAAAAAAAAAAAAAAAAAAACEUAEAi1ABAAAAAABZUwEAXFMBAF9TAQAAAAAAAAAAAAEAAAACAAAA/////xxTAQAiUwEAtdYBAAAAAABkAAAAZQAAAGYAAABkAAAACAAAAAgAAAAAAAAAAAAAACcAAAAMAAAAAAAAAAAAAAAAAAAACAAAAP////8AAAAAAAAAACgAAAAAAAAAAAAAAAAAAAAAAAAAiWIBAIxRAABABgAAAAAAAI1iAQCMUQAAcAYAAAAAAABbawEAjFEAAKAGAAAAAAAAlWIBAIxRAACgBgAAAAAAAJpiAQCMUQAA0AYAAAAAAAChYgEApFEAANAGAAAAAAAAp2IBAIxRAAAABwAAAAAAAKtiAQCMUQAAMAcAAAAAAAC11gEAjFEAAGAHAAAAAAAAtGIBAIxRAABgBwAAAAAAAL5iAQCMUQAAEAYAAAAAAADEYgEAjFEAAJAHAAAAAAAAzGIBAIxRAADABwAAAAAAANZiAQCMUQAA8AcAAAAAAADkYgEAjFEAACAIAAAAAAAA6mIBAIxRAABQCAAAAAAAAPNiAQCMUQAAgAgAAAAAAAD7YgEAjFEAALAIAAAAAAAABGMBAIxRAADgCAAAAAAAAAxjAQCMUQAAEAkAAAAAAAARYwEAjFEAAEAJAAAAAAAAFWMBAIxRAABwCQAAAAAAABxjAQCMUQAAoAkAAAAAAAAiYwEAjFEAANAJAAAAAAAALGMBALxRAAAACgAAAAAAADVjAQCMUQAAQAYAAAAAAAA6YwEAjFEAAEAGAAAAAAAARGMBAIxRAAAwCgAAAAAAAEtjAQCMUQAAYAoAAAAAAABYYwEAjFEAAJAKAAAAAAAAZmMBAIxRAADACgAAAAAAAHRjAQCMUQAA8AoAAAAAAACAYwEAjFEAACALAAAAAAAAjWMBAIxRAABQCwAAAAAAAJZjAQCMUQAAgAsAAAAAAACgYwEAjFEAALALAAAAAAAAqWMBAIxRAADgCwAAAAAAALFjAQCMUQAAEAwAAAAAAAC5YwEAjFEAAEAMAAAAAAAAwmMBAIxRAABwDAAAAAAAAMZjAQCMUQAAoAwAAAAAAADRYwEAjFEAANAMAAAAAAAA1WMBAIxRAAAADQAAAAAAAN9jAQCMUQAAMA0AAAAAAADoYwEAjFEAAGANAAAAAAAA8GMBAIxRAACQDQAAAAAAAP1jAQCMUQAAwA0AAAAAAAAJZAEAjFEAAPANAAAAAAAAFGQBAIxRAAAgDgAAAAAAACRkAQCMUQAAUA4AAAAAAAAyZAEAjFEAAIAOAAAAAAAAQWQBAIxRAACwDgAAAAAAAEtkAQCMUQAA4A4AAAAAAABUZAEAjFEAABAPAAAAAAAAXmQBAIxRAABADwAAAAAAAGhkAQCMUQAAcA8AAAAAAABvZAEAjFEAAKAPAAAAAAAAdmQBAIxRAADQDwAAAAAAAIBkAQDUUQAAAAAAAAAAAACHZAEA1FEAAAAAAAAAAAAAZWIBAOxRAAAAAAAAAAAAAI9kAQAEUgAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASwAAAEwAAAAXAAAABAAAAAIAAAAMAAAATQAAAEwAAAAXAAAABQAAAAAAAAANAAAASwAAAEwAAAAXAAAABAAAAAIAAAAMAAAATgAAAE8AAAAYAAAABgAAAAMAAAAOAAAAUAAAAFEAAAAXAAAABwAAAAAAAAAPAAAASwAAAEwAAAAXAAAACAAAAAIAAAAMAAAAEAAAABEAAAASAAAAEwAAAJFlAQCYZQEAAAAAAKBlAQCiZQEAKuMBAKRlAQAMAAAABAAAAAYAAAACAAAAAwAAAAEAAAAJAAAACAAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABEAAAASAAAAFQAAABYAAAAXAAAAGAAAABkAAAAaAAAAGwAAABwAAAAfAAAAIAAAACEAAAAiAAAAIwAAACQAAAAlAAAAJgAAACkAAAAqAAAAKwAAACwAAAAtAAAALgAAAC8AAAAwAAAAMwAAADQAAAA1AAAANgAAADcAAAA4AAAAOQAAADoAAAA9AAAAPgAAAD8AAABAAAAAQQAAAEIAAABDAAAARAAAAEcAAABIAAAASQAAAEoAAABLAAAATAAAAE0AAABOAAAAUQAAAFIAAABTAAAAVAAAAFUAAABWAAAAVwAAAFgAAADxZgEAAWcBAA5nAQAAAAAAAAAAAAQAAAATZwEAAAAAAAAAAAAeZwEAAWcBAA5nAQAAAAAANWcBAAUAAAATZwEAAAAAAD1nAQBEZwEAAWcBAFRnAQAAAAAAAAAAAAYAAAATZwEAoXYBAAAAAABZZwEAAWcBAFRnAQAAAAAANWcBAAcAAAATZwEAoXYBAD1nAQBwZwEAfWcBAFRnAQAAAAAAAAAAAAoAAACLZwEAoXYBAAAAAACRZwEAfWcBAFRnAQAAAAAAPWcBAAsAAACLZwEAoXYBAD1nAQCkZwEAfWcBALJnAQAAAAAAAAAAAAgAAACLZwEAAAAAAAAAAAC4ZwEAfWcBALJnAQAAAAAAPWcBAAkAAACLZwEAAAAAAD1nAQDMZwEAzGcBAAAAAAAAAAAAAAAAAAwAAADUZwEAAAAAAAAAAADeZwEAzGcBAKF2AQAAAAAAAAAAAA4AAADUZwEAoXYBAAAAAADrZwEAzGcBAKF2AQAAAAAANWcBAA8AAADUZwEAoXYBAD1nAQD/ZwEAzGcBAAAAAAAAAAAANWcBAA0AAADUZwEAAAAAAD1nAQAPaAEAD2gBAAAAAAAAAAAAAAAAABAAAAATZwEAAAAAAAAAAAAZaAEAD2gBAKF2AQAAAAAAAAAAABIAAAATZwEAoXYBAAAAAAAoaAEAD2gBAKF2AQAAAAAANWcBABMAAAATZwEAoXYBAD1nAQA+aAEAD2gBAAAAAABPaAEAAAAAABQAAAATZwEAAAAAAAAAAABZaAEAD2gBAKF2AQBPaAEAAAAAABYAAAATZwEAoXYBAAAAAABvaAEAD2gBAKF2AQBPaAEANWcBABcAAAATZwEAoXYBAD1nAQCMaAEAD2gBAAAAAABPaAEANWcBABUAAAATZwEAAAAAAD1nAQClaAEAD2gBAAAAAAAAAAAANWcBABEAAAATZwEAAAAAAD1nAQC3aAEAzWgBAKF2AQAAAAAAAAAAABoAAACLZwEAoXYBAAAAAADiaAEAzWgBAKF2AQAAAAAAPWcBABsAAACLZwEAoXYBAD1nAQD+aAEAzWgBAAAAAAAAAAAAPWcBABkAAACLZwEAAAAAAD1nAQAWaQEAzWgBAC1pAQAAAAAAAAAAABgAAACLZwEAAAAAAAAAAAAzaQEAQWkBAKF2AQAAAAAAAAAAAB4AAACLZwEAoXYBAAAAAABTaQEAQWkBAKF2AQAAAAAAPWcBAB8AAACLZwEAoXYBAD1nAQBnaQEAQWkBAAAAAAAAAAAAPWcBAB0AAACLZwEAAAAAAD1nAQB3aQEAQWkBAC1pAQAAAAAAAAAAABwAAACLZwEAAAAAAAAAAACGaQEAhmkBAAAAAAAAAAAAAAAAACAAAACNaQEAAAAAAAAAAACVaQEAoGkBAKF2AQAAAAAAAAAAAAIAAACLZwEAoXYBAAAAAACmaQEAoGkBAKF2AQAAAAAAPWcBAAMAAACLZwEAoXYBAD1nAQC3aQEAoGkBAAAAAAAAAAAAPWcBAAEAAACLZwEAAAAAAD1nAQBjawEAoGkBAAAAAAAAAAAAAAAAAAAAAACLZwEAAAAAAAAAAADEaQEA3mkBAO1pAQAAAAAAPWcBACEAAACLZwEAAAAAAD1nAQD0aQEAAWoBAAAAAAAAAAAAAAAAACIAAACNaQEAAAAAAAAAAAAIAAAA/////wAAAAAAAAAAKQAAAAAAAAAAAAAAAAAAAAAAAAC/awEAxgAAAMVrAQDBAAAAzGsBAMIAAADSawEAwAAAANlrAQCRAwAA32sBAMUAAADlawEAwwAAAOxrAQDEAAAA8WsBAJIDAAD2awEAxwAAAP1rAQCnAwAAAWwBACEgAAAIbAEAlAMAAA5sAQDQAAAAEmwBAMkAAAAZbAEAygAAAB9sAQDIAAAAJmwBAJUDAAAubAEAlwMAADJsAQDLAAAAN2wBAJMDAAA9bAEAzQAAAERsAQDOAAAASmwBAMwAAABRbAEAmQMAAFZsAQDPAAAAW2wBAJoDAABhbAEAmwMAAGhsAQCcAwAAa2wBANEAAABybAEAnQMAAHVsAQBSAQAAe2wBANMAAACCbAEA1AAAAIhsAQDSAAAAj2wBAKkDAACVbAEAnwMAAJ1sAQDYAAAApGwBANUAAACrbAEA1gAAALBsAQCmAwAAtGwBAKADAAC3bAEAMyAAAL1sAQCoAwAAwWwBAKEDAADFbAEAYAEAAMxsAQCjAwAA0mwBAN4AAADYbAEApAMAANxsAQCYAwAA4mwBANoAAADpbAEA2wAAAO9sAQDZAAAA9mwBAKUDAAD+bAEA3AAAAANtAQCeAwAABm0BAN0AAAANbQEAeAEAABJtAQCWAwAAF20BAOEAAAAebQEA4gAAACRtAQC0AAAAKm0BAOYAAAAwbQEA4AAAADdtAQA1IQAAP20BALEDAABFbQEAJgAAAEltAQAnIgAATW0BACAiAABRbQEA5QAAAFdtAQBIIgAAXW0BAOMAAABkbQEA5AAAAGltAQAeIAAAb20BALIDAAB0bQEApgAAAHttAQAiIAAAgG0BACkiAACEbQEA5wAAAIttAQC4AAAAkW0BAKIAAACWbQEAxwMAAJptAQDGAgAAn20BAGMmAAClbQEARSIAAKptAQCpAAAAr20BALUhAAC1bQEAKiIAALltAQCkAAAAwG0BANMhAADFbQEAICAAAMxtAQCTIQAA0W0BALAAAADVbQEAtAMAANttAQBmJgAA4W0BAPcAAADobQEA6QAAAO9tAQDqAAAA9W0BAOgAAAD8bQEABSIAAAJuAQADIAAAB24BAAIgAAAMbgEAtQMAABRuAQBhIgAAGm4BALcDAAAebgEA8AAAACJuAQDrAAAAJ24BAKwgAAAsbgEAAyIAADJuAQCSAQAAN24BAAAiAAA+bgEAvQAAAEVuAQC8AAAATG4BAL4AAABTbgEARCAAAFluAQCzAwAAX24BAGUiAABibgEAPgAAAGVuAQDUIQAAam4BAJQhAABvbgEAZSYAAHZuAQAmIAAAfW4BAO0AAACEbgEA7gAAAIpuAQChAAAAkG4BAOwAAACXbgEAESEAAJ1uAQAeIgAAo24BACsiAACnbgEAuQMAAKxuAQC/AAAAs24BAAgiAAC4bgEA7wAAAL1uAQC6AwAAw24BANAhAADIbgEAuwMAAM9uAQApIwAA1G4BAKsAAADabgEAkCEAAN9uAQAIIwAA5W4BABwgAADrbgEAZCIAAO5uAQAKIwAA9W4BABciAAD8bgEAyiUAAABvAQAOIAAABG8BADkgAAALbwEAGCAAABFvAQA8AAAAFG8BAK8AAAAZbwEAFCAAAB9vAQC1AAAAJW8BALcAAADRdwEAEiIAACxvAQC8AwAAL28BAAciAAA1bwEAoAAAADpvAQATIAAAQG8BAGAiAABDbwEACyIAAEZvAQCsAAAASm8BAAkiAABQbwEAhCIAAFVvAQDxAAAAXG8BAL0DAABfbwEA8wAAAGZvAQD0AAAAbG8BAFMBAABybwEA8gAAAHlvAQA+IAAAf28BAMkDAACFbwEAvwMAAI1vAQCVIgAAk28BACgiAACWbwEAqgAAAJtvAQC6AAAAoG8BAPgAAACnbwEA9QAAAK5vAQCXIgAAtW8BAPYAAAC6bwEAtgAAAL9vAQACIgAAxG8BADAgAADLbwEApSIAANBvAQDGAwAA1G8BAMADAADXbwEA1gMAANtvAQCxAAAA4m8BAKMAAADobwEAMiAAAO5vAQAPIgAA828BAB0iAAD4bwEAyAMAAPxvAQAiAAAAAXABANIhAAAGcAEAGiIAAAxwAQAqIwAAEXABALsAAAAXcAEAkiEAABxwAQAJIwAAInABAB0gAAAocAEAHCEAAC1wAQCuAAAAMXABAAsjAAA4cAEAwQMAADxwAQAPIAAAQHABADogAABHcAEAGSAAAE1wAQAaIAAAU3ABAGEBAABacAEAxSIAAF9wAQCnAAAAZHABAK0AAABocAEAwwMAAG5wAQDCAwAAdXABADwiAAB5cAEAYCYAAIBwAQCCIgAAhHABAIYiAACJcAEAESIAAI1wAQCDIgAAkXABALkAAACWcAEAsgAAAJtwAQCzAAAAoHABAIciAAClcAEA3wAAAKtwAQDEAwAAr3ABADQiAAC2cAEAuAMAALxwAQDRAwAAxXABAAkgAADMcAEA/gAAANJwAQDcAgAA2HABANcAAADecAEAIiEAAORwAQDRIQAA6XABAPoAAADwcAEAkSEAAPVwAQD7AAAA+3ABAPkAAAACcQEAqAAAAAZxAQDSAwAADHEBAMUDAAAUcQEA/AAAABlxAQAYIQAAIHEBAL4DAAAjcQEA/QAAACpxAQClAAAALnEBAP8AAAAzcQEAtgMAADhxAQANIAAAPHEBAAwgAAAFAAAABgAAAAEBAAAIAAAACAAAAAAAAAAAAAAAKgAAAA0AAAAAAAAAAAAAAAAAAAAIAAAAEAAAAAAAAAAAAAAAKwAAAA4AAAAAAAAAAAAAAAAAAACRdwEABwAAAJN3AQAIAAAAmHcBAAgAAACgdwEACQAAAKZ3AQAJAAAAr3cBAAoAAACydwEACgAAALh3AQALAAAAvXcBAAsAAADFdwEADAAAAMp3AQAMAAAA0XcBAA0AAADXdwEADQAAAON3AQAOAAAAUgAAACwAAAAtAAAAFAAAAC4AAABTAAAALwAAABUAAAAwAAAACAAAAAQAAAD/////AAAAAAAAAAAPAAAAAAAAAAAAAAAAAAAAO3kBAFVdyX/Jf/8ARnkBALst1L6u1P8AUXkBABR3/f3Ahv8AXHkBAFVdyX/Jf/8AZ3kBALst1L6u1P8AcnkBABR3/f3Ahv8AfXkBACpm////mf8AiHkBAFVdyX/Jf/8Ak3kBALst1L6u1P8AnnkBABR3/f3Ahv8AqXkBACpm////mf8AtHkBAJetsDhssP8Av3kBAFVdyX/Jf/8AynkBALst1L6u1P8A1XkBABR3/f3Ahv8A4HkBACpm////mf8A63kBAJetsDhssP8A9nkBAOj88PACf/8AAXoBAFVdyX/Jf/8ADHoBALst1L6u1P8AF3oBABR3/f3Ahv8AInoBACpm////mf8ALXoBAJetsDhssP8AOHoBAOj88PACf/8AQ3oBABHgv79bF/8ATnoBAFVdyX/Jf/8AWXoBALst1L6u1P8AZHoBABR3/f3Ahv8Ab3oBACpm////mf8AenoBAJetsDhssP8AhXoBAOj88PACf/8AkHoBABHgv79bF/8Am3oBAAAAZmZmZv8ApnoBAJMZ997r9/8AsHoBAI5L4Z7K4f8AunoBAJG8vTGCvf8AxHoBAJ8Q/+/z//8AznoBAI8u573X5/8A2HoBAI9/1muu1v8A4noBAJPQtSFxtf8A7HoBAJ8Q/+/z//8A9noBAI8u573X5/8AAHsBAI9/1muu1v8ACnsBAJG8vTGCvf8AFHsBAJXxnAhRnP8AHnsBAJ8Q/+/z//8AKHsBAJQr78bb7/8AMnsBAI5L4Z7K4f8APHsBAI9/1muu1v8ARnsBAJG8vTGCvf8AUHsBAJXxnAhRnP8AWnsBAJ8Q/+/z//8AZHsBAJQr78bb7/8AbnsBAI5L4Z7K4f8AeHsBAI9/1muu1v8AgnsBAJCpxkKSxv8AjHsBAJPQtSFxtf8AlnsBAJfxlAhFlP8AoHsBAJQI//f7//8AqnsBAJMZ997r9/8AtHsBAJQr78bb7/8AvnsBAI5L4Z7K4f8AyHsBAI9/1muu1v8A0nsBAJCpxkKSxv8A3HsBAJPQtSFxtf8A5nsBAJfxlAhFlP8A8HsBAJQI//f7//8A+nsBAJMZ997r9/8ABHwBAJQr78bb7/8ADnwBAI5L4Z7K4f8AGHwBAI9/1muu1v8AInwBAJCpxkKSxv8ALHwBAJPQtSFxtf8ANnwBAJXxnAhRnP8AQHwBAJjrawgwa/8ASnwBABfvVFQwBf8AVHwBAHf/PAA8MP8AX3wBABfsjIxRCv8AaXwBABjCv7+BLf8Ac3wBAB1w39/Cff8AfXwBAB409vbow/8Ah3wBAHkm6sfq5f8AkXwBAHhfzYDNwf8Am3wBAHyllzWXj/8ApXwBAHz8ZgFmXv8Ar3wBABfvVFQwBf8AuXwBAHz8ZgFmXv8AxHwBAHf/PAA8MP8Az3wBABfsjIxRCv8A2XwBABjCv7+BLf8A43wBAB1w39/Cff8A7XwBAB409vbow/8A93wBAAAA9fX19f8AAX0BAHkm6sfq5f8AC30BAHhfzYDNwf8AFX0BAHyllzWXj/8AH30BAByH2NizZf8AKH0BAAAA9fX19f8AMX0BAHt/tFq0rP8AOn0BABXXpqZhGv8AQ30BAB1w39/Cff8ATH0BAHhfzYDNwf8AVX0BAHn9hQGFcf8AXn0BABXXpqZhGv8AZ30BAB1w39/Cff8AcH0BAAAA9fX19f8AeX0BAHhfzYDNwf8Agn0BAHn9hQGFcf8Ai30BABfsjIxRCv8AlH0BAByH2NizZf8AnX0BAB409vbow/8Apn0BAHkm6sfq5f8Ar30BAHt/tFq0rP8AuH0BAHz8ZgFmXv8AwX0BABfsjIxRCv8Ayn0BAByH2NizZf8A030BAB409vbow/8A3H0BAAAA9fX19f8A5X0BAHkm6sfq5f8A7n0BAHt/tFq0rP8A930BAHz8ZgFmXv8AAH4BABfsjIxRCv8ACX4BABjCv7+BLf8AEn4BAB1w39/Cff8AG34BAB409vbow/8AJH4BAHkm6sfq5f8ALX4BAHhfzYDNwf8ANn4BAHyllzWXj/8AP34BAHz8ZgFmXv8ASH4BABfsjIxRCv8AUX4BABjCv7+BLf8AWn4BAB1w39/Cff8AY34BAB409vbow/8AbH4BAAAA9fX19f8AdX4BAHkm6sfq5f8Afn4BAHhfzYDNwf8Ah34BAHyllzWXj/8AkH4BAHz8ZgFmXv8AmX4BAIcU+eX1+f8Aon4BAHVK2JnYyf8Aq34BAGe5oiyiX/8AtH4BAIgO++34+/8AvX4BAH824rLi4v8Axn4BAHF4wmbCpP8Az34BAGK+iyOLRf8A2H4BAIgO++34+/8A4X4BAH824rLi4v8A6n4BAHF4wmbCpP8A834BAGe5oiyiX/8A/H4BAGb/bQBtLP8ABX8BAIgO++34+/8ADn8BAHci7Mzs5v8AF38BAHVK2JnYyf8AIH8BAHF4wmbCpP8AKX8BAGe5oiyiX/8AMn8BAGb/bQBtLP8AO38BAIgO++34+/8ARH8BAHci7Mzs5v8ATX8BAHVK2JnYyf8AVn8BAHF4wmbCpP8AX38BAGmfrkGudv8AaH8BAGK+iyOLRf8AcX8BAGb/WABYJP8Aen8BAIYG/ff8/f8Ag38BAIcU+eX1+f8AjH8BAHci7Mzs5v8AlX8BAHVK2JnYyf8Ann8BAHF4wmbCpP8Ap38BAGmfrkGudv8AsH8BAGK+iyOLRf8AuX8BAGb/WABYJP8Awn8BAIYG/ff8/f8Ay38BAIcU+eX1+f8A1H8BAHci7Mzs5v8A3X8BAHVK2JnYyf8A5n8BAHF4wmbCpP8A738BAGmfrkGudv8A+H8BAGK+iyOLRf8AAYABAGb/bQBtLP8ACoABAGX/RABEG/8AE4ABAJAU9ODs9P8AHIABAJRG2p682v8AJYABAMR7p4hWp/8ALoABAIgO++34+/8AN4ABAJI147PN4/8AQIABAKJKxoyWxv8ASYABAMqVnYhBnf8AUoABAIgO++34+/8AW4ABAJI147PN4/8AZIABAKJKxoyWxv8AbYABAMR7p4hWp/8AdoABANbhgYEPfP8Af4ABAIgO++34+/8AiIABAJQr5r/T5v8AkYABAJRG2p682v8AmoABAKJKxoyWxv8Ao4ABAMR7p4hWp/8ArIABANbhgYEPfP8AtYABAIgO++34+/8AvoABAJQr5r/T5v8Ax4ABAJRG2p682v8A0IABAKJKxoyWxv8A2YABAL5ksYxrsf8A4oABAMqVnYhBnf8A64ABANX8bm4Ba/8A9IABAIYG/ff8/f8A/YABAJAU9ODs9P8ABoEBAJQr5r/T5v8AD4EBAJRG2p682v8AGIEBAKJKxoyWxv8AIYEBAL5ksYxrsf8AKoEBAMqVnYhBnf8AM4EBANX8bm4Ba/8APIEBAIYG/ff8/f8ARYEBAJAU9ODs9P8AToEBAJQr5r/T5v8AV4EBAJRG2p682v8AYIEBAKJKxoyWxv8AaYEBAL5ksYxrsf8AcoEBAMqVnYhBnf8Ae4EBANbhgYEPfP8AhIEBANX/TU0AS/8AjYEBAHLTnhued/8Al4EBABL82dlfAv8AoYEBAK1fs3Vws/8Aq4EBAHLTnhued/8AtYEBABL82dlfAv8Av4EBAK1fs3Vws/8AyYEBAOnR5+cpiv8A04EBAHLTnhued/8A3YEBABL82dlfAv8A54EBAK1fs3Vws/8A8YEBAOnR5+cpiv8A+4EBAD7QpmamHv8ABYIBAHLTnhued/8AD4IBABL82dlfAv8AGYIBAK1fs3Vws/8AI4IBAOnR5+cpiv8ALYIBAD7QpmamHv8AN4IBAB/85uarAv8AQYIBAHLTnhued/8AS4IBABL82dlfAv8AVYIBAK1fs3Vws/8AX4IBAOnR5+cpiv8AaYIBAD7QpmamHv8Ac4IBAB/85uarAv8AfYIBABvSpqZ2Hf8Ah4IBAHLTnhued/8AkYIBABL82dlfAv8Am4IBAK1fs3Vws/8ApYIBAOnR5+cpiv8Ar4IBAD7QpmamHv8AuYIBAB/85uarAv8Aw4IBABvSpqZ2Hf8AzYIBAAAAZmZmZv8A14IBAEwZ8+Dz2/8A4IIBAF893ajdtf8A6YIBAIyqykOiyv8A8oIBAEER+fD56P8A+4IBAFcu5LrkvP8ABIMBAHtlzHvMxP8ADYMBAI3FviuMvv8AFoMBAEER+fD56P8AH4MBAFcu5LrkvP8AKIMBAHtlzHvMxP8AMYMBAIyqykOiyv8AOoMBAJHzrAhorP8AQ4MBAEER+fD56P8ATIMBAE0p68zrxf8AVYMBAF893ajdtf8AXoMBAHtlzHvMxP8AZ4MBAIyqykOiyv8AcIMBAJHzrAhorP8AeYMBAEER+fD56P8AgoMBAE0p68zrxf8Ai4MBAF893ajdtf8AlIMBAHtlzHvMxP8AnYMBAImg006z0/8ApoMBAI3FviuMvv8Ar4MBAJPynghYnv8AuIMBADwM/Pf88P8AwYMBAEwZ8+Dz2/8AyoMBAE0p68zrxf8A04MBAF893ajdtf8A3IMBAHtlzHvMxP8A5YMBAImg006z0/8A7oMBAI3FviuMvv8A94MBAJPynghYnv8AAIQBADwM/Pf88P8ACYQBAEwZ8+Dz2/8AEoQBAE0p68zrxf8AG4QBAF893ajdtf8AJIQBAHtlzHvMxP8ALYQBAImg006z0/8ANoQBAI3FviuMvv8AP4QBAJHzrAhorP8ASIQBAJbvgQhAgf8AUYQBAEoV9eX14P8AXIQBAFBI2aHZm/8AZ4QBAGKyozGjVP8AcoQBAEkP+O346f8AfYQBAE425Lrks/8AiIQBAFZoxHTEdv8Ak4QBAGK+iyOLRf8AnoQBAEkP+O346f8AqYQBAE425Lrks/8AtIQBAFZoxHTEdv8Av4QBAGKyozGjVP8AyoQBAGb/bQBtLP8A1YQBAEkP+O346f8A4IQBAE0s6cfpwP8A64QBAFBI2aHZm/8A9oQBAFZoxHTEdv8AAYUBAGKyozGjVP8ADIUBAGb/bQBtLP8AF4UBAEkP+O346f8AIoUBAE0s6cfpwP8ALYUBAFBI2aHZm/8AOIUBAFZoxHTEdv8AQ4UBAGCeq0GrXf8AToUBAGK+iyOLRf8AWYUBAGz/WgBaMv8AZIUBAEgH/Pf89f8Ab4UBAEoV9eX14P8AeoUBAE0s6cfpwP8AhYUBAFBI2aHZm/8AkIUBAFZoxHTEdv8Am4UBAGCeq0GrXf8ApoUBAGK+iyOLRf8AsYUBAGz/WgBaMv8AvIUBAEgH/Pf89f8Ax4UBAEoV9eX14P8A0oUBAE0s6cfpwP8A3YUBAFBI2aHZm/8A6IUBAFZoxHTEdv8A84UBAGCeq0GrXf8A/oUBAGK+iyOLRf8ACYYBAGb/bQBtLP8AFIYBAGX/RABEG/8AH4YBAAAA8PDw8P8AKYYBAAAAvb29vf8AM4YBAAAAY2NjY/8APYYBAAAA9/f39/8AR4YBAAAAzMzMzP8AUYYBAAAAlpaWlv8AW4YBAAAAUlJSUv8AZYYBAAAA9/f39/8Ab4YBAAAAzMzMzP8AeYYBAAAAlpaWlv8Ag4YBAAAAY2NjY/8AjYYBAAAAJSUlJf8Al4YBAAAA9/f39/8AoYYBAAAA2dnZ2f8Aq4YBAAAAvb29vf8AtYYBAAAAlpaWlv8Av4YBAAAAY2NjY/8AyYYBAAAAJSUlJf8A04YBAAAA9/f39/8A3YYBAAAA2dnZ2f8A54YBAAAAvb29vf8A8YYBAAAAlpaWlv8A+4YBAAAAc3Nzc/8ABYcBAAAAUlJSUv8AD4cBAAAAJSUlJf8AGYcBAAAA//////8AI4cBAAAA8PDw8P8ALYcBAAAA2dnZ2f8AN4cBAAAAvb29vf8AQYcBAAAAlpaWlv8AS4cBAAAAc3Nzc/8AVYcBAAAAUlJSUv8AX4cBAAAAJSUlJf8AaYcBAAAA//////8Ac4cBAAAA8PDw8P8AfYcBAAAA2dnZ2f8Ah4cBAAAAvb29vf8AkYcBAAAAlpaWlv8Am4cBAAAAc3Nzc/8ApYcBAAAAUlJSUv8Ar4cBAAAAJSUlJf8AuYcBAAAAAAAAAP8Aw4cBABUw/v7mzv8Az4cBABOT/f2ua/8A24cBAA7w5uZVDf8A54cBABMg/v7t3v8A84cBABR4/f2+hf8A/4cBABHC/f2NPP8AC4gBAA392dlHAf8AF4gBABMg/v7t3v8AI4gBABR4/f2+hf8AL4gBABHC/f2NPP8AO4gBAA7w5uZVDf8AR4gBAA36pqY2A/8AU4gBABMg/v7t3v8AX4gBABVb/f3Qov8Aa4gBABOT/f2ua/8Ad4gBABHC/f2NPP8Ag4gBAA7w5uZVDf8Aj4gBAA36pqY2A/8Am4gBABMg/v7t3v8Ap4gBABVb/f3Qov8As4gBABOT/f2ua/8Av4gBABHC/f2NPP8Ay4gBABDq8fFpE/8A14gBAA392dlIAf8A44gBAAz3jIwtBP8A74gBABUU///16/8A+4gBABUw/v7mzv8AB4kBABVb/f3Qov8AE4kBABOT/f2ua/8AH4kBABHC/f2NPP8AK4kBABDq8fFpE/8AN4kBAA392dlIAf8AQ4kBAAz3jIwtBP8AT4kBABUU///16/8AW4kBABUw/v7mzv8AZ4kBABVb/f3Qov8Ac4kBABOT/f2ua/8Af4kBABHC/f2NPP8Ai4kBABDq8fFpE/8Al4kBAA392dlIAf8Ao4kBAA36pqY2A/8Ar4kBAAz2f38nBP8Au4kBABk2/v7oyP8AxIkBABN5/f27hP8AzYkBAAXF4+NKM/8A1okBABol/v7w2f8A34kBABhz/f3Miv8A6IkBAA2k/PyNWf8A8YkBAAPa19cwH/8A+okBABol/v7w2f8AA4oBABhz/f3Miv8ADIoBAA2k/PyNWf8AFYoBAAXF4+NKM/8AHooBAAD/s7MAAP8AJ4oBABol/v7w2f8AMIoBABhf/f3Unv8AOYoBABN5/f27hP8AQooBAA2k/PyNWf8AS4oBAAXF4+NKM/8AVIoBAAD/s7MAAP8AXYoBABol/v7w2f8AZooBABhf/f3Unv8Ab4oBABN5/f27hP8AeIoBAA2k/PyNWf8AgYoBAAey7+9lSP8AiooBAAPa19cwH/8Ak4oBAAD/mZkAAP8AnIoBABgS///37P8ApYoBABk2/v7oyP8ArooBABhf/f3Unv8At4oBABN5/f27hP8AwIoBAA2k/PyNWf8AyYoBAAey7+9lSP8A0ooBAAPa19cwH/8A24oBAAD/mZkAAP8A5IoBABgS///37P8A7YoBABk2/v7oyP8A9ooBABhf/f3Unv8A/4oBABN5/f27hP8ACIsBAA2k/PyNWf8AEYsBAAey7+9lSP8AGosBAAPa19cwH/8AI4sBAAD/s7MAAP8ALIsBAAD/f38AAP8ANYsBAI5E46bO4/8AQYsBAL6Zmmo9mv8ATosBAJDTtB94tP8AWosBAEFh37Lfiv8AZosBAFK4oDOgLP8AcosBAABj+/uamf8AfosBAP7h4+MaHP8AiosBABeP/f2/b/8AlosBABX///9/AP8AoosBAMYq1sqy1v8ArosBAI5E46bO4/8AuosBAL6Zmmo9mv8Ax4sBACpm////mf8A1IsBAJDTtB94tP8A4IsBAEFh37Lfiv8A7IsBAFK4oDOgLP8A+IsBAABj+/uamf8ABIwBAP7h4+MaHP8AEIwBABeP/f2/b/8AHIwBABX///9/AP8AKIwBAMYq1sqy1v8ANIwBAI5E46bO4/8AQIwBAL6Zmmo9mv8ATYwBACpm////mf8AWowBAA/FsbFZKP8AZ4wBAJDTtB94tP8Ac4wBAEFh37Lfiv8Af4wBAFK4oDOgLP8Ai4wBAABj+/uamf8Al4wBAP7h4+MaHP8Ao4wBABeP/f2/b/8Ar4wBABX///9/AP8Au4wBAMYq1sqy1v8Ax4wBAI5E46bO4/8A0owBAJDTtB94tP8A3YwBAEFh37Lfiv8A6IwBAI5E46bO4/8A84wBAJDTtB94tP8A/owBAEFh37Lfiv8ACY0BAFK4oDOgLP8AFI0BAI5E46bO4/8AH40BAJDTtB94tP8AKo0BAEFh37Lfiv8ANY0BAFK4oDOgLP8AQI0BAABj+/uamf8AS40BAI5E46bO4/8AVo0BAJDTtB94tP8AYY0BAEFh37Lfiv8AbI0BAFK4oDOgLP8Ad40BAABj+/uamf8Ago0BAP7h4+MaHP8AjY0BAI5E46bO4/8AmI0BAJDTtB94tP8Ao40BAEFh37Lfiv8Aro0BAFK4oDOgLP8AuY0BAABj+/uamf8AxI0BAP7h4+MaHP8Az40BABeP/f2/b/8A2o0BAI5E46bO4/8A5Y0BAJDTtB94tP8A8I0BAEFh37Lfiv8A+40BAFK4oDOgLP8ABo4BAABj+/uamf8AEY4BAP7h4+MaHP8AHI4BABeP/f2/b/8AJ44BABX///9/AP8AMo4BAI5E46bO4/8APY4BAJDTtB94tP8ASI4BAEFh37Lfiv8AU44BAFK4oDOgLP8AXo4BAABj+/uamf8AaY4BAP7h4+MaHP8AdI4BABeP/f2/b/8Af44BABX///9/AP8Aio4BAMYq1sqy1v8AlY4BAANO+/u0rv8AoY4BAJI147PN4/8ArY4BAE0p68zrxf8AuY4BAANO+/u0rv8AxY4BAJI147PN4/8A0Y4BAE0p68zrxf8A3Y4BAMob5N7L5P8A6Y4BAANO+/u0rv8A9Y4BAJI147PN4/8AAY8BAE0p68zrxf8ADY8BAMob5N7L5P8AGY8BABhY/v7Zpv8AJY8BAANO+/u0rv8AMY8BAJI147PN4/8APY8BAE0p68zrxf8ASY8BAMob5N7L5P8AVY8BABhY/v7Zpv8AYY8BACoy////zP8AbY8BAANO+/u0rv8AeY8BAJI147PN4/8AhY8BAE0p68zrxf8AkY8BAMob5N7L5P8AnY8BABhY/v7Zpv8AqY8BACoy////zP8AtY8BABws5eXYvf8AwY8BAANO+/u0rv8AzY8BAJI147PN4/8A2Y8BAE0p68zrxf8A5Y8BAMob5N7L5P8A8Y8BABhY/v7Zpv8A/Y8BACoy////zP8ACZABABws5eXYvf8AFZABAOkj/f3a7P8AIZABAANO+/u0rv8ALZABAJI147PN4/8AOZABAE0p68zrxf8ARZABAMob5N7L5P8AUZABABhY/v7Zpv8AXZABACoy////zP8AaZABABws5eXYvf8AdZABAOkj/f3a7P8AgZABAAAA8vLy8v8AjZABAGw14rPizf8AmZABABFR/f3NrP8ApZABAJsf6MvV6P8AsZABAGw14rPizf8AvZABABFR/f3NrP8AyZABAJsf6MvV6P8A1ZABAOQr9PTK5P8A4ZABAGw14rPizf8A7ZABABFR/f3NrP8A+ZABAJsf6MvV6P8ABZEBAOQr9PTK5P8AEZEBADgt9eb1yf8AHZEBAGw14rPizf8AKZEBABFR/f3NrP8ANZEBAJsf6MvV6P8AQZEBAOQr9PTK5P8ATZEBADgt9eb1yf8AWZEBACNR///yrv8AZZEBAGw14rPizf8AcZEBABFR/f3NrP8AfZEBAJsf6MvV6P8AiZEBAOQr9PTK5P8AlZEBADgt9eb1yf8AoZEBACNR///yrv8ArZEBABkn8fHizP8AuZEBAGw14rPizf8AxZEBABFR/f3NrP8A0ZEBAJsf6MvV6P8A3ZEBAOQr9PTK5P8A6ZEBADgt9eb1yf8A9ZEBACNR///yrv8AAZIBABkn8fHizP8ADZIBAAAAzMzMzP8AGZIBAOb9jo4BUv8AI5IBAE2/ZCdkGf8ALpIBAObcxcUbff8AOJIBAOh23t53rv8AQpIBAOU+8fG22v8ATJIBAOkd/f3g7/8AVpIBADsm9eb10P8AYJIBAD1n4bjhhv8AapIBAD+mvH+8Qf8AdJIBAETFkk2SIf8AfpIBAOb9jo4BUv8AiJIBAETFkk2SIf8Ak5IBAE2/ZCdkGf8AnpIBAObcxcUbff8AqJIBAOh23t53rv8AspIBAOU+8fG22v8AvJIBAOkd/f3g7/8AxpIBAAAA9/f39/8A0JIBADsm9eb10P8A2pIBAD1n4bjhhv8A5JIBAD+mvH+8Qf8A7pIBAOdM6emjyf8A95IBAAAA9/f39/8AAJMBAD+B16HXav8ACZMBAOTc0NAci/8AEpMBAOU+8fG22v8AG5MBAD1n4bjhhv8AJJMBAEjGrE2sJv8ALZMBAOTc0NAci/8ANpMBAOU+8fG22v8AP5MBAAAA9/f39/8ASJMBAD1n4bjhhv8AUZMBAEjGrE2sJv8AWpMBAObcxcUbff8AY5MBAOdM6emjyf8AbJMBAOkd/f3g7/8AdZMBADsm9eb10P8AfpMBAD+B16HXav8Ah5MBAETFkk2SIf8AkJMBAObcxcUbff8AmZMBAOdM6emjyf8AopMBAOkd/f3g7/8Aq5MBAAAA9/f39/8AtJMBADsm9eb10P8AvZMBAD+B16HXav8AxpMBAETFkk2SIf8Az5MBAObcxcUbff8A2JMBAOh23t53rv8A4ZMBAOU+8fG22v8A6pMBAOkd/f3g7/8A85MBADsm9eb10P8A/JMBAD1n4bjhhv8ABZQBAD+mvH+8Qf8ADpQBAETFkk2SIf8AF5QBAObcxcUbff8AIJQBAOh23t53rv8AKZQBAOU+8fG22v8AMpQBAOkd/f3g7/8AO5QBAAAA9/f39/8ARJQBADsm9eb10P8ATZQBAD1n4bjhhv8AVpQBAD+mvH+8Qf8AX5QBAETFkk2SIf8AaJQBAM7/S0AAS/8AcpQBAGX/RABEG/8AfZQBAM6tg3Yqg/8Ah5QBAMdXq5lwq/8AkZQBAMczz8Klz/8Am5QBANIV6OfU6P8ApZQBAEwe8Nnw0/8Ar5QBAFBE26bboP8AuZQBAFh7rlquYf8Aw5QBAGHFeBt4N/8AzZQBAM7/S0AAS/8A15QBAGHFeBt4N/8A4pQBAGX/RABEG/8A7ZQBAM6tg3Yqg/8A95QBAMdXq5lwq/8AAZUBAMczz8Klz/8AC5UBANIV6OfU6P8AFZUBAAAA9/f39/8AH5UBAEwe8Nnw0/8AKZUBAFBE26bboP8AM5UBAFh7rlquYf8APZUBAMRGw6+Nw/8ARpUBAAAA9/f39/8AT5UBAFJav3+/e/8AWJUBAMmolHsylP8AYZUBAMczz8Klz/8AapUBAFBE26bboP8Ac5UBAGb/iACIN/8AfJUBAMmolHsylP8AhZUBAMczz8Klz/8AjpUBAAAA9/f39/8Al5UBAFBE26bboP8AoJUBAGb/iACIN/8AqZUBAM6tg3Yqg/8AspUBAMRGw6+Nw/8Au5UBANIV6OfU6P8AxJUBAEwe8Nnw0/8AzZUBAFJav3+/e/8A1pUBAGHFeBt4N/8A35UBAM6tg3Yqg/8A6JUBAMRGw6+Nw/8A8ZUBANIV6OfU6P8A+pUBAAAA9/f39/8AA5YBAEwe8Nnw0/8ADJYBAFJav3+/e/8AFZYBAGHFeBt4N/8AHpYBAM6tg3Yqg/8AJ5YBAMdXq5lwq/8AMJYBAMczz8Klz/8AOZYBANIV6OfU6P8AQpYBAEwe8Nnw0/8AS5YBAFBE26bboP8AVJYBAFh7rlquYf8AXZYBAGHFeBt4N/8AZpYBAM6tg3Yqg/8Ab5YBAMdXq5lwq/8AeJYBAMczz8Klz/8AgZYBANIV6OfU6P8AipYBAAAA9/f39/8Ak5YBAEwe8Nnw0/8AnJYBAFBE26bboP8ApZYBAFh7rlquYf8ArpYBAGHFeBt4N/8At5YBAL0L8uzn8v8AwJYBAJc926a92/8AyZYBAI3FviuMvv8A0pYBALkI9vHu9v8A25YBAJso4b3J4f8A5JYBAJFwz3Spz/8A7ZYBAI/3sAVwsP8A9pYBALkI9vHu9v8A/5YBAJso4b3J4f8ACJcBAJFwz3Spz/8AEZcBAI3FviuMvv8AGpcBAI/3jQRajf8AI5cBALkI9vHu9v8ALJcBAKgY5tDR5v8ANZcBAJc926a92/8APpcBAJFwz3Spz/8AR5cBAI3FviuMvv8AUJcBAI/3jQRajf8AWZcBALkI9vHu9v8AYpcBAKgY5tDR5v8Aa5cBAJc926a92/8AdJcBAJFwz3Spz/8AfZcBAI63wDaQwP8AhpcBAI/3sAVwsP8Aj5cBAI/4ewNOe/8AmJcBAOkI///3+/8AoZcBAL0L8uzn8v8AqpcBAKgY5tDR5v8As5cBAJc926a92/8AvJcBAJFwz3Spz/8AxZcBAI63wDaQwP8AzpcBAI/3sAVwsP8A15cBAI/4ewNOe/8A4JcBAOkI///3+/8A6ZcBAL0L8uzn8v8A8pcBAKgY5tDR5v8A+5cBAJc926a92/8ABJgBAJFwz3Spz/8ADZgBAI63wDaQwP8AFpgBAI/3sAVwsP8AH5gBAI/3jQRajf8AKJgBAI/5WAI4WP8AMZgBAMgO8Ozi8P8APJgBAJc926a92/8AR5gBAILQmRyQmf8AUpgBAM8I9/bv9/8AXZgBAJso4b3J4f8AaJgBAI+Az2epz/8Ac5gBAIL7igKBiv8AfpgBAM8I9/bv9/8AiZgBAJso4b3J4f8AlJgBAI+Az2epz/8An5gBAILQmRyQmf8AqpgBAHf8bAFsWf8AtZgBAM8I9/bv9/8AwJgBAKgY5tDR5v8Ay5gBAJc926a92/8A1pgBAI+Az2epz/8A4ZgBAILQmRyQmf8A7JgBAHf8bAFsWf8A95gBAM8I9/bv9/8AApkBAKgY5tDR5v8ADZkBAJc926a92/8AGJkBAI+Az2epz/8AI5kBAI63wDaQwP8ALpkBAIL7igKBiv8AOZkBAHb8ZAFkUP8ARJkBAOkI///3+/8AT5kBAMgO8Ozi8P8AWpkBAKgY5tDR5v8AZZkBAJc926a92/8AcJkBAI+Az2epz/8Ae5kBAI63wDaQwP8AhpkBAIL7igKBiv8AkZkBAHb8ZAFkUP8AnJkBAOkI///3+/8Ap5kBAMgO8Ozi8P8AspkBAKgY5tDR5v8AvZkBAJc926a92/8AyJkBAI+Az2epz/8A05kBAI63wDaQwP8A3pkBAIL7igKBiv8A6ZkBAHf8bAFsWf8A9JkBAHX7RgFGNv8A/5kBABLuf387CP8ACZoBAMP/Sy0AS/8AFJoBABT2s7NYBv8AHpoBABbo4OCCFP8AKJoBABeb/f24Y/8AMpoBABhI/v7gtv8APJoBAKUU69ja6/8ARpoBALEv0rKr0v8AUJoBALNUrIBzrP8AWpoBAL21iFQniP8AZJoBABLuf387CP8AbpoBAL21iFQniP8AeZoBAMP/Sy0AS/8AhJoBABT2s7NYBv8AjpoBABbo4OCCFP8AmJoBABeb/f24Y/8AopoBABhI/v7gtv8ArJoBAAAA9/f39/8AtpoBAKUU69ja6/8AwJoBALEv0rKr0v8AypoBALNUrIBzrP8A1JoBABe78fGjQP8A3ZoBAAAA9/f39/8A5poBALJFw5mOw/8A75oBABH95uZhAf8A+JoBABeb/f24Y/8AAZsBALEv0rKr0v8ACpsBALmbmV48mf8AE5sBABH95uZhAf8AHJsBABeb/f24Y/8AJZsBAAAA9/f39/8ALpsBALEv0rKr0v8AN5sBALmbmV48mf8AQJsBABT2s7NYBv8ASZsBABe78fGjQP8AUpsBABhI/v7gtv8AW5sBAKUU69ja6/8AZJsBALJFw5mOw/8AbZsBAL21iFQniP8AdpsBABT2s7NYBv8Af5sBABe78fGjQP8AiJsBABhI/v7gtv8AkZsBAAAA9/f39/8AmpsBAKUU69ja6/8Ao5sBALJFw5mOw/8ArJsBAL21iFQniP8AtZsBABT2s7NYBv8AvpsBABbo4OCCFP8Ax5sBABeb/f24Y/8A0JsBABhI/v7gtv8A2ZsBAKUU69ja6/8A4psBALEv0rKr0v8A65sBALNUrIBzrP8A9JsBAL21iFQniP8A/ZsBABT2s7NYBv8ABpwBABbo4OCCFP8AD5wBABeb/f24Y/8AGJwBABhI/v7gtv8AIZwBAAAA9/f39/8AKpwBAKUU69ja6/8AM5wBALEv0rKr0v8APJwBALNUrIBzrP8ARZwBAL21iFQniP8ATpwBALwO7+fh7/8AV5wBANZDycmUx/8AYJwBAOre3d0cd/8AaZwBALkI9vHu9v8AcpwBANMp2Ne12P8Ae5wBAOSL399lsP8AhJwBAO/ozs4SVv8AjZwBALkI9vHu9v8AlpwBANMp2Ne12P8An5wBAOSL399lsP8AqJwBAOre3d0cd/8AsZwBAOz/mJgAQ/8AupwBALkI9vHu9v8Aw5wBAMwm2tS52v8AzJwBANZDycmUx/8A1ZwBAOSL399lsP8A3pwBAOre3d0cd/8A55wBAOz/mJgAQ/8A8JwBALkI9vHu9v8A+ZwBAMwm2tS52v8AAp0BANZDycmUx/8AC50BAOSL399lsP8AFJ0BAOnR5+cpiv8AHZ0BAO/ozs4SVv8AJp0BAOz/kZEAP/8AL50BAMMF+ff0+f8AOJ0BALwO7+fh7/8AQZ0BAMwm2tS52v8ASp0BANZDycmUx/8AU50BAOSL399lsP8AXJ0BAOnR5+cpiv8AZZ0BAO/ozs4SVv8Abp0BAOz/kZEAP/8Ad50BAMMF+ff0+f8AgJ0BALwO7+fh7/8AiZ0BAMwm2tS52v8Akp0BANZDycmUx/8Am50BAOSL399lsP8ApJ0BAOnR5+cpiv8ArZ0BAO/ozs4SVv8Atp0BAOz/mJgAQ/8Av50BAPL/Z2cAH/8AyJ0BALQI9e/t9f8A1J0BAKgl3Ly93P8A4J0BALBksXVrsf8A7J0BALYH9/Lw9/8A+J0BAK0c4svJ4v8ABJ4BAK06yJ6ayP8AEJ4BALaAo2pRo/8AHJ4BALYH9/Lw9/8AKJ4BAK0c4svJ4v8ANJ4BAK06yJ6ayP8AQJ4BALBksXVrsf8ATJ4BALy5j1Qnj/8AWJ4BALYH9/Lw9/8AZJ4BAKoS69ra6/8AcJ4BAKgl3Ly93P8AfJ4BAK06yJ6ayP8AiJ4BALBksXVrsf8AlJ4BALy5j1Qnj/8AoJ4BALYH9/Lw9/8ArJ4BAKoS69ra6/8AuJ4BAKgl3Ly93P8AxJ4BAK06yJ6ayP8A0J4BAKxTuoB9uv8A3J4BALaAo2pRo/8A6J4BAL7YhkoUhv8A9J4BAL8C/fz7/f8AAJ8BALQI9e/t9f8ADJ8BAKoS69ra6/8AGJ8BAKgl3Ly93P8AJJ8BAK06yJ6ayP8AMJ8BAKxTuoB9uv8APJ8BALaAo2pRo/8ASJ8BAL7YhkoUhv8AVJ8BAL8C/fz7/f8AYJ8BALQI9e/t9f8AbJ8BAKoS69ra6/8AeJ8BAKgl3Ly93P8AhJ8BAK06yJ6ayP8AkJ8BAKxTuoB9uv8AnJ8BALaAo2pRo/8AqJ8BALy5j1Qnj/8AtJ8BAL//fT8Aff8AwJ8BAPL/Z2cAH/8Ayp8BAJbxYQUwYf8A1Z8BAPncsrIYK/8A358BAAWj1tZgTf8A6Z8BAA139PSlgv8A858BAA82/f3bx/8A/Z8BAI4g8NHl8P8AB6ABAI1X3pLF3v8AEaABAI+nw0OTw/8AG6ABAJTOrCFmrP8AJaABAPL/Z2cAH/8AL6ABAJTOrCFmrP8AOqABAJbxYQUwYf8ARaABAPncsrIYK/8AT6ABAAWj1tZgTf8AWaABAA139PSlgv8AY6ABAA82/f3bx/8AbaABAAAA9/f39/8Ad6ABAI4g8NHl8P8AgaABAI1X3pLF3v8Ai6ABAI+nw0OTw/8AlaABAAyW7++KYv8AnqABAAAA9/f39/8Ap6ABAI+Az2epz/8AsKABAPj/ysoAIP8AuaABAA139PSlgv8AwqABAI1X3pLF3v8Ay6ABAI/3sAVxsP8A1KABAPj/ysoAIP8A3aABAA139PSlgv8A5qABAAAA9/f39/8A76ABAI1X3pLF3v8A+KABAI/3sAVxsP8AAaEBAPncsrIYK/8ACqEBAAyW7++KYv8AE6EBAA82/f3bx/8AHKEBAI4g8NHl8P8AJaEBAI+Az2epz/8ALqEBAJTOrCFmrP8AN6EBAPncsrIYK/8AQKEBAAyW7++KYv8ASaEBAA82/f3bx/8AUqEBAAAA9/f39/8AW6EBAI4g8NHl8P8AZKEBAI+Az2epz/8AbaEBAJTOrCFmrP8AdqEBAPncsrIYK/8Af6EBAAWj1tZgTf8AiKEBAA139PSlgv8AkaEBAA82/f3bx/8AmqEBAI4g8NHl8P8Ao6EBAI1X3pLF3v8ArKEBAI+nw0OTw/8AtaEBAJTOrCFmrP8AvqEBAPncsrIYK/8Ax6EBAAWj1tZgTf8A0KEBAA139PSlgv8A2aEBAA82/f3bx/8A4qEBAAAA9/f39/8A66EBAI4g8NHl8P8A9KEBAI1X3pLF3v8A/aEBAI+nw0OTw/8ABqIBAJTOrCFmrP8AD6IBAPL/Z2cAH/8AGaIBAAAAGhoaGv8AJKIBAPncsrIYK/8ALqIBAAWj1tZgTf8AOKIBAA139PSlgv8AQqIBAA82/f3bx/8ATKIBAAAA4ODg4P8AVqIBAAAAurq6uv8AYKIBAAAAh4eHh/8AaqIBAAAATU1NTf8AdKIBAPL/Z2cAH/8AfqIBAAAATU1NTf8AiaIBAAAAGhoaGv8AlKIBAPncsrIYK/8AnqIBAAWj1tZgTf8AqKIBAA139PSlgv8AsqIBAA82/f3bx/8AvKIBAAAA//////8AxqIBAAAA4ODg4P8A0KIBAAAAurq6uv8A2qIBAAAAh4eHh/8A5KIBAAyW7++KYv8A7aIBAAAA//////8A9qIBAAAAmZmZmf8A/6IBAPj/ysoAIP8ACKMBAA139PSlgv8AEaMBAAAAurq6uv8AGqMBAAAAQEBAQP8AI6MBAPj/ysoAIP8ALKMBAA139PSlgv8ANaMBAAAA//////8APqMBAAAAurq6uv8AR6MBAAAAQEBAQP8AUKMBAPncsrIYK/8AWaMBAAyW7++KYv8AYqMBAA82/f3bx/8Aa6MBAAAA4ODg4P8AdKMBAAAAmZmZmf8AfaMBAAAATU1NTf8AhqMBAPncsrIYK/8Aj6MBAAyW7++KYv8AmKMBAA82/f3bx/8AoaMBAAAA//////8AqqMBAAAA4ODg4P8As6MBAAAAmZmZmf8AvKMBAAAATU1NTf8AxaMBAPncsrIYK/8AzqMBAAWj1tZgTf8A16MBAA139PSlgv8A4KMBAA82/f3bx/8A6aMBAAAA4ODg4P8A8qMBAAAAurq6uv8A+6MBAAAAh4eHh/8ABKQBAAAATU1NTf8ADaQBAPncsrIYK/8AFqQBAAWj1tZgTf8AH6QBAA139PSlgv8AKKQBAA82/f3bx/8AMaQBAAAA//////8AOqQBAAAA4ODg4P8AQ6QBAAAAurq6uv8ATKQBAAAAh4eHh/8AVaQBAAAATU1NTf8AXqQBAAMg/f3g3f8AZ6QBAPRc+vqftf8AcKQBAOPcxcUbiv8AeaQBAA0c/v7r4v8AgqQBAPxI+/u0uf8Ai6QBAO6T9/doof8AlKQBAOD9rq4Bfv8AnaQBAA0c/v7r4v8ApqQBAPxI+/u0uf8Ar6QBAO6T9/doof8AuKQBAOPcxcUbiv8AwaQBANX8enoBd/8AyqQBAA0c/v7r4v8A06QBAAM8/PzFwP8A3KQBAPRc+vqftf8A5aQBAO6T9/doof8A7qQBAOPcxcUbiv8A96QBANX8enoBd/8AAKUBAA0c/v7r4v8ACaUBAAM8/PzFwP8AEqUBAPRc+vqftf8AG6UBAO6T9/doof8AJKUBAObD3d00l/8ALaUBAOD9rq4Bfv8ANqUBANX8enoBd/8AP6UBAA4M///38/8ASKUBAAMg/f3g3f8AUaUBAAM8/PzFwP8AWqUBAPRc+vqftf8AY6UBAO6T9/doof8AbKUBAObD3d00l/8AdaUBAOD9rq4Bfv8AfqUBANX8enoBd/8Ah6UBAA4M///38/8AkKUBAAMg/f3g3f8AmaUBAAM8/PzFwP8AoqUBAPRc+vqftf8Aq6UBAO6T9/doof8AtKUBAObD3d00l/8AvaUBAOD9rq4Bfv8AxqUBANX8enoBd/8Az6UBAMf/akkAav8A2KUBAPX/paUAJv8A5KUBAKerlTE2lf8A8aUBAALQ19cwJ/8A/aUBAAq49PRtQ/8ACaYBABSd/f2uYf8AFaYBAB5u/v7gkP8AIaYBAIgY+ODz+P8ALaYBAIpD6avZ6f8AOaYBAI9x0XSt0f8ARaYBAJedtEV1tP8AUaYBAPX/paUAJv8AXaYBAJedtEV1tP8AaqYBAKerlTE2lf8Ad6YBAALQ19cwJ/8Ag6YBAAq49PRtQ/8Aj6YBABSd/f2uYf8Am6YBAB5u/v7gkP8Ap6YBACpA////v/8As6YBAIgY+ODz+P8Av6YBAIpD6avZ6f8Ay6YBAI9x0XSt0f8A16YBAA2k/PyNWf8A4qYBACpA////v/8A7aYBAI9W25G/2/8A+KYBAP7h19cZHP8AA6cBABSd/f2uYf8ADqcBAIpD6avZ6f8AGacBAJHBtix7tv8AJKcBAP7h19cZHP8AL6cBABSd/f2uYf8AOqcBACpA////v/8ARacBAIpD6avZ6f8AUKcBAJHBtix7tv8AW6cBAALQ19cwJ/8AZqcBAA2k/PyNWf8AcacBAB5u/v7gkP8AfKcBAIgY+ODz+P8Ah6cBAI9W25G/2/8AkqcBAJedtEV1tP8AnacBAALQ19cwJ/8AqKcBAA2k/PyNWf8As6cBAB5u/v7gkP8AvqcBACpA////v/8AyacBAIgY+ODz+P8A1KcBAI9W25G/2/8A36cBAJedtEV1tP8A6qcBAALQ19cwJ/8A9acBAAq49PRtQ/8AAKgBABSd/f2uYf8AC6gBAB5u/v7gkP8AFqgBAIgY+ODz+P8AIagBAIpD6avZ6f8ALKgBAI9x0XSt0f8AN6gBAJedtEV1tP8AQqgBAALQ19cwJ/8ATagBAAq49PRtQ/8AWKgBABSd/f2uYf8AY6gBAB5u/v7gkP8AbqgBACpA////v/8AeagBAIgY+ODz+P8AhKgBAIpD6avZ6f8Aj6gBAI9x0XSt0f8AmqgBAJedtEV1tP8ApagBAPX/paUAJv8AsagBAGv/aABoN/8AvqgBAALQ19cwJ/8AyqgBAAq49PRtQ/8A1qgBABSd/f2uYf8A4qgBAB9z/v7gi/8A7qgBADNq79nvi/8A+qgBAD6C2abZav8ABqkBAFN5vWa9Y/8AEqkBAGfTmBqYUP8AHqkBAPX/paUAJv8AKqkBAGfTmBqYUP8AN6kBAGv/aABoN/8ARKkBAALQ19cwJ/8AUKkBAAq49PRtQ/8AXKkBABSd/f2uYf8AaKkBAB9z/v7gi/8AdKkBACpA////v/8AgKkBADNq79nvi/8AjKkBAD6C2abZav8AmKkBAFN5vWa9Y/8ApKkBAA2k/PyNWf8Ar6kBACpA////v/8AuqkBAEKIz5HPYP8AxakBAP7h19cZHP8A0KkBABSd/f2uYf8A26kBAD6C2abZav8A5qkBAGLSlhqWQf8A8akBAP7h19cZHP8A/KkBABSd/f2uYf8AB6oBACpA////v/8AEqoBAD6C2abZav8AHaoBAGLSlhqWQf8AKKoBAALQ19cwJ/8AM6oBAA2k/PyNWf8APqoBAB9z/v7gi/8ASaoBADNq79nvi/8AVKoBAEKIz5HPYP8AX6oBAGfTmBqYUP8AaqoBAALQ19cwJ/8AdaoBAA2k/PyNWf8AgKoBAB9z/v7gi/8Ai6oBACpA////v/8AlqoBADNq79nvi/8AoaoBAEKIz5HPYP8ArKoBAGfTmBqYUP8At6oBAALQ19cwJ/8AwqoBAAq49PRtQ/8AzaoBABSd/f2uYf8A2KoBAB9z/v7gi/8A46oBADNq79nvi/8A7qoBAD6C2abZav8A+aoBAFN5vWa9Y/8ABKsBAGfTmBqYUP8AD6sBAALQ19cwJ/8AGqsBAAq49PRtQ/8AJasBABSd/f2uYf8AMKsBAB9z/v7gi/8AO6sBACpA////v/8ARqsBADNq79nvi/8AUasBAD6C2abZav8AXKsBAFN5vWa9Y/8AZ6sBAGfTmBqYUP8AcqsBAA0s/v7g0v8Ae6sBAAmL/PyScv8AhKsBAAHT3t4tJv8AjasBAA0l/v7l2f8AlqsBAAts/Pyukf8An6sBAAez+/tqSv8AqKsBAP3gy8sYHf8AsasBAA0l/v7l2f8AuqsBAAts/Pyukf8Aw6sBAAez+/tqSv8AzKsBAAHT3t4tJv8A1asBAP3npaUPFf8A3qsBAA0l/v7l2f8A56sBAAxc/Py7of8A8KsBAAmL/PyScv8A+asBAAez+/tqSv8AAqwBAAHT3t4tJv8AC6wBAP3npaUPFf8AFKwBAA0l/v7l2f8AHawBAAxc/Py7of8AJqwBAAmL/PyScv8AL6wBAAez+/tqSv8AOKwBAAPQ7+87LP8AQawBAP3gy8sYHf8ASqwBAPv/mZkADf8AU6wBAA4P///18P8AXKwBAA0s/v7g0v8AZawBAAxc/Py7of8AbqwBAAmL/PyScv8Ad6wBAAez+/tqSv8AgKwBAAPQ7+87LP8AiawBAP3gy8sYHf8AkqwBAPv/mZkADf8Am6wBAA4P///18P8ApKwBAA0s/v7g0v8ArawBAAxc/Py7of8AtqwBAAmL/PyScv8Av6wBAAez+/tqSv8AyKwBAAPQ7+87LP8A0awBAP3gy8sYHf8A2qwBAP3npaUPFf8A46wBAPn/Z2cADf8A7KwBAP7h5OQaHP8A9awBAJKyuDd+uP8A/qwBAFOTr02vSv8AB60BAP7h5OQaHP8AEK0BAJKyuDd+uP8AGa0BAFOTr02vSv8AIq0BAM+Eo5hOo/8AK60BAP7h5OQaHP8ANK0BAJKyuDd+uP8APa0BAFOTr02vSv8ARq0BAM+Eo5hOo/8AT60BABX///9/AP8AWK0BAP7h5OQaHP8AYa0BAJKyuDd+uP8Aaq0BAFOTr02vSv8Ac60BAM+Eo5hOo/8AfK0BABX///9/AP8Aha0BACrM////M/8Ajq0BAP7h5OQaHP8Al60BAJKyuDd+uP8AoK0BAFOTr02vSv8Aqa0BAM+Eo5hOo/8Asq0BABX///9/AP8Au60BACrM////M/8AxK0BAA/BpqZWKP8Aza0BAP7h5OQaHP8A1q0BAJKyuDd+uP8A360BAFOTr02vSv8A6K0BAM+Eo5hOo/8A8a0BABX///9/AP8A+q0BACrM////M/8AA64BAA/BpqZWKP8ADK4BAOh59/eBv/8AFa4BAP7h5OQaHP8AHq4BAJKyuDd+uP8AJ64BAFOTr02vSv8AMK4BAM+Eo5hOo/8AOa4BABX///9/AP8AQq4BACrM////M/8AS64BAA/BpqZWKP8AVK4BAOh59/eBv/8AXa4BAAAAmZmZmf8AZq4BAHJ4wmbCpf8Ab64BAAub/PyNYv8AeK4BAJxNy42gy/8Aga4BAHJ4wmbCpf8Aiq4BAAub/PyNYv8Ak64BAJxNy42gy/8AnK4BAORm5+eKw/8Apa4BAHJ4wmbCpf8Arq4BAAub/PyNYv8At64BAJxNy42gy/8AwK4BAORm5+eKw/8Aya4BADqb2KbYVP8A0q4BAHJ4wmbCpf8A264BAAub/PyNYv8A5K4BAJxNy42gy/8A7a4BAORm5+eKw/8A9q4BADqb2KbYVP8A/64BACLQ///ZL/8ACK8BAHJ4wmbCpf8AEa8BAAub/PyNYv8AGq8BAJxNy42gy/8AI68BAORm5+eKw/8ALK8BADqb2KbYVP8ANa8BACLQ///ZL/8APq8BABla5eXElP8AR68BAHJ4wmbCpf8AUK8BAAub/PyNYv8AWa8BAJxNy42gy/8AYq8BAORm5+eKw/8Aa68BADqb2KbYVP8AdK8BACLQ///ZL/8Afa8BABla5eXElP8Ahq8BAAAAs7Ozs/8Aj68BAHhU043Tx/8Ama8BANNSvbyAvf8ApK8BACpM////s/8Arq8BAK8l2r662v8AuK8BAASL+/uAcv8Awq8BAJBk04Cx0/8AzK8BABac/f20Yv8A1q8BADqG3rPeaf8A4K8BAOkv/PzN5f8A6q8BAAAA2dnZ2f8A9K8BAHhU043Tx/8A/q8BANNSvbyAvf8ACbABAE0p68zrxf8AFLABACpM////s/8AHrABAK8l2r662v8AKLABAASL+/uAcv8AMrABAJBk04Cx0/8APLABABac/f20Yv8ARrABADqG3rPeaf8AULABAOkv/PzN5f8AWrABAAAA2dnZ2f8AZLABAHhU043Tx/8AbrABANNSvbyAvf8AebABAE0p68zrxf8AhLABACWQ///tb/8Aj7ABACpM////s/8AmbABAK8l2r662v8Ao7ABAASL+/uAcv8ArbABAJBk04Cx0/8At7ABABac/f20Yv8AwbABADqG3rPeaf8Ay7ABAOkv/PzN5f8A1bABAAAA2dnZ2f8A37ABAHhU043Tx/8A6LABACpM////s/8A8bABAK8l2r662v8A+rABAHhU043Tx/8AA7EBACpM////s/8ADLEBAK8l2r662v8AFbEBAASL+/uAcv8AHrEBAHhU043Tx/8AJ7EBACpM////s/8AMLEBAK8l2r662v8AObEBAASL+/uAcv8AQrEBAJBk04Cx0/8AS7EBAHhU043Tx/8AVLEBACpM////s/8AXbEBAK8l2r662v8AZrEBAASL+/uAcv8Ab7EBAJBk04Cx0/8AeLEBABac/f20Yv8AgbEBAHhU043Tx/8AirEBACpM////s/8Ak7EBAK8l2r662v8AnLEBAASL+/uAcv8ApbEBAJBk04Cx0/8ArrEBABac/f20Yv8At7EBADqG3rPeaf8AwLEBAHhU043Tx/8AybEBACpM////s/8A0rEBAK8l2r662v8A27EBAASL+/uAcv8A5LEBAJBk04Cx0/8A7bEBABac/f20Yv8A9rEBADqG3rPeaf8A/7EBAOkv/PzN5f8ACLIBAHhU043Tx/8AEbIBACpM////s/8AGrIBAK8l2r662v8AI7IBAASL+/uAcv8ALLIBAJBk04Cx0/8ANbIBABac/f20Yv8APrIBADqG3rPeaf8AR7IBAOkv/PzN5f8AULIBAAAA2dnZ2f8AWbIBAO39np4BQv8AZ7IBALGCol5Pov8AdrIBAPq01dU+T/8AhLIBAAq49PRtQ/8AkrIBABSd/f2uYf8AoLIBAB9z/v7gi/8ArrIBADFg9eb1mP8AvLIBAE9B3avdpP8AyrIBAHJ4wmbCpf8A2LIBAI+7vTKIvf8A5rIBAO39np4BQv8A9LIBAI+7vTKIvf8AA7MBALGCol5Pov8AErMBAPq01dU+T/8AILMBAAq49PRtQ/8ALrMBABSd/f2uYf8APLMBAB9z/v7gi/8ASrMBACpA////v/8AWLMBADFg9eb1mP8AZrMBAE9B3avdpP8AdLMBAHJ4wmbCpf8AgrMBAA2k/PyNWf8Aj7MBACpA////v/8AnLMBAFFN1ZnVlP8AqbMBAP7h19cZHP8AtrMBABSd/f2uYf8Aw7MBAE9B3avdpP8A0LMBAI/EuiuDuv8A3bMBAP7h19cZHP8A6rMBABSd/f2uYf8A97MBACpA////v/8ABLQBAE9B3avdpP8AEbQBAI/EuiuDuv8AHrQBAPq01dU+T/8AK7QBAA2k/PyNWf8AOLQBAB9z/v7gi/8ARbQBADFg9eb1mP8AUrQBAFFN1ZnVlP8AX7QBAI+7vTKIvf8AbLQBAPq01dU+T/8AebQBAA2k/PyNWf8AhrQBAB9z/v7gi/8Ak7QBACpA////v/8AoLQBADFg9eb1mP8ArbQBAFFN1ZnVlP8AurQBAI+7vTKIvf8Ax7QBAPq01dU+T/8A1LQBAAq49PRtQ/8A4bQBABSd/f2uYf8A7rQBAB9z/v7gi/8A+7QBADFg9eb1mP8ACLUBAE9B3avdpP8AFbUBAHJ4wmbCpf8AIrUBAI+7vTKIvf8AL7UBAPq01dU+T/8APLUBAAq49PRtQ/8ASbUBABSd/f2uYf8AVrUBAB9z/v7gi/8AY7UBACpA////v/8AcLUBADFg9eb1mP8AfbUBAE9B3avdpP8AirUBAHJ4wmbCpf8Al7UBAI+7vTKIvf8ApLUBAJMP//D4//8As7UBABgj+vrr1/8AxbUBAH///wD///8Az7UBAHGA/3//1P8A37UBAH8P//D///8A6rUBACoa9fX13P8A9bUBABc6///kxP8AAbYBAAAAAAAAAP8ADLYBABkx///rzf8AILYBAKr//wAA//8AKrYBAMDO4oor4v8AOrYBAAC+paUqKv8ARbYBABdj3t64h/8AVLYBAIBnoF+eoP8AY7YBAD///3//AP8Ac7YBABHa0tJpHv8AgrYBAAuv//9/UP8AjbYBAJqT7WSV7f8AobYBACEi///43P8Ar7YBAPbn3NwUPP8AvLYBAH///wD///8AxrYBAKr/iwAAi/8A1LYBAH//iwCLi/8A4rYBAB7vuLiGC/8A9bYBAAAAqampqf8AA7cBAFX/ZABkAP8AErcBAAAAqampqf8AILcBACduvb23a/8AL7cBANT/i4sAi/8AQLcBADqOa1VrL/8AVLcBABf///+MAP8AZLcBAMbAzJkyzP8AdLcBAAD/i4sAAP8AgbcBAAp56emWev8AkbcBAFU9vI+8j/8Ao7cBAK+Pi0g9i/8AtrcBAH9nTy9PT/8AybcBAH9nTy9PT/8A3LcBAID/0QDO0f8A77cBAMf/05QA0/8A/7cBAOjr//8Uk/8ADbgBAIr//wC///8AHrgBAAAAaWlpaf8AK7gBAAAAaWlpaf8AOLgBAJTh/x6Q//8ASLgBAADOsrIiIv8AV7gBABwP///68P8AaLgBAFXAiyKLIv8AebgBANT///8A//8AhrgBAAAA3Nzc3P8AlbgBAKoH//j4//8ApbgBACP////XAP8Ar7gBAB7Z2tqlIP8AvrgBAAAAgICAgP8AyLgBAFX/gACAAP8A07gBADvQ/63/L/8A5LgBAAAAgICAgP8A7rgBAFUP//D/8P8A/LgBAOmW//9ptP8ACbkBAACMzc1cXP8AGLkBAML/gksAgv8AJLkBACoP////8P8AL7kBACZq8PDmjP8AOrkBAKoU+ubm+v8ASLkBAPAP///w9f8AW7kBAED//Hz8AP8AarkBACYx///6zf8AfLkBAIk/5q3Y5v8Ai7kBAAB38PCAgP8Am7kBAH8f/+D///8AqrkBACoo+vr60v8AxLkBAAAA09PT0/8A07kBAFVk7pDukP8A47kBAAAA09PT0/8A8rkBAPhJ//+2wf8AAboBAAyE//+gev8AEroBAH3RsiCyqv8AJboBAI91+ofO+v8AN7oBAJQ4mXeImf8AS7oBAJQ4mXeImf8AX7oBAJc03rDE3v8Ac7oBACof////4P8AhLoBAFX//wD/AP8AjroBAFXAzTLNMv8AnboBABUU+vrw5v8AqLoBANT///8A//8AtboBAAD/gIAAAP8AwboBAHGAzWbNqv8A17oBAKr/zQAAzf8A57oBAMyY07pV0/8A+boBALd825Nw2/8AC7sBAGepszyzcf8AH7sBALCP7nto7v8ANLsBAG//+gD6mv8AS7sBAH2n0UjRzP8AYLsBAOTkx8cVhf8AdbsBAKrGcBkZcP8Ah7sBAGoJ//X/+v8AlrsBAAQe///k4f8ApbsBABpJ///ktf8As7sBABlR///erf8AxLsBAKr/gAAAgP8AzrsBABsX/f315v8A27sBACr/gICAAP8A5rsBADjAjmuOI/8A9bsBABv///+lAP8AAbwBAAv///9FAP8AELwBANZ72tpw1v8AHLwBACZI7u7oqv8AL7wBAFVk+5j7mP8APrwBAH9D7q/u7v8AUbwBAPF829twk/8AZLwBABop///v1f8AdLwBABRG///auf8Ag7wBABSwzc2FP/8AjbwBAPc////Ay/8Al7wBANRG3d2g3f8AobwBAIQ75rDg5v8AsbwBANT/gIAAgP8AvbwBAAD///8AAP8AxrwBAAA9vLyPj/8A1bwBAJ+14UFp4f8A5LwBABHci4tFE/8A9bwBAASK+vqAcv8AAb0BABOa9PSkYP8AEb0BAGeqiy6LV/8AH70BABEQ///17v8ALb0BAA23oKBSLf8AOb0BAAAAwMDAwP8ARb0BAIts64fO6/8AUr0BAK+PzWpazf8AYb0BAJQ4kHCAkP8AcL0BAJQ4kHCAkP8Af70BAAAF///6+v8Aib0BAGr//wD/f/8Amr0BAJKbtEaCtP8Aqb0BABhU0tK0jP8Asr0BAH//gACAgP8AvL0BANQd2Ni/2P8Ayb0BAAa4//9jR/8A1b0BAHu24EDg0P8A5L0BANRz7u6C7v8A8L0BABtE9fXes/8A+70BAAAA//////8ABr4BAAAA9fX19f8AFr4BACr/////AP8AIr4BADjAzZrNMv8AM74BAC1D/Pf8uf8APL4BAERb3a3djv8ARb4BAGKyozGjVP8ATr4BACoy////zP8AV74BAD5V5sLmmf8AYL4BAFVkxnjGef8Aab4BAGO7hCOEQ/8Acr4BACoy////zP8Ae74BAD5V5sLmmf8AhL4BAFVkxnjGef8Ajb4BAGKyozGjVP8Alr4BAGv/aABoN/8An74BACoy////zP8AqL4BADdR8Nnwo/8Asb4BAERb3a3djv8Aur4BAFVkxnjGef8Aw74BAGKyozGjVP8AzL4BAGv/aABoN/8A1b4BACoy////zP8A3r4BADdR8Nnwo/8A574BAERb3a3djv8A8L4BAFVkxnjGef8A+b4BAGCeq0GrXf8AAr8BAGO7hCOEQ/8AC78BAGz/WgBaMv8AFL8BACoZ////5f8AHb8BAC1D/Pf8uf8AJr8BADdR8Nnwo/8AL78BAERb3a3djv8AOL8BAFVkxnjGef8AQb8BAGCeq0GrXf8ASr8BAGO7hCOEQ/8AU78BAGz/WgBaMv8AXL8BACoZ////5f8AZb8BAC1D/Pf8uf8Abr8BADdR8Nnwo/8Ad78BAERb3a3djv8AgL8BAFVkxnjGef8Aib8BAGCeq0GrXf8Akr8BAGO7hCOEQ/8Am78BAGv/aABoN/8ApL8BAG7/RQBFKf8Arb8BADFJ+O34sf8AuL8BAHVhzX/Nu/8Aw78BAJDCuCx/uP8Azr8BACoy////zP8A2b8BAGNC2qHatP8A5L8BAISqxEG2xP8A778BAJbLqCJeqP8A+r8BACoy////zP8ABcABAGNC2qHatP8AEMABAISqxEG2xP8AG8ABAJDCuCx/uP8AJsABAKS/lCU0lP8AMcABACoy////zP8APMABAEU66cfptP8AR8ABAHVhzX/Nu/8AUsABAISqxEG2xP8AXcABAJDCuCx/uP8AaMABAKS/lCU0lP8Ac8ABACoy////zP8AfsABAEU66cfptP8AicABAHVhzX/Nu/8AlMABAISqxEG2xP8An8ABAIvYwB2RwP8AqsABAJbLqCJeqP8AtcABAJ7nhAwshP8AwMABACom////2f8Ay8ABADFJ+O34sf8A1sABAEU66cfptP8A4cABAHVhzX/Nu/8A7MABAISqxEG2xP8A98ABAIvYwB2RwP8AAsEBAJbLqCJeqP8ADcEBAJ7nhAwshP8AGMEBACom////2f8AI8EBADFJ+O34sf8ALsEBAEU66cfptP8AOcEBAHVhzX/Nu/8ARMEBAISqxEG2xP8AT8EBAIvYwB2RwP8AWsEBAJbLqCJeqP8AZcEBAKS/lCU0lP8AcMEBAJ7nWAgdWP8Ae8EBACVC///3vP8AhsEBAByv/v7ET/8AkcEBABDu2dlfDv8AnMEBACoq////1P8Ap8EBABxw/v7Zjv8AssEBABbV/v6ZKf8AvcEBAA/8zMxMAv8AyMEBACoq////1P8A08EBABxw/v7Zjv8A3sEBABbV/v6ZKf8A6cEBABDu2dlfDv8A9MEBAA34mZk0BP8A/8EBACoq////1P8ACsIBAB9t/v7jkf8AFcIBAByv/v7ET/8AIMIBABbV/v6ZKf8AK8IBABDu2dlfDv8ANsIBAA34mZk0BP8AQcIBACoq////1P8ATMIBAB9t/v7jkf8AV8IBAByv/v7ET/8AYsIBABbV/v6ZKf8AbcIBABLp7OxwFP8AeMIBAA/8zMxMAv8Ag8IBAAz3jIwtBP8AjsIBACoZ////5f8AmcIBACVC///3vP8ApMIBAB9t/v7jkf8Ar8IBAByv/v7ET/8AusIBABbV/v6ZKf8AxcIBABLp7OxwFP8A0MIBAA/8zMxMAv8A28IBAAz3jIwtBP8A5sIBACoZ////5f8A8cIBACVC///3vP8A/MIBAB9t/v7jkf8AB8MBAByv/v7ET/8AEsMBABbV/v6ZKf8AHcMBABLp7OxwFP8AKMMBAA/8zMxMAv8AM8MBAA34mZk0BP8APsMBAA3wZmYlBv8AScMBACJf///toP8AVMMBABiy/v6yTP8AX8MBAAXd8PA7IP8AasMBACpN////sv8AdcMBAB2i/v7MXP8AgMMBABHC/f2NPP8Ai8MBAP7h4+MaHP8AlsMBACpN////sv8AocMBAB2i/v7MXP8ArMMBABHC/f2NPP8At8MBAAXd8PA7IP8AwsMBAPb/vb0AJv8AzcMBACpN////sv8A2MMBAB6I/v7Zdv8A48MBABiy/v6yTP8A7sMBABHC/f2NPP8A+cMBAAXd8PA7IP8ABMQBAPb/vb0AJv8AD8QBACpN////sv8AGsQBAB6I/v7Zdv8AJcQBABiy/v6yTP8AMMQBABHC/f2NPP8AO8QBAAfU/PxOKv8ARsQBAP7h4+MaHP8AUcQBAPX/sbEAJv8AXMQBACoy////zP8AZ8QBACJf///toP8AcsQBAB6I/v7Zdv8AfcQBABiy/v6yTP8AiMQBABHC/f2NPP8Ak8QBAAfU/PxOKv8AnsQBAP7h4+MaHP8AqcQBAPX/sbEAJv8AtMQBACoy////zP8Av8QBACJf///toP8AysQBAB6I/v7Zdv8A1cQBABiy/v6yTP8A4MQBABHC/f2NPP8A68QBAAfU/PxOKv8A9sQBAP7h4+MaHP8AAcUBAPb/vb0AJv8ADMUBAPL/gIAAJv8AF8UBAJMP//D4//8AIcUBABgj+vrr1/8ALsUBABck///v2/8APMUBABck7u7fzP8ASsUBABckzc3AsP8AWMUBABgii4uDeP8AZsUBAHGA/3//1P8AccUBAHGA/3//1P8AfcUBAHGA7nbuxv8AicUBAHGAzWbNqv8AlcUBAHGAi0WLdP8AocUBAH8P//D///8Ap8UBAH8P//D///8ArsUBAH8P7uDu7v8AtcUBAH8OzcHNzf8AvMUBAH8Oi4OLi/8Aw8UBACoa9fX13P8AycUBABc6///kxP8A0MUBABc6///kxP8A2MUBABc67u7Vt/8A4MUBABY6zc23nv8A6MUBABc6i4t9a/8A+twBAAAAAAAAAP8A8MUBABkx///rzf8A/8UBAKr//wAA//8ABMYBAKr//wAA//8ACsYBAKr/7gAA7v8AEMYBAKr/zQAAzf8AFsYBAKr/iwAAi/8AHMYBAMDO4oor4v8AJ8YBAAC+paUqKv8ALcYBAAC///9AQP8ANMYBAAC/7u47O/8AO8YBAAC/zc0zM/8AQsYBAAC+i4sjI/8AScYBABdj3t64h/8AU8YBABdk///Tm/8AXsYBABdj7u7Fkf8AacYBABdjzc2qff8AdMYBABdji4tzVf8Af8YBAIBnoF+eoP8AicYBAINn/5j1//8AlMYBAINm7o7l7v8An8YBAINnzXrFzf8AqsYBAINmi1OGi/8AtcYBAD///3//AP8AwMYBAD///3//AP8AzMYBAD//7nbuAP8A2MYBAD//zWbNAP8A5MYBAD//i0WLAP8A8MYBABHa0tJpHv8A+sYBABHb//9/JP8ABccBABHb7u52If8AEMcBABHazc1mHf8AG8cBABHci4tFE/8AJscBAAuv//9/UP8ALMcBAAep//9yVv8AM8cBAAap7u5qUP8AOscBAAapzc1bRf8AQccBAAaoi4s+L/8ASMcBAJqT7WSV7f8AV8cBACEi///43P8AYMcBACEi///43P8AascBACIj7u7ozf8AdMcBACIizc3Isf8AfscBACMii4uIeP8AiMcBAPbn3NwUPP8AkMcBAH///wD///8AlccBAH///wD///8Am8cBAH//7gDu7v8AoccBAH//zQDNzf8Ap8cBAH//iwCLi/8ArccBAB7vuLiGC/8Au8cBAB7w//+5D/8AyscBAB7w7u6tDv8A2ccBAB7wzc2VDP8A6McBAB7wi4tlCP8A98cBAFX/ZABkAP8AAcgBACduvb23a/8AC8gBADqOa1VrL/8AGsgBADqP/8r/cP8AKsgBADqP7rzuaP8AOsgBADqPzaLNWv8ASsgBADqPi26LPf8AWsgBABf///+MAP8AZcgBABX///9/AP8AccgBABX/7u52AP8AfcgBABX/zc1mAP8AicgBABX/i4tFAP8AlcgBAMbAzJkyzP8AoMgBAMbB/78+//8ArMgBAMbA7rI67v8AuMgBAMbAzZoyzf8AxMgBAMbAi2gii/8A0MgBAAp56emWev8A28gBAFU9vI+8j/8A6MgBAFU+/8H/wf8A9sgBAFU+7rTutP8ABMkBAFU+zZvNm/8AEskBAFU+i2mLaf8AIMkBAK+Pi0g9i/8ALskBAH9nTy9PT/8APMkBAH9o/5f///8AS8kBAH9n7o3u7v8AWskBAH9ozXnNzf8AackBAH9oi1KLi/8AeMkBAH9nTy9PT/8AhskBAID/0QDO0f8AlMkBAMf/05QA0/8An8kBAOjr//8Uk/8AqMkBAOjr//8Uk/8AsskBAOjr7u4Sif8AvMkBAOjrzc0Qdv8AxskBAOfsi4sKUP8A0MkBAIr//wC///8A3MkBAIr//wC///8A6ckBAIr/7gCy7v8A9skBAIr/zQCazf8AA8oBAIr/iwBoi/8AEMoBAAAAaWlpaf8AGMoBAAAAaWlpaf8AIMoBAJTh/x6Q//8AK8oBAJTh/x6Q//8AN8oBAJTh7hyG7v8AQ8oBAJThzRh0zf8AT8oBAJThixBOi/8AW8oBAADOsrIiIv8AZcoBAADP//8wMP8AcMoBAADP7u4sLP8Ae8oBAADPzc0mJv8AhsoBAADPi4saGv8AkcoBABwP///68P8AncoBAFXAiyKLIv8AqcoBAAAA3Nzc3P8As8oBAKoH//j4//8AvsoBACP////XAP8Aw8oBACP////XAP8AycoBACP/7u7JAP8Az8oBACP/zc2tAP8A1coBACP/i4t1AP8A28oBAB7Z2tqlIP8A5coBAB7a///BJf8A8MoBAB7a7u60Iv8A+8oBAB7azc2bHf8ABssBAB7ai4tpFP8AEcsBAAAAwMDAwP8AFssBAAAAAAAAAP8AHMsBAAAAAwMDA/8AIssBAAAAGhoaGv8AKcsBAAAA//////8AMcsBAAAAHBwcHP8AOMsBAAAAHx8fH/8AP8sBAAAAISEhIf8ARssBAAAAJCQkJP8ATcsBAAAAJiYmJv8AVMsBAAAAKSkpKf8AW8sBAAAAKysrK/8AYssBAAAALi4uLv8AacsBAAAAMDAwMP8AcMsBAAAABQUFBf8AdssBAAAAMzMzM/8AfcsBAAAANjY2Nv8AhMsBAAAAODg4OP8Ai8sBAAAAOzs7O/8AkssBAAAAPT09Pf8AmcsBAAAAQEBAQP8AoMsBAAAAQkJCQv8Ap8sBAAAARUVFRf8ArssBAAAAR0dHR/8AtcsBAAAASkpKSv8AvMsBAAAACAgICP8AwssBAAAATU1NTf8AycsBAAAAT09PT/8A0MsBAAAAUlJSUv8A18sBAAAAVFRUVP8A3ssBAAAAV1dXV/8A5csBAAAAWVlZWf8A7MsBAAAAXFxcXP8A88sBAAAAXl5eXv8A+ssBAAAAYWFhYf8AAcwBAAAAY2NjY/8ACMwBAAAACgoKCv8ADswBAAAAZmZmZv8AFcwBAAAAaWlpaf8AHMwBAAAAa2tra/8AI8wBAAAAbm5ubv8AKswBAAAAcHBwcP8AMcwBAAAAc3Nzc/8AOMwBAAAAdXV1df8AP8wBAAAAeHh4eP8ARswBAAAAenp6ev8ATcwBAAAAfX19ff8AVMwBAAAADQ0NDf8AWswBAAAAf39/f/8AYcwBAAAAgoKCgv8AaMwBAAAAhYWFhf8Ab8wBAAAAh4eHh/8AdswBAAAAioqKiv8AfcwBAAAAjIyMjP8AhMwBAAAAj4+Pj/8Ai8wBAAAAkZGRkf8AkswBAAAAlJSUlP8AmcwBAAAAlpaWlv8AoMwBAAAADw8PD/8ApswBAAAAmZmZmf8ArcwBAAAAnJycnP8AtMwBAAAAnp6env8Au8wBAAAAoaGhof8AwswBAAAAo6Ojo/8AycwBAAAApqampv8A0MwBAAAAqKioqP8A18wBAAAAq6urq/8A3swBAAAAra2trf8A5cwBAAAAsLCwsP8A7MwBAAAAEhISEv8A8swBAAAAs7Ozs/8A+cwBAAAAtbW1tf8AAM0BAAAAuLi4uP8AB80BAAAAurq6uv8ADs0BAAAAvb29vf8AFc0BAAAAv7+/v/8AHM0BAAAAwsLCwv8AI80BAAAAxMTExP8AKs0BAAAAx8fHx/8AMc0BAAAAycnJyf8AOM0BAAAAFBQUFP8APs0BAAAAzMzMzP8ARc0BAAAAz8/Pz/8ATM0BAAAA0dHR0f8AU80BAAAA1NTU1P8AWs0BAAAA1tbW1v8AYc0BAAAA2dnZ2f8AaM0BAAAA29vb2/8Ab80BAAAA3t7e3v8Ads0BAAAA4ODg4P8Afc0BAAAA4+Pj4/8AhM0BAAAAFxcXF/8Ais0BAAAA5eXl5f8Akc0BAAAA6Ojo6P8AmM0BAAAA6+vr6/8An80BAAAA7e3t7f8Aps0BAAAA8PDw8P8Arc0BAAAA8vLy8v8AtM0BAAAA9fX19f8Au80BAAAA9/f39/8Aws0BAAAA+vr6+v8Ayc0BAAAA/Pz8/P8A0M0BAFX//wD/AP8A1s0BAFX//wD/AP8A3c0BAFX/7gDuAP8A5M0BAFX/zQDNAP8A680BAFX/iwCLAP8A8s0BADvQ/63/L/8A/s0BAAAAwMDAwP8AA84BAAAAAAAAAP8ACc4BAAAAAwMDA/8AD84BAAAAGhoaGv8AFs4BAAAA//////8AHs4BAAAAHBwcHP8AJc4BAAAAHx8fH/8ALM4BAAAAISEhIf8AM84BAAAAJCQkJP8AOs4BAAAAJiYmJv8AQc4BAAAAKSkpKf8ASM4BAAAAKysrK/8AT84BAAAALi4uLv8AVs4BAAAAMDAwMP8AXc4BAAAABQUFBf8AY84BAAAAMzMzM/8Aas4BAAAANjY2Nv8Acc4BAAAAODg4OP8AeM4BAAAAOzs7O/8Af84BAAAAPT09Pf8Ahs4BAAAAQEBAQP8Ajc4BAAAAQkJCQv8AlM4BAAAARUVFRf8Am84BAAAAR0dHR/8Aos4BAAAASkpKSv8Aqc4BAAAACAgICP8Ar84BAAAATU1NTf8Ats4BAAAAT09PT/8Avc4BAAAAUlJSUv8AxM4BAAAAVFRUVP8Ay84BAAAAV1dXV/8A0s4BAAAAWVlZWf8A2c4BAAAAXFxcXP8A4M4BAAAAXl5eXv8A584BAAAAYWFhYf8A7s4BAAAAY2NjY/8A9c4BAAAACgoKCv8A+84BAAAAZmZmZv8AAs8BAAAAaWlpaf8ACc8BAAAAa2tra/8AEM8BAAAAbm5ubv8AF88BAAAAcHBwcP8AHs8BAAAAc3Nzc/8AJc8BAAAAdXV1df8ALM8BAAAAeHh4eP8AM88BAAAAenp6ev8AOs8BAAAAfX19ff8AQc8BAAAADQ0NDf8AR88BAAAAf39/f/8ATs8BAAAAgoKCgv8AVc8BAAAAhYWFhf8AXM8BAAAAh4eHh/8AY88BAAAAioqKiv8Aas8BAAAAjIyMjP8Acc8BAAAAj4+Pj/8AeM8BAAAAkZGRkf8Af88BAAAAlJSUlP8Ahs8BAAAAlpaWlv8Ajc8BAAAADw8PD/8Ak88BAAAAmZmZmf8Ams8BAAAAnJycnP8Aoc8BAAAAnp6env8AqM8BAAAAoaGhof8Ar88BAAAAo6Ojo/8Ats8BAAAApqampv8Avc8BAAAAqKioqP8AxM8BAAAAq6urq/8Ay88BAAAAra2trf8A0s8BAAAAsLCwsP8A2c8BAAAAEhISEv8A388BAAAAs7Ozs/8A5s8BAAAAtbW1tf8A7c8BAAAAuLi4uP8A9M8BAAAAurq6uv8A+88BAAAAvb29vf8AAtABAAAAv7+/v/8ACdABAAAAwsLCwv8AENABAAAAxMTExP8AF9ABAAAAx8fHx/8AHtABAAAAycnJyf8AJdABAAAAFBQUFP8AK9ABAAAAzMzMzP8AMtABAAAAz8/Pz/8AOdABAAAA0dHR0f8AQNABAAAA1NTU1P8AR9ABAAAA1tbW1v8ATtABAAAA2dnZ2f8AVdABAAAA29vb2/8AXNABAAAA3t7e3v8AY9ABAAAA4ODg4P8AatABAAAA4+Pj4/8AcdABAAAAFxcXF/8Ad9ABAAAA5eXl5f8AftABAAAA6Ojo6P8AhdABAAAA6+vr6/8AjNABAAAA7e3t7f8Ak9ABAAAA8PDw8P8AmtABAAAA8vLy8v8AodABAAAA9fX19f8AqNABAAAA9/f39/8Ar9ABAAAA+vr6+v8AttABAAAA/Pz8/P8AvdABAFUP//D/8P8AxtABAFUP//D/8P8A0NABAFUP7uDu4P8A2tABAFUOzcHNwf8A5NABAFUOi4OLg/8A7tABAOmW//9ptP8A9tABAOqR//9utP8A/9ABAOuN7u5qp/8ACNEBAOyHzc1gkP8AEdEBAOqUi4s6Yv8AGtEBAACMzc1cXP8AJNEBAACU//9qav8AL9EBAACU7u5jY/8AOtEBAACVzc1VVf8ARdEBAACUi4s6Ov8AUNEBAML/gksAgv8AV9EBACoA/////gAAXdEBACoP////8P8AY9EBACoP////8P8AatEBACoP7u7u4P8AcdEBACoOzc3Nwf8AeNEBACoOi4uLg/8Af9EBACZq8PDmjP8AhdEBACdw///2j/8AjNEBACdw7u7mhf8Ak9EBACdvzc3Gc/8AmtEBACdvi4uGTv8AodEBAKoU+ubm+v8AqtEBAPAP///w9f8AuNEBAPAP///w9f8Ax9EBAO8P7u7g5f8A1tEBAPAOzc3Bxf8A5dEBAO8Oi4uDhv8A9NEBAED//Hz8AP8A/tEBACYx///6zf8AC9IBACYx///6zf8AGdIBACUy7u7pv/8AJ9IBACYxzc3Jpf8ANdIBACcxi4uJcP8AQ9IBAIk/5q3Y5v8ATdIBAIpA/7/v//8AWNIBAIpA7rLf7v8AY9IBAIo/zZrAzf8AbtIBAIlAi2iDi/8AedIBAAB38PCAgP8AhNIBAH8f/+D///8AjtIBAH8f/+D///8AmdIBAH8f7tHu7v8ApNIBAH8fzbTNzf8Ar9IBAH8fi3qLi/8AutIBACNz7u7dgv8AydIBACN0///si/8A2dIBACNz7u7cgv8A6dIBACNzzc2+cP8A+dIBACNzi4uBTP8ACdMBACoo+vr60v8AHtMBAAAA09PT0/8AKNMBAAAA09PT0/8AMtMBAPhJ//+2wf8APNMBAPlR//+uuf8AR9MBAPhR7u6irf8AUtMBAPlQzc2Mlf8AXdMBAPlQi4tfZf8AaNMBAAyE//+gev8AdNMBAAyE//+gev8AgdMBAAuE7u6Vcv8AjtMBAAyFzc2BYv8Am9MBAAyFi4tXQv8AqNMBAH3RsiCyqv8AttMBAI91+ofO+v8Aw9MBAI9P/7Di//8A0dMBAI9P7qTT7v8A39MBAI5PzY22zf8A7dMBAI9Oi2B7i/8A+9MBAK+P/4Rw//8ACtQBAJQ4mXeImf8AGdQBAJQ4mXeImf8AKNQBAJc03rDE3v8AN9QBAJc1/8rh//8AR9QBAJc17rzS7v8AV9QBAJc1zaK1zf8AZ9QBAJY1i257i/8Ad9QBACof////4P8Ag9QBACof////4P8AkNQBACof7u7u0f8AndQBACofzc3NtP8AqtQBACofi4uLev8At9QBAFXAzTLNMv8AwdQBABUU+vrw5v8Ax9QBANT///8A//8Az9QBANT///8A//8A2NQBANT/7u4A7v8A4dQBANT/zc0Azf8A6tQBANT/i4sAi/8A89QBAO+5sLAwYP8A+tQBAOTL//80s/8AAtUBAOTL7u4wp/8ACtUBAOTMzc0pkP8AEtUBAOTLi4scYv8AGtUBAHGAzWbNqv8AK9UBAKr/zQAAzf8ANtUBAMyY07pV0/8AQ9UBAMuZ/+Bm//8AUdUBAMuZ7tFf7v8AX9UBAMuZzbRSzf8AbdUBAMuai3o3i/8Ae9UBALd825Nw2/8AiNUBALd9/6uC//8AltUBALd97p957v8ApNUBALd9zYlozf8AstUBALd8i11Hi/8AwNUBAGepszyzcf8Az9UBALCP7nto7v8A39UBAG//+gD6mv8A8dUBAH2n0UjRzP8AAdYBAOTkx8cVhf8AEdYBAKrGcBkZcP8AHtYBAGoJ//X/+v8AKNYBAAQe///k4f8AMtYBAAQe///k4f8APdYBAAQe7u7V0v8ASNYBAAMdzc23tf8AU9YBAAUdi4t9e/8AXtYBABpJ///ktf8AZ9YBABlR///erf8Ac9YBABlR///erf8AgNYBABlS7u7Pof8AjdYBABlSzc2zi/8AmtYBABlSi4t5Xv8Ap9YBAKr/gAAAgP8ArNYBAKr/gAAAgP8AtdYBACoA/////gAAutYBABsX/f315v8AwtYBADjAjmuOI/8AzNYBADjB/8D/Pv8A19YBADjA7rPuOv8A4tYBADjAzZrNMv8A7dYBADjAi2mLIv8A+NYBABv///+lAP8A/9YBABv///+lAP8AB9cBABv/7u6aAP8AD9cBABv/zc2FAP8AF9cBABv/i4taAP8AH9cBAAv///9FAP8AKdcBAAv///9FAP8ANNcBAAv/7u5AAP8AP9cBAAv/zc03AP8AStcBAAv/i4slAP8AVdcBANZ72tpw1v8AXNcBANZ8//+D+v8AZNcBANZ87u566f8AbNcBANZ8zc1pyf8AdNcBANV8i4tHif8AfNcBACZI7u7oqv8AitcBAFVk+5j7mP8AlNcBAFVl/5r/mv8An9cBAFVk7pDukP8AqtcBAFVkzXzNfP8AtdcBAFVki1SLVP8AwNcBAH9D7q/u7v8AztcBAH9E/7v///8A3dcBAH9E7q7u7v8A7NcBAH9EzZbNzf8A+9cBAH9Di2aLi/8ACtgBAPF829twk/8AGNgBAPF9//+Cq/8AJ9gBAPF97u55n/8ANtgBAPF9zc1oif8ARdgBAPF8i4tHXf8AVNgBABop///v1f8AX9gBABRG///auf8AadgBABRG///auf8AdNgBABNF7u7Lrf8Af9gBABNFzc2vlf8AitgBABRFi4t3Zf8AldgBABSwzc2FP/8AmtgBAPc////Ay/8An9gBAPVJ//+1xf8ApdgBAPVJ7u6puP8Aq9gBAPVKzc2Rnv8AsdgBAPVJi4tjbP8At9gBANRG3d2g3f8AvNgBANRE//+7//8AwtgBANRE7u6u7v8AyNgBANREzc2Wzf8AztgBANRDi4tmi/8A1NgBAIQ75rDg5v8A39gBAMTd8KAg8P8A5tgBAL/P/5sw//8A7tgBAMDP7pEs7v8A9tgBAMDPzX0mzf8A/tgBAMDPi1Uai/8ABtkBAAD///8AAP8ACtkBAAD///8AAP8AD9kBAAD/7u4AAP8AFNkBAAD/zc0AAP8AGdkBAAD/i4sAAP8AHtkBAAA9vLyPj/8AKNkBAAA+///Bwf8AM9kBAAA+7u60tP8APtkBAAA+zc2bm/8ASdkBAAA+i4tpaf8AVNkBAJ+14UFp4f8AXtkBAJ+3/0h2//8AadkBAJ+37kNu7v8AdNkBAJ+2zTpfzf8Af9kBAJ+3iydAi/8AitkBABHci4tFE/8AltkBAASK+vqAcv8AndkBAAmW//+Maf8ApdkBAAmW7u6CYv8ArdkBAAmWzc1wVP8AtdkBAAmWi4tMOf8AvdkBABOa9PSkYP8AyNkBAGeqiy6LV/8A0dkBAGer/1T/n/8A29kBAGer7k7ulP8A5dkBAGerzUPNgP8A79kBAGeqiy6LV/8A+dkBABEQ///17v8AAtoBABEQ///17v8ADNoBABIR7u7l3v8AFtoBABIRzc3Fv/8AINoBABIQi4uGgv8AKtoBAA23oKBSLf8AMdoBAA24//+CR/8AOdoBAA247u55Qv8AQdoBAA24zc1oOf8ASdoBAA25i4tHJv8AUdoBAIts64fO6/8AWdoBAJB4/4fO//8AYtoBAJB47n7A7v8Aa9oBAJB4zWymzf8AdNoBAJF3i0pwi/8AfdoBAK+PzWpazf8Ah9oBAK+Q/4Nv//8AktoBAK+Q7npn7v8AndoBAK+QzWlZzf8AqNoBAK+Qi0c8i/8As9oBAJQ4kHCAkP8AvdoBAJU4/8bi//8AyNoBAJU47rnT7v8A09oBAJQ5zZ+2zf8A3toBAJU4i2x7i/8A6doBAJQ4kHCAkP8A89oBAAAF///6+v8A+NoBAAAF///6+v8A/toBAAAF7u7p6f8ABNsBAAAEzc3Jyf8ACtsBAAADi4uJif8AENsBAGr//wD/f/8AHNsBAGr//wD/f/8AKdsBAGr/7gDudv8ANtsBAGr/zQDNZv8AQ9sBAGr/iwCLRf8AUNsBAJKbtEaCtP8AWtsBAJKc/2O4//8AZdsBAJKc7lys7v8AcNsBAJKczU+Uzf8Ae9sBAJObizZki/8AhtsBABhU0tK0jP8AitsBABSw//+lT/8Aj9sBABSw7u6aSf8AlNsBABSwzc2FP/8AmdsBABSwi4taK/8AntsBANQd2Ni/2P8AptsBANQe///h//8Ar9sBANQe7u7S7v8AuNsBANQdzc21zf8AwdsBANQdi4t7i/8AytsBAAa4//9jR/8A0dsBAAa4//9jR/8A2dsBAAa47u5cQv8A4dsBAAa4zc1POf8A6dsBAAa5i4s2Jv8AO90BACoA/////gAA8dsBAHu24EDg0P8A+9sBAIH//wD1//8ABtwBAIH/7gDl7v8AEdwBAIH/zQDFzf8AHNwBAIH/iwCGi/8AJ9wBANRz7u6C7v8ALtwBAOPX0NAgkP8AONwBAOvB//8+lv8AQ9wBAOvA7u46jP8ATtwBAOvAzc0yeP8AWdwBAOvAi4siUv8AZNwBABtE9fXes/8AatwBABtF///nuv8AcdwBABtE7u7Yrv8AeNwBABtEzc26lv8Af9wBABtDi4t+Zv8AhtwBAAAA//////8AjNwBAAAA9fX19f8Al9wBACr/////AP8AntwBACr/////AP8AptwBACr/7u7uAP8ArtwBACr/zc3NAP8AttwBACr/i4uLAP8AvtwBADjAzZrNMv8AReEBAE7dAQBQ3QEAUt0BAFTdAQBW3QEAWN0BAFrdAQBc3QEAXt0BAGDdAQBj3QEAZt0BAGndAQBs3QEAb90BAHLdAQB13QEAeN0BAHvdAQB+3QEAAAAAAAQAAAAEAAAABQAAADEAAAAQAAAAAAAAAAAAAAAAAAAACAAAABAAAAAYAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAACAAAABAAAAAYAAAAAAAAAAAAAAASAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAADIAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAADMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADMAAAAAAAAAAAAAAAAAAAAAAAAAlNcAABQAAABDLlVURi04AAAAAAAAAAAAAAAAAN4SBJUAAAAA////////////////AgAAwAMAAMAEAADABQAAwAYAAMAHAADACAAAwAkAAMAKAADACwAAwAwAAMANAADADgAAwA8AAMAQAADAEQAAwBIAAMATAADAFAAAwBUAAMAWAADAFwAAwBgAAMAZAADAGgAAwBsAAMAcAADAHQAAwB4AAMAfAADAAAAAswEAAMMCAADDAwAAwwQAAMMFAADDBgAAwwcAAMMIAADDCQAAwwoAAMMLAADDDAAAww0AANMOAADDDwAAwwAADLsBAAzDAgAMwwMADMMEAAzTeNgAAAkAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAHAAAAbqgCAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD42AAABQAAAAAAAAAAAAAADwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAcAAAB2rAIAAAQAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAACv////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPjYAAB82QAABQAAAAAAAAAAAAAADwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACQAAAAcAAAB+sAIAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAA//////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9JoCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAABAAAAAQAAAAGAAAAg/miAERObgD8KRUA0VcnAN009QBi28AAPJmVAEGQQwBjUf4Au96rALdhxQA6biQA0k1CAEkG4AAJ6i4AHJLRAOsd/gApsRwA6D6nAPU1ggBEuy4AnOmEALQmcABBfl8A1pE5AFODOQCc9DkAi1+EACj5vQD4HzsA3v+XAA+YBQARL+8AClqLAG0fbQDPfjYACcsnAEZPtwCeZj8ALepfALondQDl68cAPXvxAPc5BwCSUooA+2vqAB+xXwAIXY0AMANWAHv8RgDwq2sAILzPADb0mgDjqR0AXmGRAAgb5gCFmWUAoBRfAI1AaACA2P8AJ3NNAAYGMQDKVhUAyahzAHviYABrjMAAIAAAAAkAAAAKAAAADQAAAAsAAAAMAAAAhQAAAAAgAAABIAAAAiAAAAMgAAAEIAAABSAAAAYgAAAIIAAACSAAAAogAAAoIAAAKSAAAF8gAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAZAAAAOgDAAAQJwAAoIYBAEBCDwCAlpgAAOH1BV9wiQD/CS8PdAAAAPMOAgBuAAAA9Q4CAHIAAAD3DgIAZgAAAPkOAgBhAAAA+w4CAGUAAAD9DgIAdwAAAP8OAgBXAAAADA8CAHMAAAAaDwIAUwAAACYPAgBkAAAAMw8CAEQAAAA/DwIAAAAAAAAAAAAAAAAAAAAEAAQAGwAbACAAIAAjACEACgACABYACQAhACEAIQAVABwAAQAUABQAFAAUABQAFAAUAAgABAAFABsAAgAXABsAIAAfAB4AHQAJABMAAAAVABIAFQADAAcAFQAVABQAFAAUABQAFAAUABQAFAAIAAQABQAFAAYAGwAaABgAGQAgAAcAFQAUABQAFAAUABQAFAALABQADQAUAAwAFAAUABQADgAUABQAFAAQABQADwAUABEAAAAAAAAArgAuAC8AMwA1ADAANwCqANsA2wDbANsAAAA9AIcANwA3ANsA2wAAACgANQAuADIALwBiAAAAAABHAAAAAADbAFEAAADbANsA2wAAANsAhABVANsAggDbAAAAgQDbAAAAPgBCAEEASABEAFIAWwAAAAAAXgBfANsAAADbANsA2wAAAAAAewBJAFcAUgBaAFoAXQAAAF8AAABfAAAAZQBdAF8AAABdAG4AagAAAGkAAABuAAAA2wCTAJoAoQCoAKsAcACxALgAvwDGAM0A0wAAAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAMABAAHAAMABAAFAAUABgAGAAgABwAHABEAFgASABEAEgAIAAgADwAPABcADwAYAA8AGQAaABoAHgAWADQAHgAFADIABgAiACIAMwAXABgANQAZABoAGgAqADYAKgA0ADcAMgBFADsAPAAzADsAPABGADUARwBIAEwANgAiAEkASgA3AEUATgBQAGIAUQBSAFQARgBHAFUASABMAFYASQBKAFgAWgBOAEQAUABRAFIAVAA4AC8ALABVACkAVgAbABAAWABaAF0AXQBdAF0AXQBdAF0AXgBeAF4AXgBeAF4AXgBfAF8AXwBfAF8AXwBfAGAACQBgAGAAYABgAGAAYQBhAGMAAgBjAGMAYwBjAGMAZAAAAGQAAABkAGQAZABlAAAAZQBlAGUAZQBlAGYAZgAAAGYAZgBmAGYAZwAAAGcAZwBnAGcAaAAAAGgAaABoAGgAaABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAAAAXAABAF0AXQBeAF4AXwBfAFwAXABcAFwAXABgAFwAXABcAGEAXABcAGIAYgBiAGIAYgBiAGIAYwBkAGUAZgBmAFwAXABnAFwAXABcAGAAXABcAGEAXABhAFwAaABhAFwAYgBiAGIAYgBiAGIAYgBiAGMAZABlAGUAXABmAFwAXABcAGcAaABhAGIAYgBiAGIAYgBiAGIAYgBiAGIAYgBiAGIAYgBiAGIAYgBiAGIAYgBiAGIAYgAAAFwAXABcAFwAXABcAFwAXABcAFwAXABcAAAACgALAAwADQAOAAoADwAQABEAEgATAAoAFAAVABUAFQAWABcAFQAYABUAFQAZABUAFQAVABoAFQAVAAoAFQAVABUAFgAXABgAFQAVABkAFQAVABUAGgAVABUAFQAVABsADAAMACQAHgAeACAAIQAgACEAJAAlACYALQAyAC8ALgAqACUAJgAoACkAMwAqADQAKwA1ADYANwA8ADIARwA9ACIARQAiAD8AQABGADMANABIADUANgA3AC8ASQAqAEcASgBFAEwAXAA8AEYAXAA9AE0ASABOAE8AUgBJAEEAUABRAEoATABTAFQAMQBVAFYAVwBNAE4AWABPAFIAWQBQAFEAWgBbAFMARABUAFUAVgBXAEsARAAsAFgALABZADgALABaAFsAHQAdAB0AHQAdAB0AHQAfAB8AHwAfAB8AHwAfACMAIwAjACMAIwAjACMAJwBcACcAJwAnACcAJwAwADAAOQAcADkAOQA5ADkAOQA6AFwAOgBcADoAOgA6ADsAXAA7ADsAOwA7ADsAPgA+AFwAPgA+AD4APgBCAFwAQgBCAEIAQgBDAFwAQwBDAEMAQwBDAAkAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwACACu/9EACgCu/67/CwCu/67/rv+u/67/rv+u/67/BQDRAK7/0QDRANEA0QDRANEA0QDRAK7/+/+u/w4A7P+u/67/rv+u/9EA0QDRANEA0QANACUADABCABAAUAATAG0AewAUAJgADwCmAMMArv+u/67/rv+u/67/rv+u/67/rv+u/67/rv+u/67/rv+u/67/rv+u/67/rv+u/67/FwCu/3cArv8HAC4Arv8mAK7/FwARACMArv8NAK7/rv+u/67/OgCu/67/NQCu/67/rv8oAK7/BwCu/zsARQCu/0gArv+u/67/rv+u/67/rv/8/+gA9v///xoAAAAnAAEAMgCu/67/AgAkAAMALwCu/67/rv+u/67//v+UAK7/CQAbAK7/vP+u/67/r/+u/67/rv+u/67/rv+u/wAAAAAAAG3m7N4FAAsASQAxAVMAfwEwAWkAeAH/AIEBUwKCAYMBhAGFAYYBVAKHAYgBiQFWAooBVwKLAYwBjgHdAY8BWQKQAVsCkQGSAZMBYAKUAWMClgFpApcBaAKYAZkBnAFvAp0BcgKfAXUCpgGAAqcBqAGpAYMCrAGtAa4BiAKvAbABsQGKArIBiwK3AZICuAG5AbwBvQHEAcYBxAHFAcUBxgHHAckBxwHIAcgByQHKAcwBygHLAcsBzAHxAfMB8QHyAfIB8wH0AfUB9gGVAfcBvwEgAp4BhgOsA4gDrQOJA64DigOvA4wDzAOOA80DjwPOA5kDRQOZA74fowPCA/cD+AP6A/sDYB6bHp4e3wBZH1EfWx9TH10fVR9fH1cfvB+zH8wfwx/sH+Uf/B/zHzoCZSw7AjwCPQKaAT4CZixBAkICQwKAAUQCiQJFAowC9AO4A/kD8gP9A3sD/gN8A/8DfQPABM8EJiHJAyohawArIeUAMiFOIYMhhCFgLGEsYixrAmMsfR1kLH0CbSxRAm4scQJvLFACcCxSAnIscyx1LHYsfiw/An8sQALyLPMsfad5HYunjKeNp2UCqqdmAscQJy3NEC0tdgN3A5wDtQCSA9ADmAPRA6YD1QOgA9YDmgPwA6ED8QOVA/UDzwPXAwAAAABBACAawAAgHwABAS8yAQEFOQEBD0oBAS15AQEFcAMBA5EDIBGjAyAJAARQEBAEICBgBAEhigQBNcEEAQ3QBAE/FAUBEzEFMCagAQEFswEBA80BAQ/eAQER+AEBJyICARHYAwEXAB4BlaAeAV8IH/gIGB/4Bigf+Ag4H/gISB/4Bmgf+AiIH/gImB/4CKgf+Ai4H/gCuh+2AsgfqgTYH/gC2h+cAugf+ALqH5AC+B+AAvofggJGAgEJEAUBA2AhEBAALDAvZywBBYAsAWPrLAEDQKYBLYCmARcipwENMqcBPXmnAQN+pwEJkKcBA6CnAQkh/yAaAAAAAHsgdmFyIHBhdGggPSBQb2ludGVyX3N0cmluZ2lmeSgkMCk7IHZhciBkYXRhID0gUG9pbnRlcl9zdHJpbmdpZnkoJDEpOyBGUy5jcmVhdGVQYXRoKCIvIiwgUEFUSC5kaXJuYW1lKHBhdGgpKTsgRlMud3JpdGVGaWxlKFBBVEguam9pbigiLyIsIHBhdGgpLCBkYXRhKTsgfQBjb3JlAHhkb3R2ZXJzaW9uADEuNwAxLjQAMS4yAF9sZHJhd18AX2hkcmF3XwBfdGRyYXdfAF9obGRyYXdfAF90bGRyYXdfAHhkb3QgdmVyc2lvbiAiJXMiIHRvbyBsb25nACAlZCAAJS4wMmYAJXMlZCAtACMlMDJ4JTAyeCUwMnglMDJ4AHNldGxpbmV3aWR0aCgAJS4zZgBTIABDIAAyIAAlLjAzZgBFIABlIABGIAB0ICV1IABUIABkb3Q6ZG90AGd2OmRvdABjYW5vbjpkb3QAcGxhaW46ZG90AHBsYWluLWV4dDpkb3QAeGRvdDp4ZG90AHhkb3QxLjI6eGRvdAB4ZG90MS40Onhkb3QASSAAIl9zdWJncmFwaF9jbnQiOiAlZAAiX2d2aWQiOiAlZAAiZWRnZXMiOiBbCgAiX2d2aWQiOiAlZCwKACJ0YWlsIjogJWQsCgAiaGVhZCI6ICVkACJvYmplY3RzIjogWwoAIm5vZGVzIjogWwoAIm5hbWUiOiAiJXMiAFwiAFwvAFxiAFxmAFxuAFxyAFx0ACJzdWJncmFwaHMiOiBbCgAiJXMiOiAAIiVzIgBDb3VsZCBub3QgcGFyc2UgeGRvdCAiJXMiCgBbCgAib3AiOiAiJWMiLAoAInJlY3QiOiBbJS4wM2YsJS4wM2YsJS4wM2YsJS4wM2ZdCgAib3AiOiAiTCIsCgAib3AiOiAiVCIsCgAicHQiOiBbJS4wM2YsJS4wM2ZdLAoAImFsaWduIjogIiVjIiwKACJ3aWR0aCI6ICUuMDNmLAoAInRleHQiOiAiJXMiCgAiZ3JhZCI6ICJub25lIiwKACJjb2xvciI6ICIlcyIKACJncmFkIjogImxpbmVhciIsCgAiZ3JhZCI6ICJyYWRpYWwiLAoAIm9wIjogIkYiLAoAInNpemUiOiAlLjAzZiwKACJmYWNlIjogIiVzIgoAIm9wIjogIlMiLAoAInN0eWxlIjogIiVzIgoAIm9wIjogInQiLAoAImZvbnRjaGFyIjogJWQKACJwMCI6IFslLjAzZiwlLjAzZiwlLjAzZl0sCgAicDEiOiBbJS4wM2YsJS4wM2YsJS4wM2ZdLAoAInN0b3BzIjogWwB7ImZyYWMiOiAlLjAzZiwgImNvbG9yIjogIiVzIn0AXQoAInAwIjogWyUuMDNmLCUuMDNmXSwKACJwMSI6IFslLjAzZiwlLjAzZl0sCgAicG9pbnRzIjogWwBbJS4wM2YsJS4wM2ZdAGRyYXdfAGxkcmF3XwBoZHJhd18AdGRyYXdfAGhsZHJhd18AdGxkcmF3XwAiZGlyZWN0ZWQiOiAlcywKACJzdHJpY3QiOiAlcwAgIABEdXBsaWNhdGUgY2x1c3RlciBuYW1lICIlcyIKAHhkb3QAanNvbgBqc29uMABkb3RfanNvbgB4ZG90X2pzb24AanNvbjpqc29uAGpzb24wOmpzb24AZG90X2pzb246anNvbgB4ZG90X2pzb246anNvbgBuID49IDQAZ3ZyZW5kZXJfY29yZV9maWcuYwBmaWdfYmV6aWVyAGZpZ19yZXNvbHZlX2NvbG9yAGZpZwBmaWc6ZmlnAG1hcAByZWN0ICVzICVkLCVkICVkLCVkCgBjaXJjbGUgJXMgJWQsJWQsJWQKAHBvbHkgJXMAICVkLCVkAGd2cmVuZGVyX2NvcmVfbWFwLmMAbWFwX291dHB1dF9zaGFwZQByZWN0YW5nbGUgKCVkLCVkKSAoJWQsJWQpICVzICVzCgA8YXJlYSBzaGFwZT0iY2lyY2xlIgA8YXJlYSBzaGFwZT0icmVjdCIAPGFyZWEgc2hhcGU9InBvbHkiACBocmVmPSIAIHRpdGxlPSIAIGFsdD0iIgAgY29vcmRzPSIAJWQsJWQsJWQAJWQsJWQsJWQsJWQAJWQsJWQALCVkLCVkACI+CgA8L21hcD4KAGJhc2UgcmVmZXJlcgoAZGVmYXVsdCAAPG1hcCBpZD0iACIgbmFtZT0iAGlzbWFwOm1hcABjbWFwOm1hcABpbWFwOm1hcABjbWFweDptYXAAaW1hcF9ucDptYXAAY21hcHhfbnA6bWFwACMgJXMKACVkICVkICVkICVkICVkICVkICVkICVkICVkICUuMWYgJWQgJWQgJWQgJWQgJWQgJWQKACVkICVkICVkICVkICVkICVkICVkICVkICVkICUuMWYgJWQgJWQgJWQgJWQKACVkICVkICVkICVkICVkICVkICVkICVkICVkICUuM2YgJWQgJS40ZiAlZCAlZCAlZCAlZCAlZCAlZCAlZCAlZAoAJWQgJWQgIyUwMnglMDJ4JTAyeAoAZ3ZyZW5kZXJfY29yZV9tcC5jAG1wX3Jlc29sdmVfY29sb3IAJWQgJWQgJWQgJWQgJWQgJWQgJS4xZiAlLjRmICVkICUuMWYgJS4xZiAlZCAlZCAlc1wwMDEKACMgZW5kIG9mIEZJRyBmaWxlCgAjRklHIDMuMgoAIyBHZW5lcmF0ZWQgYnkgJXMgdmVyc2lvbiAlcyAoJXMpCgAjIFRpdGxlOiAlcwoAIyBQYWdlczogJWQKAFBvcnRyYWl0CgBDZW50ZXIKAEluY2hlcwoATGV0dGVyCgAxMDAuMDAKAFNpbmdsZQoALTIKADEyMDAAIDIKAG1wAG1wOm1wACBdICAlZCB0cnVlICVzCgAgXSAgJWQgZmFsc2UgJXMKACBzZXRsaW5ld2lkdGgKACVzIABzZXRoc2IAJS41ZyAlLjVnICUuNWcgJXNjb2xvcgoAJSAAbmV3cGF0aCAAIG1vdmV0bwoAIGxpbmV0bwoAc3Ryb2tlCgAgY3VydmV0bwoAY2xvc2VwYXRoIGZpbGwKAGNsb3NlcGF0aCBzdHJva2UKACBlbGxpcHNlX3BhdGggZmlsbAoAIGVsbGlwc2VfcGF0aCBzdHJva2UKACAvJXMgc2V0X2ZvbnQKACBtb3ZldG8gACAlcyBhbGlnbmVkdGV4dAoAWyAvUmVjdCBbIAAgXQoAICAvQm9yZGVyIFsgMCAwIDAgXQogIC9BY3Rpb24gPDwgL1N1YnR5cGUgL1VSSSAvVVJJICVzID4+CiAgL1N1YnR5cGUgL0xpbmsKL0FOTiBwZGZtYXJrCgBnc2F2ZQoAJSUgJXMKADAgMCAwIGVkZ2Vjb2xvcgoAZW5kcGFnZQpzaG93cGFnZQpncmVzdG9yZQoAJSVQYWdlVHJhaWxlcgoAJSUlJUVuZFBhZ2U6ICVkCgAlJSUlUGFnZTogJWQgJWQKACUlJSVQYWdlQm91bmRpbmdCb3g6ICVkICVkICVkICVkCgBMYW5kc2NhcGUAUG9ydHJhaXQAJSUlJVBhZ2VPcmllbnRhdGlvbjogJXMKADw8IC9QYWdlU2l6ZSBbJWQgJWRdID4+IHNldHBhZ2VkZXZpY2UKACVkICVkICVkIGJlZ2lucGFnZQoAZ3NhdmUKJWQgJWQgJWQgJWQgYm94cHJpbSBjbGlwIG5ld3BhdGgKACVnICVnIHNldF9zY2FsZSAlZCByb3RhdGUgJWcgJWcgdHJhbnNsYXRlCgBjYW52YXMgc2l6ZSAoJWQsJWQpIGV4Y2VlZHMgUERGIGxpbWl0ICglZCkKCShzdWdnZXN0IHNldHRpbmcgYSBib3VuZGluZyBib3ggc2l6ZSwgc2VlIGRvdCgxKSkKAFsgL0Nyb3BCb3ggWyVkICVkICVkICVkXSAvUEFHRVMgcGRmbWFyawoAJWQgJWQgc2V0bGF5ZXIKACUlJSVUaXRsZTogJXMKACUlUGFnZXM6IChhdGVuZCkKACUlUGFnZXM6IDEKACUlQm91bmRpbmdCb3g6IChhdGVuZCkKACUlJSVCb3VuZGluZ0JveDogJWQgJWQgJWQgJWQKACUlRW5kQ29tbWVudHMKc2F2ZQoAc2V0dXBMYXRpbjEKAFsge0NhdGFsb2d9IDw8IC9VUkkgPDwgL0Jhc2UgJXMgPj4gPj4KL1BVVCBwZGZtYXJrCgAlJUJlZ2luUHJvbG9nAC9Eb3REaWN0IDIwMCBkaWN0IGRlZgBEb3REaWN0IGJlZ2luAC9zZXR1cExhdGluMSB7AG1hcmsAL0VuY29kaW5nVmVjdG9yIDI1NiBhcnJheSBkZWYAIEVuY29kaW5nVmVjdG9yIDAASVNPTGF0aW4xRW5jb2RpbmcgMCAyNTUgZ2V0aW50ZXJ2YWwgcHV0aW50ZXJ2YWwARW5jb2RpbmdWZWN0b3IgNDUgL2h5cGhlbiBwdXQAJSBTZXQgdXAgSVNPIExhdGluIDEgY2hhcmFjdGVyIGVuY29kaW5nAC9zdGFybmV0SVNPIHsAICAgICAgICBkdXAgZHVwIGZpbmRmb250IGR1cCBsZW5ndGggZGljdCBiZWdpbgAgICAgICAgIHsgMSBpbmRleCAvRklEIG5lIHsgZGVmIH17IHBvcCBwb3AgfSBpZmVsc2UAICAgICAgICB9IGZvcmFsbAAgICAgICAgIC9FbmNvZGluZyBFbmNvZGluZ1ZlY3RvciBkZWYAICAgICAgICBjdXJyZW50ZGljdCBlbmQgZGVmaW5lZm9udAB9IGRlZgAvVGltZXMtUm9tYW4gc3Rhcm5ldElTTyBkZWYAL1RpbWVzLUl0YWxpYyBzdGFybmV0SVNPIGRlZgAvVGltZXMtQm9sZCBzdGFybmV0SVNPIGRlZgAvVGltZXMtQm9sZEl0YWxpYyBzdGFybmV0SVNPIGRlZgAvSGVsdmV0aWNhIHN0YXJuZXRJU08gZGVmAC9IZWx2ZXRpY2EtT2JsaXF1ZSBzdGFybmV0SVNPIGRlZgAvSGVsdmV0aWNhLUJvbGQgc3Rhcm5ldElTTyBkZWYAL0hlbHZldGljYS1Cb2xkT2JsaXF1ZSBzdGFybmV0SVNPIGRlZgAvQ291cmllciBzdGFybmV0SVNPIGRlZgAvQ291cmllci1PYmxpcXVlIHN0YXJuZXRJU08gZGVmAC9Db3VyaWVyLUJvbGQgc3Rhcm5ldElTTyBkZWYAL0NvdXJpZXItQm9sZE9ibGlxdWUgc3Rhcm5ldElTTyBkZWYAY2xlYXJ0b21hcmsAfSBiaW5kIGRlZgAlJUJlZ2luUmVzb3VyY2U6IHByb2NzZXQgZ3JhcGh2aXogMCAwAC9jb29yZC1mb250LWZhbWlseSAvVGltZXMtUm9tYW4gZGVmAC9kZWZhdWx0LWZvbnQtZmFtaWx5IC9UaW1lcy1Sb21hbiBkZWYAL2Nvb3JkZm9udCBjb29yZC1mb250LWZhbWlseSBmaW5kZm9udCA4IHNjYWxlZm9udCBkZWYAL0ludlNjYWxlRmFjdG9yIDEuMCBkZWYAL3NldF9zY2FsZSB7ACAgICAgICBkdXAgMSBleGNoIGRpdiAvSW52U2NhbGVGYWN0b3IgZXhjaCBkZWYAICAgICAgIHNjYWxlACUgc3R5bGVzAC9zb2xpZCB7IFtdIDAgc2V0ZGFzaCB9IGJpbmQgZGVmAC9kYXNoZWQgeyBbOSBJbnZTY2FsZUZhY3RvciBtdWwgZHVwIF0gMCBzZXRkYXNoIH0gYmluZCBkZWYAL2RvdHRlZCB7IFsxIEludlNjYWxlRmFjdG9yIG11bCA2IEludlNjYWxlRmFjdG9yIG11bF0gMCBzZXRkYXNoIH0gYmluZCBkZWYAL2ludmlzIHsvZmlsbCB7bmV3cGF0aH0gZGVmIC9zdHJva2Uge25ld3BhdGh9IGRlZiAvc2hvdyB7cG9wIG5ld3BhdGh9IGRlZn0gYmluZCBkZWYAL2JvbGQgeyAyIHNldGxpbmV3aWR0aCB9IGJpbmQgZGVmAC9maWxsZWQgeyB9IGJpbmQgZGVmAC91bmZpbGxlZCB7IH0gYmluZCBkZWYAL3JvdW5kZWQgeyB9IGJpbmQgZGVmAC9kaWFnb25hbHMgeyB9IGJpbmQgZGVmAC90YXBlcmVkIHsgfSBiaW5kIGRlZgAlIGhvb2tzIGZvciBzZXR0aW5nIGNvbG9yIAAvbm9kZWNvbG9yIHsgc2V0aHNiY29sb3IgfSBiaW5kIGRlZgAvZWRnZWNvbG9yIHsgc2V0aHNiY29sb3IgfSBiaW5kIGRlZgAvZ3JhcGhjb2xvciB7IHNldGhzYmNvbG9yIH0gYmluZCBkZWYAL25vcGNvbG9yIHtwb3AgcG9wIHBvcH0gYmluZCBkZWYAL2JlZ2lucGFnZSB7CSUgaSBqIG5wYWdlcwAJL25wYWdlcyBleGNoIGRlZgAJL2ogZXhjaCBkZWYACS9pIGV4Y2ggZGVmAAkvc3RyIDEwIHN0cmluZyBkZWYACW5wYWdlcyAxIGd0IHsACQlnc2F2ZQAJCQljb29yZGZvbnQgc2V0Zm9udAAJCQkwIDAgbW92ZXRvAAkJCShcKCkgc2hvdyBpIHN0ciBjdnMgc2hvdyAoLCkgc2hvdyBqIHN0ciBjdnMgc2hvdyAoXCkpIHNob3cACQlncmVzdG9yZQAJfSBpZgAvc2V0X2ZvbnQgewAJZmluZGZvbnQgZXhjaAAJc2NhbGVmb250IHNldGZvbnQAJSBkcmF3IHRleHQgZml0dGVkIHRvIGl0cyBleHBlY3RlZCB3aWR0aAAvYWxpZ25lZHRleHQgewkJCSUgd2lkdGggdGV4dAAJL3RleHQgZXhjaCBkZWYACS93aWR0aCBleGNoIGRlZgAJZ3NhdmUACQl3aWR0aCAwIGd0IHsACQkJW10gMCBzZXRkYXNoAAkJCXRleHQgc3RyaW5nd2lkdGggcG9wIHdpZHRoIGV4Y2ggc3ViIHRleHQgbGVuZ3RoIGRpdiAwIHRleHQgYXNob3cACQl9IGlmAAlncmVzdG9yZQAvYm94cHJpbSB7CQkJCSUgeGNvcm5lciB5Y29ybmVyIHhzaXplIHlzaXplAAkJNCAyIHJvbGwACQltb3ZldG8ACQkyIGNvcHkACQlleGNoIDAgcmxpbmV0bwAJCTAgZXhjaCBybGluZXRvAAkJcG9wIG5lZyAwIHJsaW5ldG8ACQljbG9zZXBhdGgAL2VsbGlwc2VfcGF0aCB7AAkvcnkgZXhjaCBkZWYACS9yeCBleGNoIGRlZgAJL3kgZXhjaCBkZWYACS94IGV4Y2ggZGVmAAltYXRyaXggY3VycmVudG1hdHJpeAAJbmV3cGF0aAAJeCB5IHRyYW5zbGF0ZQAJcnggcnkgc2NhbGUACTAgMCAxIDAgMzYwIGFyYwAJc2V0bWF0cml4AC9lbmRwYWdlIHsgc2hvd3BhZ2UgfSBiaW5kIGRlZgAvc2hvd3BhZ2UgeyB9IGRlZgAvbGF5ZXJjb2xvcnNlcQAJWwklIGxheWVyIGNvbG9yIHNlcXVlbmNlIC0gZGFya2VzdCB0byBsaWdodGVzdAAJCVswIDAgMF0ACQlbLjIgLjggLjhdAAkJWy40IC44IC44XQAJCVsuNiAuOCAuOF0ACQlbLjggLjggLjhdAAldAGRlZgAvbGF5ZXJsZW4gbGF5ZXJjb2xvcnNlcSBsZW5ndGggZGVmAC9zZXRsYXllciB7L21heGxheWVyIGV4Y2ggZGVmIC9jdXJsYXllciBleGNoIGRlZgAJbGF5ZXJjb2xvcnNlcSBjdXJsYXllciAxIHN1YiBsYXllcmxlbiBtb2QgZ2V0AAlhbG9hZCBwb3Agc2V0aHNiY29sb3IACS9ub2RlY29sb3Ige25vcGNvbG9yfSBkZWYACS9lZGdlY29sb3Ige25vcGNvbG9yfSBkZWYACS9ncmFwaGNvbG9yIHtub3Bjb2xvcn0gZGVmAC9vbmxheWVyIHsgY3VybGF5ZXIgbmUge2ludmlzfSBpZiB9IGRlZgAvb25sYXllcnMgewAJL215dXBwZXIgZXhjaCBkZWYACS9teWxvd2VyIGV4Y2ggZGVmAAljdXJsYXllciBteWxvd2VyIGx0AAljdXJsYXllciBteXVwcGVyIGd0AAlvcgAJe2ludmlzfSBpZgAvY3VybGF5ZXIgMCBkZWYAJSVFbmRSZXNvdXJjZQAlJUVuZFByb2xvZwAlJUJlZ2luU2V0dXAAMTQgZGVmYXVsdC1mb250LWZhbWlseSBzZXRfZm9udAAlIC9hcnJvd2xlbmd0aCAxMCBkZWYAJSAvYXJyb3d3aWR0aCA1IGRlZgAlIG1ha2Ugc3VyZSBwZGZtYXJrIGlzIGhhcm1sZXNzIGZvciBQUy1pbnRlcnByZXRlcnMgb3RoZXIgdGhhbiBEaXN0aWxsZXIAL3BkZm1hcmsgd2hlcmUge3BvcH0ge3VzZXJkaWN0IC9wZGZtYXJrIC9jbGVhcnRvbWFyayBsb2FkIHB1dH0gaWZlbHNlACUgbWFrZSAnPDwnIGFuZCAnPj4nIHNhZmUgb24gUFMgTGV2ZWwgMSBkZXZpY2VzAC9sYW5ndWFnZWxldmVsIHdoZXJlIHtwb3AgbGFuZ3VhZ2VsZXZlbH17MX0gaWZlbHNlADIgbHQgewAgICAgdXNlcmRpY3QgKDw8KSBjdm4gKFspIGN2biBsb2FkIHB1dAAgICAgdXNlcmRpY3QgKD4+KSBjdm4gKFspIGN2biBsb2FkIHB1dAB9IGlmACUlRW5kU2V0dXAAJSVUcmFpbGVyCgAlJSUlUGFnZXM6ICVkCgBlbmQKcmVzdG9yZQoAJSVFT0YKACUhUFMtQWRvYmUtMy4wACBFUFNGLTMuMAoAJSUlJUNyZWF0b3I6ICVzIHZlcnNpb24gJXMgKCVzKQoAcHMyOnBzADwhLS0gADxwb2x5bGluZQAgcG9pbnRzPSIAIi8+CgAgZmlsbD0iAHVybCgjbF8lZCkAdXJsKCNyXyVkKQAiIGZpbGwtb3BhY2l0eT0iJWYAIiBzdHJva2U9IgAiIHN0cm9rZS13aWR0aD0iACIgc3Ryb2tlLWRhc2hhcnJheT0iJXMANSwyADEsNQAiIHN0cm9rZS1vcGFjaXR5PSIlZgBndnJlbmRlcl9jb3JlX3N2Zy5jAHN2Z19wcmludF9jb2xvcgA8cGF0aAAgaWQ9IgBfcCIgACBkPSIAJWMAPGRlZnM+CjxyYWRpYWxHcmFkaWVudCBpZD0icl8lZCIgY3g9IjUwJSUiIGN5PSI1MCUlIiByPSI3NSUlIiBmeD0iJWQlJSIgZnk9IiVkJSUiPgoAPHN0b3Agb2Zmc2V0PSIwIiBzdHlsZT0ic3RvcC1jb2xvcjoAO3N0b3Atb3BhY2l0eToAMS4AOyIvPgoAPHN0b3Agb2Zmc2V0PSIxIiBzdHlsZT0ic3RvcC1jb2xvcjoAOyIvPgo8L3JhZGlhbEdyYWRpZW50Pgo8L2RlZnM+CgA8ZGVmcz4KPGxpbmVhckdyYWRpZW50IGlkPSJsXyVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgAHgxPSIAIiB5MT0iACIgeDI9IgAiIHkyPSIAIiA+CgA8c3RvcCBvZmZzZXQ9IiUuMDNmIiBzdHlsZT0ic3RvcC1jb2xvcjoAOyIvPgo8L2xpbmVhckdyYWRpZW50Pgo8L2RlZnM+CgA8cG9seWdvbgA8ZWxsaXBzZQAgY3g9IgAiIGN5PSIAIiByeD0iACIgcnk9IgA8dGV4dAAgdGV4dC1hbmNob3I9InN0YXJ0IgAgdGV4dC1hbmNob3I9ImVuZCIAIHRleHQtYW5jaG9yPSJtaWRkbGUiACB4PSIAIiB5PSIAIGZvbnQtZmFtaWx5PSIlcwAsJXMAIGZvbnQtd2VpZ2h0PSIlcyIAIGZvbnQtc3RyZXRjaD0iJXMiACBmb250LXN0eWxlPSIlcyIAIGZvbnQtZmFtaWx5PSIlcyIAIGZvbnQtd2VpZ2h0PSJib2xkIgAgZm9udC1zdHlsZT0iaXRhbGljIgAgdGV4dC1kZWNvcmF0aW9uPSIAJXNvdmVybGluZQAlc2xpbmUtdGhyb3VnaAAgYmFzZWxpbmUtc2hpZnQ9InN1cGVyIgAgYmFzZWxpbmUtc2hpZnQ9InN1YiIAIGZvbnQtc2l6ZT0iJS4yZiIAIGZpbGw9IiVzIgAgZmlsbD0iIyUwMnglMDJ4JTAyeCIAc3ZnX3RleHRzcGFuAD4APHRleHRQYXRoIHhsaW5rOmhyZWY9IiMlc19wIiBzdGFydE9mZnNldD0iNTAlJSI+ADx0c3BhbiB4PSIwIiBkeT0iACI+ADwvdHNwYW4+PC90ZXh0UGF0aD4APC90ZXh0PgoAPC9nPgoAPGcAIGlkPSJhXwAgeGxpbms6aHJlZj0iACB4bGluazp0aXRsZT0iACB0YXJnZXQ9IgA8dGl0bGU+ADwvdGl0bGU+CgA8ZyBpZD0iAF8lcwAiIGNsYXNzPSIlcwBjbGFzcwAgdHJhbnNmb3JtPSJzY2FsZSgAKSByb3RhdGUoJWQpIHRyYW5zbGF0ZSgAKSI+CgA8L3N2Zz4KADwhLS0AIFBhZ2VzOiAlZCAtLT4KADxzdmcgd2lkdGg9IiVkcHQiIGhlaWdodD0iJWRwdCIKACB2aWV3Qm94PSIlLjJmICUuMmYgJS4yZiAlLjJmIgAgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIgAgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiADw/eG1sIHZlcnNpb249IjEuMCIgZW5jb2Rpbmc9IlVURi04IiBzdGFuZGFsb25lPSJubyI/PgoAc3R5bGVzaGVldAA8P3htbC1zdHlsZXNoZWV0IGhyZWY9IgAiIHR5cGU9InRleHQvY3NzIj8+CgA8IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iCgAgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+CgA8IS0tIEdlbmVyYXRlZCBieSAAZGFya2JsdWUAZGFya2N5YW4AZGFya2dyYXkAZGFya2dyZXkAZGFya21hZ2VudGEAZGFya3JlZABsaWdodGdyZWVuACMgACBjcmVhdGUgbGluZSAAIC1maWxsIAAgLWRhc2ggNQAgLWRhc2ggMgBndnJlbmRlcl9jb3JlX3RrLmMAdGtnZW5fcHJpbnRfdGFncwBncmFwaCBsYWJlbAAgLXRhZ3MgeyVkJXMlcH0AdGtnZW5fcHJpbnRfY29sb3IAJGMAIC13aWR0aCAAIC1zbW9vdGggYmV6aWVyIAAgY3JlYXRlIHBvbHlnb24gACAtb3V0bGluZSAAIGNyZWF0ZSBvdmFsIAAgY3JlYXRlIHRleHQgACAtdGV4dCB7AH0AIC1mb250IHsAICVkfQAgLWFuY2hvciB3ACAtYW5jaG9yIGUAIwAgVGl0bGU6IAAgUGFnZXM6ICVkCgAjIEdlbmVyYXRlZCBieSAAKQoAdGsAdGs6dGsAICAgICAgPCEtLSAAIC0tPgoARXJyb3IgZHVyaW5nIGNvbnZlcnNpb24gdG8gIlVURi04Ii4gIFF1aXRpbmcuCgAgPHY6c2hhcGUgc3R5bGU9InBvc2l0aW9uOmFic29sdXRlOyAAIHdpZHRoOiAlZDsgaGVpZ2h0OiAlZCIgZmlsbGVkPSJmYWxzZSI+ADx2OnBhdGggdj0iACBtIAAlLjBmLCUuMGYgACBsIAAgZSAAIi8+ADwvdjpzaGFwZT4KADx2OnN0cm9rZSBjb2xvcj0iACIgd2VpZ2h0PSIlLjBmcHQAIiBkYXNoc3R5bGU9ImRhc2gAIiBkYXNoc3R5bGU9ImRvdAAiIC8+ACMlMDJ4JTAyeCUwMngAZ3ZyZW5kZXJfY29yZV92bWwuYwB2bWxfcHJpbnRfY29sb3IAIHdpZHRoOiAlZDsgaGVpZ2h0OiAlZCIAID4APHY6cGF0aCAgdj0iAC8+PC92OnNoYXBlPgoAbSAAJXMlLjBmLCUuMGYgAGMgACBmaWxsZWQ9InRydWUiIGZpbGxjb2xvcj0iACIgACBmaWxsZWQ9ImZhbHNlIiAAJS4wZiAlLjBmIABsIAB4IGUgIi8+ACAgPHY6b3ZhbCBzdHlsZT0icG9zaXRpb246YWJzb2x1dGU7ACBsZWZ0OiAlLjJmOyB0b3A6ICUuMmY7ACB3aWR0aDogJS4yZjsgaGVpZ2h0OiAlLjJmIgA8L3Y6b3ZhbD4KADx2OnJlY3Qgc3R5bGU9InBvc2l0aW9uOmFic29sdXRlOyAAIHN0cm9rZWQ9ImZhbHNlIiBmaWxsZWQ9ImZhbHNlIj4KADx2OnRleHRib3ggaW5zZXQ9IjAsMCwwLDAiIHN0eWxlPSJwb3NpdGlvbjphYnNvbHV0ZTsgdi10ZXh0LXdyYXBwaW5nOidmYWxzZSc7cGFkZGluZzonMCc7AGZvbnQtZmFtaWx5OiAnJXMnOwBmb250LXdlaWdodDogJXM7AGZvbnQtc3RyZXRjaDogJXM7AGZvbnQtc3R5bGU6ICVzOwAgZm9udC1zaXplOiAlLjJmcHQ7AGNvbG9yOiVzOwBjb2xvcjojJTAyeCUwMnglMDJ4OwB2bWxfdGV4dHNwYW4AIj48Y2VudGVyPgA8L2NlbnRlcj48L3Y6dGV4dGJveD4KADwvdjpyZWN0PgoAPC9hPgoAPGEAIGhyZWY9IiVzIgAgdGl0bGU9IiVzIgAgdGFyZ2V0PSIlcyIAPgoAPC92Omdyb3VwPgoAPC9ESVY+CgA8RElWIGlkPSdfVk1MMl8nIHN0eWxlPSJwb3NpdGlvbjpyZWxhdGl2ZTt2aXNpYmlsaXR5OmhpZGRlbiI+CgA8IS0tIGluc2VydCBhbnkgb3RoZXIgaHRtbCBjb250ZW50IGhlcmUgLS0+CgA8RElWIGlkPSdfbm90Vk1MMV8nIHN0eWxlPSJwb3NpdGlvbjpyZWxhdGl2ZTsiPgoAPCEtLSB0aGlzIHNob3VsZCBvbmx5IGRpc3BsYXkgb24gTk9OLUlFIGJyb3dzZXJzIC0tPgoAPEgyPlNvcnJ5LCB0aGlzIGRpYWdyYW0gd2lsbCBvbmx5IGRpc3BsYXkgY29ycmVjdGx5IG9uIEludGVybmV0IEV4cGxvcmVyIDUgKGFuZCB1cCkgYnJvd3NlcnMuPC9IMj4KADxESVYgaWQ9J19ub3RWTUwyXycgc3R5bGU9InBvc2l0aW9uOnJlbGF0aXZlOyI+CgA8IS0tIGluc2VydCBhbnkgb3RoZXIgTk9OLUlFIGh0bWwgY29udGVudCBoZXJlIC0tPgoAPC9CT0RZPgo8L0hUTUw+CgA8SEVBRD4APE1FVEEgaHR0cC1lcXVpdj0iQ29udGVudC1UeXBlIiBjb250ZW50PSJ0ZXh0L2h0bWw7IGNoYXJzZXQ9VVRGLTgiPgoAPFRJVExFPgA8L1RJVExFPgA8IS0tIFBhZ2VzOiAlZCAtLT4KACAgIDxTQ1JJUFQgTEFOR1VBR0U9J0phdmFzY3JpcHQnPgoAICAgZnVuY3Rpb24gYnJvd3NlcmNoZWNrKCkKACAgIHsKACAgICAgIHZhciB1YSA9IHdpbmRvdy5uYXZpZ2F0b3IudXNlckFnZW50CgAgICAgICB2YXIgbXNpZSA9IHVhLmluZGV4T2YgKCAnTVNJRSAnICkKACAgICAgIHZhciBpZXZlcnM7CgAgICAgICB2YXIgaXRlbTsKACAgICAgIHZhciBWTUx5ZXM9bmV3IEFycmF5KCdfVk1MMV8nLCdfVk1MMl8nKTsKACAgICAgIHZhciBWTUxubz1uZXcgQXJyYXkoJ19ub3RWTUwxXycsJ19ub3RWTUwyXycpOwoAICAgICAgaWYgKCBtc2llID4gMCApeyAgICAgIC8vIElmIEludGVybmV0IEV4cGxvcmVyLCByZXR1cm4gdmVyc2lvbiBudW1iZXIKACAgICAgICAgIGlldmVycz0gcGFyc2VJbnQgKHVhLnN1YnN0cmluZyAobXNpZSs1LCB1YS5pbmRleE9mICgnLicsIG1zaWUgKSkpCgAgICAgICB9CgAgICAgICBpZiAoaWV2ZXJzPj01KXsKACAgICAgICBmb3IgKHggaW4gVk1MeWVzKXsKACAgICAgICAgIGl0ZW0gPSBkb2N1bWVudC5nZXRFbGVtZW50QnlJZChWTUx5ZXNbeF0pOwoAICAgICAgICAgaWYgKGl0ZW0pIHsKACAgICAgICAgICAgaXRlbS5zdHlsZS52aXNpYmlsaXR5PSd2aXNpYmxlJzsKACAgICAgICAgIH0KACAgICAgICB9CgAgICAgICAgZm9yICh4IGluIFZNTG5vKXsKACAgICAgICAgIGl0ZW0gPSBkb2N1bWVudC5nZXRFbGVtZW50QnlJZChWTUxub1t4XSk7CgAgICAgICAgICAgIGl0ZW0uc3R5bGUudmlzaWJpbGl0eT0naGlkZGVuJzsKACAgICAgfWVsc2V7CgAgICAgIH0KACAgIH0KACAgIDwvU0NSSVBUPgoAPC9IRUFEPgA8Qk9EWSBvbmxvYWQ9J2Jyb3dzZXJjaGVjaygpOyc+CgA8RElWIGlkPSdfVk1MMV8nIHN0eWxlPSJwb3NpdGlvbjpyZWxhdGl2ZTsgZGlzcGxheTppbmxpbmU7IHZpc2liaWxpdHk6aGlkZGVuACB3aWR0aDogJWRwdDsgaGVpZ2h0OiAlZHB0Ij4KADxTVFlMRT4KAHZcOiogeyBiZWhhdmlvcjogdXJsKCNkZWZhdWx0I1ZNTCk7ZGlzcGxheTppbmxpbmUtYmxvY2t9CgA8L1NUWUxFPgoAPHhtbDpuYW1lc3BhY2UgbnM9InVybjpzY2hlbWFzLW1pY3Jvc29mdC1jb206dm1sIiBwcmVmaXg9InYiIC8+CgAgPHY6Z3JvdXAgc3R5bGU9InBvc2l0aW9uOnJlbGF0aXZlOyAAIHdpZHRoOiAlZHB0OyBoZWlnaHQ6ICVkcHQiACBjb29yZG9yaWdpbj0iMCwwIiBjb29yZHNpemU9IiVkLCVkIiA+ADxIVE1MPgoACjwhLS0gR2VuZXJhdGVkIGJ5IAAgdmVyc2lvbiAAICgAKQotLT4KAGFxdWEAZnVjaHNpYQBsaW1lAG9saXZlAHRlYWwAdm1sAHZtbDp2bWwALy8qKiogY29tbWVudDogJXMKAC8vKioqIHBvbHlsaW5lCgBzY2FsZSAgICA8JTkuM2YsICU5LjNmLCAlOS4zZj4KAHJvdGF0ZSAgIDwlOS4zZiwgJTkuM2YsICU5LjNmPgoAdHJhbnNsYXRlPCU5LjNmLCAlOS4zZiwgJTkuM2Y+CgBzcGhlcmVfc3dlZXAgewogICAgJXMKICAgICVkLAoAbGluZWFyX3NwbGluZQA8JTkuM2YsICU5LjNmLCAlOS4zZj4sICUuM2YKACVzICAgICVzACAgICB0b2xlcmFuY2UgMC4wMQogICAgJXMgICAgJXMgICAgJXMgICAgJXN9CgAlcyVzACVzIHRyYW5zbWl0ICUuM2YAUmVkAEdyZWVuAEJsdWUAcmdiPCU5LjNmLCAlOS4zZiwgJTkuM2Y+IHRyYW5zbWl0ICUuM2YAb29wcywgaW50ZXJuYWwgZXJyb3I6IHVuaGFuZGxlZCBjb2xvciB0eXBlPSVkICVzCgBndnJlbmRlcl9jb3JlX3Bvdi5jAHBvdl9jb2xvcl9hc19zdHIAcGlnbWVudCB7IGNvbG9yICVzIH0KAHBvdiByZW5kZXJlcjplbCAtICVzCgAvLyoqKiBiZXppZXIKAGJfc3BsaW5lACAgICAgICAgdG9sZXJhbmNlIDAuMDEKICAgICVzICAgICVzICAgICVzICAgICVzfQoALy8qKiogcG9seWdvbgoAICAgIHRvbGVyYW5jZSAwLjEKICAgICVzICAgICVzICAgICVzICAgICVzfQoAcG9seWdvbiB7ICVkLAoAPCU5LjNmLCAlOS4zZiwgJTkuM2Y+ACVzCiAgICAlcwAKICAgICVzICAgICVzICAgICVzICAgICVzfQoALy8qKiogZWxsaXBzZQoAdG9ydXMgeyAlLjNmLCAlLjNmCiAgICAlcyAgICAlcyAgICAlcyAgICAlc30KAHNwaGVyZSB7PCU5LjNmLCAlOS4zZiwgJTkuM2Y+LCAxLjAKICAgICVzICAgICVzICAgICVzICAgICVzfQoALy8qKiogdGV4dHNwYW46ICVzLCBmb250c2l6ZSA9ICUuM2YsIGZvbnRuYW1lID0gJXMKAHNjYWxlICUuM2YKAHRleHQgewogICAgdHRmICIlcyIsCiAgICAiJXMiLCAlLjNmLCAlLjNmCiAgICAlcyAgICAlcyAgICAlcyAgICAlcyAgICAlc30KACAgICBub19zaGFkb3cKAC8vKioqIGVuZF9lZGdlCgAvLyoqKiBiZWdpbl9lZGdlCgAvLyoqKiBlbmRfbm9kZQoALy8qKiogYmVnaW5fbm9kZTogJXMKAC8vKioqIGVuZF9jbHVzdGVyCgAvLyoqKiBiZWdpbl9jbHVzdGVyCgAvLyoqKiBlbmRfcGFnZQoALy8qKiogYmVnaW5fcGFnZQoALy8qKiogZW5kX2xheWVyCgAvLyoqKiBiZWdpbl9sYXllcjogJXMsICVkLyVkCgAvLyoqKiBlbmRfZ3JhcGgKAC8vKioqIGJlZ2luX2dyYXBoICVzCgBjYW1lcmEgeyBsb2NhdGlvbiA8JS4zZiAsICUuM2YgLCAlLjNmPgogICAgICAgICBsb29rX2F0ICA8JS4zZiAsICUuM2YgLCAlLjNmPgogICAgICAgICByaWdodCB4ICogaW1hZ2Vfd2lkdGggLyBpbWFnZV9oZWlnaHQKICAgICAgICAgYW5nbGUgJS4zZgp9CgAvL3NreQpwbGFuZSB7IDwwLCAxLCAwPiwgMSBob2xsb3cKICAgIHRleHR1cmUgewogICAgICAgIHBpZ21lbnQgeyBib3pvIHR1cmJ1bGVuY2UgMC45NQogICAgICAgICAgICBjb2xvcl9tYXAgewogICAgICAgICAgICAgICAgWzAuMDAgcmdiIDwwLjA1LCAwLjIwLCAwLjUwPl0KICAgICAgICAgICAgICAgIFswLjUwIHJnYiA8MC4wNSwgMC4yMCwgMC41MD5dCiAgICAgICAgICAgICAgICBbMC43NSByZ2IgPDEuMDAsIDEuMDAsIDEuMDA+XQogICAgICAgICAgICAgICAgWzAuNzUgcmdiIDwwLjI1LCAwLjI1LCAwLjI1Pl0KICAgICAgICAgICAgICAgIFsxLjAwIHJnYiA8MC41MCwgMC41MCwgMC41MD5dCiAgICAgICAgICAgIH0KICAgICAgICAgICAgc2NhbGUgPDEuMDAsIDEuMDAsIDEuNTA+ICogMi41MAogICAgICAgICAgICB0cmFuc2xhdGUgPDAuMDAsIDAuMDAsIDAuMDA+CiAgICAgICAgfQogICAgICAgIGZpbmlzaCB7IGFtYmllbnQgMSBkaWZmdXNlIDAgfQogICAgfQogICAgc2NhbGUgMTAwMDAKfQovL21pc3QKZm9nIHsgZm9nX3R5cGUgMgogICAgZGlzdGFuY2UgNTAKICAgIGNvbG9yIHJnYiA8MS4wMCwgMS4wMCwgMS4wMD4gKiAwLjc1CiAgICBmb2dfb2Zmc2V0IDAuMTAKICAgIGZvZ19hbHQgMS41MAogICAgdHVyYnVsZW5jZSAxLjc1Cn0KLy9nbmQKcGxhbmUgeyA8MC4wMCwgMS4wMCwgMC4wMD4sIDAKICAgIHRleHR1cmUgewogICAgICAgIHBpZ21lbnR7IGNvbG9yIHJnYiA8MC4yNSwgMC40NSwgMC4wMD4gfQogICAgICAgIG5vcm1hbCB7IGJ1bXBzIDAuNzUgc2NhbGUgMC4wMSB9CiAgICAgICAgZmluaXNoIHsgcGhvbmcgMC4xMCB9CiAgICB9Cn0KAGxpZ2h0X3NvdXJjZSB7IDwxNTAwLDMwMDAsLTI1MDA+IGNvbG9yIFdoaXRlIH0KACN2ZXJzaW9uIDMuNjsKAGdsb2JhbF9zZXR0aW5ncyB7IGFzc3VtZWRfZ2FtbWEgMS4wIH0KACNkZWZhdWx0IHsgZmluaXNoIHsgYW1iaWVudCAwLjEgZGlmZnVzZSAwLjkgfSB9CgAjaW5jbHVkZSAiY29sb3JzLmluYyIKI2luY2x1ZGUgInRleHR1cmVzLmluYyIKI2luY2x1ZGUgInNoYXBlcy5pbmMiCgAjZGVjbGFyZSAlcyA9ICVzOwoAQmxhY2sAV2hpdGUAYmFrZXJzY2hvYwBicmFzcwBicmlnaHRnb2xkAGJyb256ZQBicm9uemUyAGNsZWFyAGNvb2xjb3BwZXIAY29wcGVyAGRhcmticm93bgBkYXJrcHVycGxlAGRhcmt0YW4AZGFya3dvb2QAZGtncmVlbmNvcHBlcgBkdXN0eXJvc2UAZmVsZHNwYXIAZmxlc2gAZ3JheTA1AGdyZWVuY29wcGVyAGh1bnRlcnNncmVlbgBsaWdodF9wdXJwbGUAbGlnaHR3b29kAG1hbmRhcmlub3JhbmdlAG1lZGl1bWZvcmVzdGdyZWVuAG1lZGl1bWdvbGRlbnJvZABtZWRpdW13b29kAG1lZF9wdXJwbGUAbWljYQBuZW9uYmx1ZQBuZW9ucGluawBuZXdtaWRuaWdodGJsdWUAbmV3dGFuAG9sZGdvbGQAcXVhcnR6AHJpY2hibHVlAHNjYXJsZXQAc2VtaVN3ZWV0Q2hvYwBzaWx2ZXIAc3BpY3lwaW5rAHN1bW1lcnNreQB2ZXJ5ZGFya2Jyb3duAHZlcnlfbGlnaHRfcHVycGxlAHBvdgBwb3Y6cG92ACVzICVzCgAuXCIgACAlZCAlZAAgJXMKACAlZABmaWxsIABlbGxpcHNlIGF0dHJzJWQgJXN3aWQgJS41ZiBodCAlLjVmIGF0ICglLjVmLCUuNWYpOwoALmZ0ICVzCgAucHMgJWQqXG4oU0Z1LyUuMGZ1CgAiJXMiIGF0ICglLjVmLCUuNWYpOwoAJTAzbwAlcyVzIGlzIG5vdCBhIHRyb2ZmIGZvbnQKAGRvdCBwaWMgcGx1Z2luOiAAUgBdCi5QRQoALlBTICUuNWYgJS41ZgoAJXMgdG8gY2hhbmdlIGRyYXdpbmcgc2l6ZSwgbXVsdGlwbHkgdGhlIHdpZHRoIGFuZCBoZWlnaHQgb24gdGhlIC5QUyBsaW5lIGFib3ZlIGFuZCB0aGUgbnVtYmVyIG9uIHRoZSB0d28gbGluZXMgYmVsb3cgKHJvdW5kZWQgdG8gdGhlIG5lYXJlc3QgaW50ZWdlcikgYnkgYSBzY2FsZSBmYWN0b3IKAC5uciBTRiAlLjBmCnNjYWxldGhpY2tuZXNzID0gJS4wZgoAJXMgZG9uJ3QgY2hhbmdlIGFueXRoaW5nIGJlbG93IHRoaXMgbGluZSBpbiB0aGlzIGRyYXdpbmcKACVzIG5vbi1mYXRhbCBydW4tdGltZSBwaWMgdmVyc2lvbiBkZXRlcm1pbmF0aW9uLCB2ZXJzaW9uIDIKAGJveHJhZD0yLjAgJXMgd2lsbCBiZSByZXNldCB0byAwLjAgYnkgZ3BpYyBvbmx5CgBzY2FsZT0xLjAgJXMgcmVxdWlyZWQgZm9yIGNvbXBhcmlzb25zCgAlcyBib3hyYWQgaXMgbm93IDAuMCBpbiBncGljLCBlbHNlIGl0IHJlbWFpbnMgMi4wCgAlcyBkYXNod2lkIGlzIDAuMSBpbiAxMHRoIEVkaXRpb24sIDAuMDUgaW4gRFdCIDIgYW5kIGluIGdwaWMKACVzIGZpbGx2YWwgaXMgMC4zIGluIDEwdGggRWRpdGlvbiAoZmlsbCAwIG1lYW5zIGJsYWNrKSwgMC41IGluIGdwaWMgKGZpbGwgMCBtZWFucyB3aGl0ZSksIHVuZGVmaW5lZCBpbiBEV0IgMgoAJXMgZmlsbCBoYXMgbm8gbWVhbmluZyBpbiBEV0IgMiwgZ3BpYyBjYW4gdXNlIGZpbGwgb3IgZmlsbGVkLCAxMHRoIEVkaXRpb24gdXNlcyBmaWxsIG9ubHkKACVzIERXQiAyIGRvZXNuJ3QgdXNlIGZpbGwgYW5kIGRvZXNuJ3QgZGVmaW5lIGZpbGx2YWwKACVzIHJlc2V0IHdvcmtzIGluIGdwaWMgYW5kIDEwdGggZWRpdGlvbiwgYnV0IGlzbid0IGRlZmluZWQgaW4gRFdCIDIKACVzIERXQiAyIGNvbXBhdGliaWxpdHkgZGVmaW5pdGlvbnMKAGlmIGJveHJhZCA+IDEuMCAmJiBkYXNod2lkIDwgMC4wNzUgdGhlbiBYCglmaWxsdmFsID0gMTsKCWRlZmluZSBmaWxsIFkgWTsKCWRlZmluZSBzb2xpZCBZIFk7CglkZWZpbmUgcmVzZXQgWSBzY2FsZT0xLjAgWTsKWAoAcmVzZXQgJXMgc2V0IHRvIGtub3duIHN0YXRlCgAlcyBHTlUgcGljIHZzLiAxMHRoIEVkaXRpb24gZFwoZSd0ZW50ZQoAaWYgZmlsbHZhbCA+IDAuNCB0aGVuIFgKCWRlZmluZSBzZXRmaWxsdmFsIFkgZmlsbHZhbCA9IDEgLSBZOwoJZGVmaW5lIGJvbGQgWSB0aGlja25lc3MgMiBZOwoACSVzIGlmIHlvdSB1c2UgZ3BpYyBhbmQgaXQgYmFyZnMgb24gZW5jb3VudGVyaW5nICJzb2xpZCIsCgAJJXMJaW5zdGFsbCBhIG1vcmUgcmVjZW50IHZlcnNpb24gb2YgZ3BpYyBvciBzd2l0Y2ggdG8gRFdCIG9yIDEwdGggRWRpdGlvbiBwaWM7CgAJJXMJc29ycnksIHRoZSBncm9mZiBmb2xrcyBjaGFuZ2VkIGdwaWM7IHNlbmQgYW55IGNvbXBsYWludCB0byB0aGVtOwoAWCBlbHNlIFoKCWRlZmluZSBzZXRmaWxsdmFsIFkgZmlsbHZhbCA9IFk7CglkZWZpbmUgYm9sZCBZIFk7CglkZWZpbmUgZmlsbGVkIFkgZmlsbCBZOwpaCgAlcyBhcnJvd2hlYWQgaGFzIG5vIG1lYW5pbmcgaW4gRFdCIDIsIGFycm93aGVhZCA9IDcgbWFrZXMgZmlsbGVkIGFycm93aGVhZHMgaW4gZ3BpYyBhbmQgaW4gMTB0aCBFZGl0aW9uCgAlcyBhcnJvd2hlYWQgaXMgdW5kZWZpbmVkIGluIERXQiAyLCBpbml0aWFsbHkgMSBpbiBncGljLCAyIGluIDEwdGggRWRpdGlvbgoAYXJyb3doZWFkID0gNyAlcyBub3QgdXNlZCBieSBncmFwaHZpegoAJXMgR05VIHBpYyBzdXBwb3J0cyBhIGJveHJhZCB2YXJpYWJsZSB0byBkcmF3IGJveGVzIHdpdGggcm91bmRlZCBjb3JuZXJzOyBEV0IgYW5kIDEwdGggRWQuIGRvIG5vdAoAYm94cmFkID0gMCAlcyBubyByb3VuZGVkIGNvcm5lcnMgaW4gZ3JhcGh2aXoKACVzIEdOVSBwaWMgc3VwcG9ydHMgYSBsaW5ldGhpY2sgdmFyaWFibGUgdG8gc2V0IGxpbmUgdGhpY2tuZXNzOyBEV0IgYW5kIDEwdGggRWQuIGRvIG5vdAoAbGluZXRoaWNrID0gMDsgb2xkbGluZXRoaWNrID0gbGluZXRoaWNrCgAlcyAuUFMgdy9vIGFyZ3MgY2F1c2VzIEdOVSBwaWMgdG8gc2NhbGUgZHJhd2luZyB0byBmaXQgOC41eDExIHBhcGVyOyBEV0IgZG9lcyBub3QKACVzIG1heHBzaHQgYW5kIG1heHBzd2lkIGhhdmUgbm8gbWVhbmluZyBpbiBEV0IgMi4wLCBzZXQgcGFnZSBib3VuZGFyaWVzIGluIGdwaWMgYW5kIGluIDEwdGggRWRpdGlvbgoAJXMgbWF4cHNodCBhbmQgbWF4cHN3aWQgYXJlIHByZWRlZmluZWQgdG8gMTEuMCBhbmQgOC41IGluIGdwaWMKAG1heHBzaHQgPSAlZgptYXhwc3dpZCA9ICVmCgBEb3Q6IFsKAGRlZmluZSBhdHRyczAgJSUgJSU7IGRlZmluZSB1bmZpbGxlZCAlJSAlJTsgZGVmaW5lIHJvdW5kZWQgJSUgJSU7IGRlZmluZSBkaWFnb25hbHMgJSUgJSUKACVzJXMgdW5zdXBwb3J0ZWQKAHJvdGF0aW9uACVzIHJlc3RvcmUgcG9pbnQgc2l6ZSBhbmQgZm9udAoucHMgXG4oLlMKLmZ0IFxuKERGCgAlcyBDcmVhdG9yOiAlcyB2ZXJzaW9uICVzICglcykKACVzIFRpdGxlOiAlcwoAJXMgc2F2ZSBwb2ludCBzaXplIGFuZCBmb250Ci5uciAuUyBcbigucwoubnIgREYgXG4oLmYKAHBpYwBwaWM6cGljAHBuZzpzdmcAZ2lmOnN2ZwBqcGVnOnN2ZwBqcGU6c3ZnAGpwZzpzdmcAcG5nOmZpZwBnaWY6ZmlnAGpwZWc6ZmlnAGpwZTpmaWcAanBnOmZpZwBwbmc6dnJtbABnaWY6dnJtbABqcGVnOnZybWwAanBlOnZybWwAanBnOnZybWwAZXBzOnBzAHBzOnBzAChsaWIpOnBzAHBuZzptYXAAZ2lmOm1hcABqcGVnOm1hcABqcGU6bWFwAGpwZzptYXAAcHM6bWFwAGVwczptYXAAc3ZnOm1hcABwbmc6ZG90AGdpZjpkb3QAanBlZzpkb3QAanBlOmRvdABqcGc6ZG90AHBzOmRvdABlcHM6ZG90AHN2Zzpkb3QAcG5nOnhkb3QAZ2lmOnhkb3QAanBlZzp4ZG90AGpwZTp4ZG90AGpwZzp4ZG90AHBzOnhkb3QAZXBzOnhkb3QAc3ZnOnhkb3QAc3ZnOnN2ZwBwbmc6dm1sAGdpZjp2bWwAanBlZzp2bWwAanBlOnZtbABqcGc6dm1sAGdpZjp0awBpbWFnZSBjcmVhdGUgcGhvdG8gInBob3RvXyVzIiAtZmlsZSAiJXMiCgAkYyBjcmVhdGUgaW1hZ2UgJS4yZiAlLjJmIC1pbWFnZSAicGhvdG9fJXMiCgA8djppbWFnZSBzcmM9IiVzIiBzdHlsZT0iIHBvc2l0aW9uOmFic29sdXRlOyB3aWR0aDolLjJmOyBoZWlnaHQ6JS4yZjsgbGVmdDolLjJmIDsgdG9wOiUuMmYiACAvPgoAZ3Zsb2FkaW1hZ2VfY29yZS5jAGNvcmVfbG9hZGltYWdlX3BzbGliAFsgACVnICVnIABdICAlZCB0cnVlICVzCgBdICAlZCBmYWxzZSAlcwoAY29yZV9sb2FkaW1hZ2VfcHMAZ3NhdmUgJWcgJWcgdHJhbnNsYXRlIG5ld3BhdGgKAHVzZXJfc2hhcGVfJWQKAGdyZXN0b3JlCgBjb3JlX2xvYWRpbWFnZV92cm1sAFNoYXBlIHsKACAgYXBwZWFyYW5jZSBBcHBlYXJhbmNlIHsKACAgICBtYXRlcmlhbCBNYXRlcmlhbCB7CgAgICAgICBhbWJpZW50SW50ZW5zaXR5IDAuMzMKACAgICAgICAgZGlmZnVzZUNvbG9yIDEgMSAxCgAgICAgfQoAICAgIHRleHR1cmUgSW1hZ2VUZXh0dXJlIHsgdXJsICIlcyIgfQoAICB9CgBjb3JlX2xvYWRpbWFnZV9maWcAJWQgJWQgJWQgJWQgJWQgJWQgJWQgJWQgJWQgJS4xZiAlZCAlZCAlZCAlZCAlZCAlZAogJWQgJXMKACAlZCAlZCAlZCAlZCAlZCAlZCAlZCAlZCAlZCAlZAoAY29yZV9sb2FkaW1hZ2Vfc3ZnADxpbWFnZSB4bGluazpocmVmPSIAIiB3aWR0aD0iJWdweCIgaGVpZ2h0PSIlZ3B4IiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWlkWU1pZCBtZWV0IiB4PSIlZyIgeT0iJWciACB0cmFuc2Zvcm09InJvdGF0ZSglZCAlZyAlZykiACIgd2lkdGg9IiVncHgiIGhlaWdodD0iJWdweCIgcHJlc2VydmVBc3BlY3RSYXRpbz0ieE1pbllNaW4gbWVldCIgeD0iJWciIHk9IiVnIgAvPgoAZG90X2xheW91dABwaGFzZQBkb3QgZG9lcyBub3Qgc3VwcG9ydCB0aGUgYXNwZWN0IGF0dHJpYnV0ZSBmb3IgZGlzY29ubmVjdGVkIGdyYXBocyBvciBncmFwaHMgd2l0aCBjbHVzdGVycwoAY29tcG91bmQAdiA9PSBuAGRvdGluaXQuYwByZW1vdmVfZnJvbV9yYW5rAG9yZGVyAGVkZ2UgbGFiZWxzIHdpdGggc3BsaW5lcz1jdXJ2ZWQgbm90IHN1cHBvcnRlZCBpbiBkb3QgLSB1c2UgeGxhYmVscwoARURfbGFiZWwoZmUpAGRvdHNwbGluZXMuYwBfZG90X3NwbGluZXMAZmxhdCBlZGdlIGJldHdlZW4gYWRqYWNlbnQgbm9kZXMgb25lIG9mIHdoaWNoIGhhcyBhIHJlY29yZCBzaGFwZSAtIHJlcGxhY2UgcmVjb3JkcyB3aXRoIEhUTUwtbGlrZSBsYWJlbHMKACAgRWRnZSAlcyAlcyAlcwoAeHh4ADEwMDAwAHslc30AYXV4ZwBsYWJlbF9mbG9hdABmaXhlZAAobCA9IEVEX2xhYmVsKGZlKSkAc2V0RWRnZUxhYmVsUG9zAGUgIT0gTlVMTABmYXN0Z3IuYwBkZWxldGVfZmFzdF9lZGdlAG4gIT0gTkRfbmV4dChuKQBmYXN0X25vZGUAdSAhPSB2AGZhc3Rfbm9kZWFwcABORF9uZXh0KHYpID09IE5VTEwAZmluZF9mYXN0X25vZGUoZywgbikAZGVsZXRlX2Zhc3Rfbm9kZQBkZWxldGVfZmxhdF9lZGdlAG1lcmdlX29uZXdheSBnbGl0Y2gKAG1lcmdlX29uZXdheQBzYWZlX2RlbGV0ZV9mYXN0X2VkZ2UAbGcAaW5mbwBjb21wAGNudCA9PSBzegBtaW5jcm9zcy5jAGZpeExhYmVsT3JkZXIAcmVtaW5jcm9zcwBtaW5jcm9zcyAlczogJWQgY3Jvc3NpbmdzLCAlLjJmIHNlY3MuCgB2AG5laWdoYm9yAChydiA9PSAwKSB8fCAoTkRfb3JkZXIocnYpLU5EX29yZGVyKHYpKSpkaXIgPiAwAGNvbnN0cmFpbmluZ19mbGF0X2VkZ2UoZyx2LGUpID09IEZBTFNFAGZsYXRfcmVvcmRlcgBORF9yYW5rKHYpID09IHIAcG9zdG9yZGVyAGZsYXRpbmRleChhZ2hlYWQoZSkpIDwgTS0+bnJvd3MAZmxhdF9zZWFyY2gAZmxhdGluZGV4KGFndGFpbChlKSkgPCBNLT5uY29scwBvdXQAb3JkZXJpbmcgJyVzJyBub3QgcmVjb2duaXplZC4KAG9yZGVyaW5nICclcycgbm90IHJlY29nbml6ZWQgZm9yIG5vZGUgJyVzJy4KAG1lcmdlMjogZ3JhcGggJXMsIHJhbmsgJWQgaGFzIG9ubHkgJWQgPCAlZCBub2RlcwoAbWluY3Jvc3M6IHBhc3MgJWQgaXRlciAlZCB0cnlpbmcgJWQgY3VyX2Nyb3NzICVkIGJlc3RfY3Jvc3MgJWQKAE5EX29yZGVyKHYpIDwgTkRfb3JkZXIodykAYmFsYW5jZQB0cmFuc3Bvc2Vfc3RlcABzdXJwcmlzZQoAaW5zdGFsbF9pbl9yYW5rLCBsaW5lICVkOiAlcyAlcyByYW5rICVkIGkgPSAlZCBhbiA9IDAKAEdEX3JhbmsoZylbcl0ubiA8PSBHRF9yYW5rKGcpW3JdLmFuAGluc3RhbGxfaW5fcmFuawBpbnN0YWxsX2luX3JhbmssIGxpbmUgJWQ6IE5EX29yZGVyKCVzKSBbJWRdID4gR0RfcmFuayhSb290KVslZF0uYW4gWyVkXQoAaW5zdGFsbF9pbl9yYW5rLCBsaW5lICVkOiByYW5rICVkIG5vdCBpbiByYW5rIHJhbmdlIFslZCwlZF0KAGluc3RhbGxfaW5fcmFuaywgbGluZSAlZDogR0RfcmFuayhnKVslZF0udiArIE5EX29yZGVyKCVzKSBbJWRdID4gR0RfcmFuayhnKVslZF0uYXYgKyBHRF9yYW5rKFJvb3QpWyVkXS5hbiBbJWRdCgBfbmV3X3JhbmsAbWNsaW1pdAByYW5rKGcsIDIsIG5zaXRlcjIoZykpID09IDAAcG9zaXRpb24uYwBkb3RfcG9zaXRpb24AQVI9JTAuNGxmCSBBcmVhPSAlMC40bGYJAER1bW15PSVkCgBHb2luZyB0byBhcHBseSBhbm90aGVyIGV4cGFuc2lvbi4KAG5leHQjaXRlcj0lZAoAaHAAY29ubmVjdEdyYXBoAEVkZ2UgbGVuZ3RoICVmIGxhcmdlciB0aGFuIG1heGltdW0gJXUgYWxsb3dlZC4KQ2hlY2sgZm9yIG92ZXJ3aWRlIG5vZGUocykuCgBuc2xpbWl0AGNvbnRhaW5fbm9kZXMgY2x1c3QgJXMgcmFuayAlZCBtaXNzaW5nIG5vZGUKAG5zbGltaXQxAG5ld3JhbmsATWF4cmFuayA9ICVkLCBtaW5yYW5rID0gJWQKAGxlYWRlciAhPSBOVUxMAHJhbmsuYwBjbHVzdGVyX2xlYWRlcgAoTkRfVUZfc2l6ZShuKSA8PSAxKSB8fCAobiA9PSBsZWFkZXIpAGFnaGVhZChlKSA9PSBVRl9maW5kKGFnaGVhZChlKSkAbWlubWF4X2VkZ2VzAGFndGFpbChlKSA9PSBVRl9maW5kKGFndGFpbChlKSkAcmFuawBzYW1lAG1pbgBzb3VyY2UAbWF4AHNpbmsAbGV2ZWwgYXNzaWdubWVudCBjb25zdHJhaW50cwBsZXZlbCBncmFwaCByZWMAf3Jvb3QAf3RvcAB/Ym90AGNvbXBhY3QAX3dlYWtfJWQAcmFua2luZzogZmFpbHVyZSB0byBjcmVhdGUgc3Ryb25nIGNvbnN0cmFpbnQgZWRnZSBiZXR3ZWVuIG5vZGVzICVzIGFuZCAlcwoAJXMgaGFzIHVucmVjb2duaXplZCByYW5rPSVzAGxldmVsIGVkZ2UgcmVjAGxldmVsIG5vZGUgcmVjAHNhbWVoZWFkAHNhbWV0YWlsAHRvbyBtYW55ICg+ICVkKSBzYW1le2hlYWQsdGFpbH0gZ3JvdXBzIGZvciBub2RlICVzCgBjb21iaUFSID0gJWxmCgAlbGYsJWQAdGhlIGFzcGVjdCBhdHRyaWJ1dGUgaGFzIGJlZW4gZGlzYWJsZWQgZHVlIHRvIGltcGxlbWVudGF0aW9uIGZsYXdzIC0gYXR0cmlidXRlIGlnbm9yZWQuCgBFRF90b192aXJ0KGUpID09IE5VTEwAY2xhc3MyLmMAbWVyZ2VfY2hhaW4ARURfdG9fdmlydChvcmlnKSA9PSBOVUxMAG1ha2VfY2hhaW4ARURfdG9fdmlydChvcmlnKSAhPSBOVUxMAE5EX3JhbmsoZnJvbSkgPCBORF9yYW5rKHRvKQBjbHVzdGVyLmMAbWFwX3BhdGgAJXMgd2FzIGFscmVhZHkgaW4gYSByYW5rc2V0LCBkZWxldGVkIGZyb20gY2x1c3RlciAlcwoAbGhlYWQAbHRhaWwAJXMgLT4gJXM6IHNwbGluZSBzaXplID4gMSBub3Qgc3VwcG9ydGVkCgAlcyAtPiAlczogaGVhZCBub3QgaW5zaWRlIGhlYWQgY2x1c3RlciAlcwoAJXMgLT4gJXM6IHRhaWwgaXMgaW5zaWRlIGhlYWQgY2x1c3RlciAlcwoAYmV6LT5zZmxhZwBjb21wb3VuZC5jAG1ha2VDb21wb3VuZEVkZ2UAYmV6LT5lZmxhZwAlcyAtPiAlczogdGFpbCBub3QgaW5zaWRlIHRhaWwgY2x1c3RlciAlcwoAJXMgLT4gJXM6IGhlYWQgaXMgaW5zaWRlIHRhaWwgY2x1c3RlciAlcwoAc2VnbWVudCBbJXMsJXNdIGRvZXMgbm90IGludGVyc2VjdCBib3ggbGw9JXMsdXI9JXMKAGJveEludGVyc2VjdGYAKCUuNWcsJS41ZykAY2x1c3RlciBuYW1lZCAlcyBub3QgZm91bmQKAGNvbmNlbnRyYXRlPXRydWUgbWF5IG5vdCB3b3JrIGNvcnJlY3RseS4KAHJlYnVpbHRkX3ZsaXN0czogcmFuayBsZWFkICVzIG5vdCBpbiBvcmRlciAlZCBvZiByYW5rICVkCgBkZWdlbmVyYXRlIGNvbmNlbnRyYXRlZCByYW5rICVzLCVkCgBORF9pbihyaWdodCkuc2l6ZSArIE5EX291dChyaWdodCkuc2l6ZSA9PSAwAGNvbmMuYwBtZXJnZXZpcnR1YWwAZG90OiBPdXQgb2YgbWVtb3J5CgBORF9vdXQodikuc2l6ZSA9PSAyAGZsYXQuYwBzZXRib3VuZHMAR0RfbWlucmFuayhnKSA9PSAwAGFib21pbmF0aW9uAEVycm9yAFdhcm5pbmcAJXM6IAB1c2Vyb3V0OiBjb3VsZCBub3QgYWxsb2NhdGUgbWVtb3J5CgBfQUdfc3RyZGF0YQBfQUdfZGF0YWRpY3QAYWdkaWN0b2Y6IHVua25vd24ga2luZCAlZAoAJWMlbGQAbWVtb3J5IGFsbG9jYXRpb24gZmFpbHVyZQBhZ2RlbGV0ZSBvbiB3cm9uZyBncmFwaABfQUdfcGVuZGluZwBhZ3JlY29yZF9jYWxsYmFjayBvZiBhIGJhZCBvYmplY3QAcGVuZCBkaWN0b2YgYSBiYWQgb2JqZWN0AG1vdmUgdG8gZnJvbnQgbG9jayBpbmNvbnNpc3RlbmN5AFxcAGZhdGFsIGZsZXggc2Nhbm5lciBpbnRlcm5hbCBlcnJvci0tbm8gYWN0aW9uIGZvdW5kACVzCgBmYXRhbCBmbGV4IHNjYW5uZXIgaW50ZXJuYWwgZXJyb3ItLWVuZCBvZiBidWZmZXIgbWlzc2VkAGZhdGFsIGVycm9yIC0gc2Nhbm5lciBpbnB1dCBidWZmZXIgb3ZlcmZsb3cAb3V0IG9mIGR5bmFtaWMgbWVtb3J5IGluIGFhZ19nZXRfbmV4dF9idWZmZXIoKQBpbnB1dABzeW50YXggYW1iaWd1aXR5IC0gYmFkbHkgZGVsaW1pdGVkIG51bWJlciAnACcgaW4gbGluZSAlZCBvZiAAIHNwbGl0cyBpbnRvIHR3byB0b2tlbnMKACVzAGxpbmUAJWQgJTFbIl0lbgBvdXQgb2YgZHluYW1pYyBtZW1vcnkgaW4gYWFnX2NyZWF0ZV9idWZmZXIoKQBvdXQgb2YgZHluYW1pYyBtZW1vcnkgaW4gYWFnZW5zdXJlX2J1ZmZlcl9zdGFjaygpADogACBpbiBsaW5lICVkACBuZWFyICcAIHNjYW5uaW5nIGEgcXVvdGVkIHN0cmluZyAobWlzc2luZyBlbmRxdW90ZT8gbG9uZ2VyIHRoYW4gJWQ/KQAKU3RyaW5nIHN0YXJ0aW5nOiIAIHNjYW5uaW5nIGEgSFRNTCBzdHJpbmcgKG1pc3NpbmcgJz4nPyBiYWQgbmVzdGluZz8gbG9uZ2VyIHRoYW4gJWQ/KQAKU3RyaW5nIHN0YXJ0aW5nOjwAIHNjYW5uaW5nIGEgLyouLi4qLyBjb21tZW50IChtaXNzaW5nICcqLz8gbG9uZ2VyIHRoYW4gJWQ/KQBmbGV4IHNjYW5uZXIgcHVzaC1iYWNrIG92ZXJmbG93ACIiAHN0cmljdABsaW5lbGVuZ3RoADsKACBba2V5PQBdACBbACwKAD0AXyVsZF9TVVNQRUNUAGRpAHN0cmljdCAAewoAXTsKABLu7hQJA+7+7u7uAe7u7gHu7gr+7hMZFe4TAe7u7u4LEe7u7u7u7u7u7gHu7hYJAQEdDxfu7hoXG+7uHO7u7u4BGfvu7u4B7hDu7h7u7u7uAAICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAhcRAgICAgICAgICAgICAhIQAhMCAhYCAgICAgICAgICAgICAgICAgICAgICAgICAhQCFQICAgICAgICAgICAgICAgICAgICAgICAgICAgICDgIPAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgECAwQFBgcICQoLDA0LAwQFDwcDDA0GDA0ODA0aFRYAAQADBw4GDwgMDRITKhARCRAvMBEyFxMNFBIuEhRBEzITLEAqQhksQkYiDA0OIw8JEBEKEBHJEBEtRUb8AQb2Dwf2JAIQES8wNk1OKCY7PCo2MTk9Py86QNhEMD4lN0M1Sys4SUwAAwkAAAABDgILDAgjJCU2Oz0ADRASGxYcEicyIhczHjwGBzUFDxEUGCkAEykAAAAAADcVKB0eACEmNB8wPhksABsAIBoqACs6Li8AMTg5LQACAgEAAwMBAAEAAQEBAAIBAQACAgMBAQAABQABAwEDBQMBAQEBAgABAAQCAAIBAQMCAQADAgEAAQEAAQEBAwAYGRkZGhscHB0dHh4fHyAgISEiIiMkJCYnJSUoKCkpKSoqKysrLCwtLS4vLzAxMTIzNDY1Nzc3ODg4OTk6Ou7u/+7u7u7u7h8g7gDv7u7uDO7u7ggN7u7u+O7u7u7u7vXu/wMIBCEFCxITJxQVFikyQRcYGRosMzRCR0gbShwdLh5PHyBrZXkAYXR0cmlidXRlIG1hY3JvcyBub3QgaW1wbGVtZW50ZWQAJXM6JXMAQ291bGQgbm90IG9wZW4gIiVzIiBmb3Igd3JpdGluZyA6ICVzCgBObyBsaWJ6IHN1cHBvcnQuCgAuJWQAbm9uYW1lLmd2AGd2d3JpdGVfbm9feiBwcm9ibGVtICVkCgBtZW1vcnkgYWxsb2NhdGlvbiBmYWlsdXJlCgBObyBsaWJ6IHN1cHBvcnQKAGd2cHJpbnRmOiAlcwoALTk5OTk5OTk5OTk5OTk5OS45OQBncmFwaHZpegAyLjQwLjEAMjAxNjEyMjUuMDMwNAByZW5kZXIAbGF5b3V0AGRldmljZQBsb2FkaW1hZ2UAZHluYW1pYyBsb2FkaW5nIG5vdCBhdmFpbGFibGUKAFVzaW5nICVzOiAlczolcwoAZ3Z1c2Vyc2hhcGUuYwBndnVzZXJzaGFwZV9maW5kAGd2dXNlcnNoYXBlX2ZpbGVfYWNjZXNzAEZpbGVuYW1lICIlcyIgaXMgdW5zYWZlCgAlcyB3aGlsZSBvcGVuaW5nICVzCgB1cy0+ZgBndnVzZXJzaGFwZV9vcGVuACIlcyIgd2FzIG5vdCBmb3VuZCBhcyBhIGZpbGUgb3IgYXMgYSBzaGFwZSBsaWJyYXJ5IG1lbWJlcgoAL01lZGlhQm94AChbYS16XVthLXpBLVpdKik9IihbXiJdKikiAGNhbm5vdCBjb21waWxlIHJlZ3VsYXIgZXhwcmVzc2lvbiAlcwAlbGYlMnMAcHQAdmlld0JveAAlbGYgJWxmICVsZiAlbGYAaW4AcHgAcGMAIgBjbQBtbQAlJUJvdW5kaW5nQm94OgAB0NHS09TV1tfY2QA8c3ZnAFdFQlAAd2VicAAobGliKQCJUE5HDQoaCgBwbmcAJSFQUy1BZG9iZS0AQk0AYm1wAEdJRjgAZ2lmAP/Y/+AAanBlZwAlUERGLQBwZGYAxdDTxgBlcHMAPD94bWwAeG1sAFJJRkYAcmlmZgAAAAEAAGljbwBMYXlvdXQgdHlwZTogIiVzIiBub3QgcmVjb2duaXplZC4gVXNlIG9uZSBvZjolcwoAJWQgJWQgJWQgJWQATGF5b3V0IHdhcyBub3QgZG9uZQoAZmFpbHVyZSBtYWxsb2MnaW5nIGZvciByZXN1bHQgc3RyaW5nAGdjOiBPdXQgb2YgbWVtb3J5CgBfY2NfAG9yaWcAb3AAY2NvbXBzLmMAbWFwQ2x1c3QAY2NncmFwaGluZm8AY2Nnbm9kZWluZm8AKCU0bGQpICU3bGQgbm9kZXMgJTdsZCBlZGdlcwoAICAgICAgICU3ZCBub2RlcyAlN2QgZWRnZXMgJTdsZCBjb21wb25lbnRzICVzCgBkZwBFcnJvcjogbm9kZSAiJXMiIGJlbG9uZ3MgdG8gdHdvIG5vbi1uZXN0ZWQgY2x1c3RlcnMgIiVzIiBhbmQgIiVzIgoAc29ydHYAcm93IG1ham9yAGNvbHVtbiBtYWpvcgBhcnJheSBwYWNraW5nOiAlcyAlZCByb3dzICVkIGNvbHVtbnMKAGJiWyVzXSAlLjVnICUuNWcgJS41ZyAlLjVnCgBzdGVwIHNpemUgPSAlZAoAcG9zWyVkXSAlZCAlZAoAY2MgKCVkIGNlbGxzKSBhdCAoJWQsJWQpICglZCwlZCkKAGNjICglZCBjZWxscykgYXQgKCVkLCVkKQoAJXMgbm8uIGNlbGxzICVkIFcgJWQgSCAlZAoAICAlZCAlZCBjZWxsCgBsaWJwYWNrOiBkaXNjID0gJWYgKCA8IDApCgBQYWNraW5nOiBjb21wdXRlIGdyaWQgc2l6ZQoAYSAlZiBiICVmIGMgJWYgZCAlZiByICVmCgByb290ICVkICglZikgJWQgKCVmKQoAIHIxICVmIHIyICVmCgBwaW5mbwBwYWNrLmMAZ2V0UGFja0luZm8AICBtYXJnaW4gJWQKAHBhY2ttb2RlAHBhcnNlUGFja01vZGVJbmZvAGFycmF5AGFzcGVjdAAlZgBwYWNrIGluZm86CgAgIG1vZGUgICAlcwoAICBhc3BlY3QgJWYKACAgc2l6ZSAgICVkCgAgIGZsYWdzICAlZAoAdW5kZWZpbmVkAHBhY2sAQXJyb3cgdHlwZSAiJXMiIHVua25vd24gLSBpZ25vcmluZwoAbm9ybWFsAGNyb3cAdGVlAGRvdABpbnYAdmVlAHBlbgBtcHR5AGN1cnZlAGljdXJ2ZQBsAGhhbGYAaW52ZW1wdHkAX2JhY2tncm91bmQAX2RyYXdfAENvdWxkIG5vdCBwYXJzZSAiX2JhY2tncm91bmQiIGF0dHJpYnV0ZSBpbiBncmFwaCAlcwoAICAiJXMiCgBubyBtZW1vcnkgZnJvbSB6bWFsbG9jKCkKAG9iagBlbWl0LmMAcG9wX29ial9zdGF0ZQBjbHVzdAAlbGQAcGFnZSVkLCVkXwBUb3RhbCBzaXplID4gMSBpbiAiJXMiIGNvbG9yIHNwZWMgAElsbGVnYWwgbGVuZ3RoIHZhbHVlIGluICIlcyIgY29sb3IgYXR0cmlidXRlIABjb2xvcnNjaGVtZQBlbWl0X2VkZ2VfbGFiZWwAJXMtJXMAZm9yd2FyZABiYWNrACAtPiAAIC0tIABpbiBlZGdlICVzJXMlcwoAbGFiZWxhbGlnbmVkAGVkZ2VocmVmAGVkZ2VVUkwAbGFiZWxocmVmAGxhYmVsVVJMAHRhaWxocmVmAHRhaWxVUkwAaGVhZGhyZWYAaGVhZFVSTAB0YXJnZXQAZWRnZXRhcmdldABsYWJlbHRhcmdldAB0YWlsdGFyZ2V0AGhlYWR0YXJnZXQAZWRnZXRvb2x0aXAAbGFiZWx0b29sdGlwAHRhaWx0b29sdGlwAGhlYWR0b29sdGlwAAFuZXN0aW5nIG5vdCBhbGxvd2VkIGluIHN0eWxlOiAlcwoAdW5tYXRjaGVkICcpJyBpbiBzdHlsZTogJXMKAHRydW5jYXRpbmcgc3R5bGUgJyVzJwoAdW5tYXRjaGVkICcoJyBpbiBzdHlsZTogJXMKAGFsbABiZ2NvbG9yAGluIGNsdXN0ZXIgJXMKAE1vcmUgdGhhbiAyIGNvbG9ycyBzcGVjaWZpZWQgZm9yIGEgZ3JhZGllbnQgLSBpZ25vcmluZyByZW1haW5pbmcKAGdyYWRpZW50IHBlbiBjb2xvcnMgbm90IHlldCBzdXBwb3J0ZWQuCgBJbWFnZXMgdW5zdXBwb3J0ZWQgaW4gImJhY2tncm91bmQiIGF0dHJpYnV0ZQoAbGF5ZXJzIG5vdCBzdXBwb3J0ZWQgaW4gJXMgb3V0cHV0CgBMYXlvdXQgd2FzIG5vdCBkb25lLiAgTWlzc2luZyBsYXlvdXQgcGx1Z2lucz8gCgBndlJlbmRlckpvYnMgJXM6ICUuMmYgc2Vjcy4KAGxheW91dCB3YXMgbm90IGRvbmUKAHJlbmRlcmVyIGZvciAlcyBpcyB1bmF2YWlsYWJsZQoAcGFnZWRpcj0lcyBpZ25vcmVkCgB2aWV3cG9ydAAlbGYsJWxmLCVsZiwnJVteJ10nACVsZiwlbGYsJWxmLCVbXixdJXMAJWxmLCVsZiwlbGYsJWxmLCVsZgBvdXRwdXRvcmRlcgBvZGVzZmlyc3QAZGdlc2ZpcnN0AGxheWVycwBsYXllcnNlbGVjdABUaGUgbGF5ZXJzZWxlY3QgYXR0cmlidXRlICIlcyIgZG9lcyBub3QgbWF0Y2ggYW55IGxheWVyIHNwZWNpZmVkIGJ5IHRoZSBsYXllcnMgYXR0cmlidXRlIC0gaWdub3JlZC4KAGxheWVyc2VwADoJIABsYXllcmxpc3RzZXAALABUaGUgY2hhcmFjdGVyICclYycgYXBwZWFycyBpbiBib3RoIHRoZSBsYXllcnNlcCBhbmQgbGF5ZXJsaXN0c2VwIGF0dHJpYnV0ZXMgLSBsYXllcmxpc3RzZXAgaWdub3JlZC4KAHBhZABCTABwYWdlZGlyAHNvbGlkAABzZXRsaW5ld2lkdGgAMQAAc3BsLT5zaXplID4gMABpbml0X3NwbGluZXNfYmIAYnouc2l6ZSA+IDAAYmV6aWVyX2JiAGJ6LnNpemUgJSAzID09IDEAbGFiZWwAJWxmAGZvbnRwYXRoAERPVEZPTlRQQVRIAEdERk9OVFBBVEgAaW1hZ2VwYXRoAHF1YW50dW0AcmFua2RpcgBMUgBCVABSTABub2Rlc2VwAHJhbmtzZXAAZXF1YWxseQBzaG93Ym94ZXMAZm9udG5hbWVzAHNpemUAcGFnZQBjZW50ZXIAcm90YXRlAG9yaWVudGF0aW9uAGxhbmRzY2FwZQBjbHVzdGVycmFuawBjb25jZW50cmF0ZQBkcGkAcmVzb2x1dGlvbgBvcmRlcmluZwBncmFkaWVudGFuZ2xlAGZpbGxjb2xvcgBzdHlsZQBmb250c2l6ZQBmb250bmFtZQBmb250Y29sb3IAeGxhYmVsAHBlbndpZHRoAHNpZGVzAHBlcmlwaGVyaWVzAHNrZXcAZGlzdG9ydGlvbgBmaXhlZHNpemUAbm9qdXN0aWZ5AGxheWVyAGdyb3VwAGNvbW1lbnQAdmVydGljZXMAegB3ZWlnaHQAbGFiZWxmbG9hdABkaXIAYXJyb3doZWFkAGFycm93dGFpbABoZWFkbGFiZWwAdGFpbGxhYmVsAGxhYmVsZm9udHNpemUAbGFiZWxmb250bmFtZQBsYWJlbGZvbnRjb2xvcgBsYWJlbGRpc3RhbmNlAGxhYmVsYW5nbGUAbWlubGVuAGRlY29yYXRlAGFycm93c2l6ZQBjb25zdHJhaW50AHRhaWxjbGlwAGhlYWRjbGlwAGlkAGxhYmVsanVzdABsb2NhbABnbG9iYWwAJWxmLCVsZiVjACVsZiVjAHJhdGlvAGF1dG8AY29tcHJlc3MAZXhwYW5kAGZpbGwAZ2QAcHMAc3ZnAGNoYXJzZXQAdXRmLTgAbGF0aW4tMQBsYXRpbjEAbDEASVNPLTg4NTktMQBJU09fODg1OS0xAElTTzg4NTktMQBJU08tSVItMTAwAGJpZy01AGJpZzUAdXRmOABVbnN1cHBvcnRlZCBjaGFyc2V0ICIlcyIgLSBhc3N1bWluZyB1dGYtOAoAaW4gbGFiZWwgb2YgZ3JhcGggJXMKAGluIGxhYmVsIG9mIG5vZGUgJXMKAGluIGxhYmVsIG9mIGVkZ2UgJXMgJXMgJXMKAGtpbmQgPT0gTFRfTk9ORQBsYWJlbHMuYwBtYWtlX2xhYmVsAFxMAFxHAFxFAFxIAFxUACYjMTM7ACYjMTA7ACZxdW90OwAmIzE2MDsAJmFtcDsAJmd0OwAmIzM5OwAmIzQ1OwAmbHQ7ACVzICVkIG5vZGVzICVkIGVkZ2VzIG1heGl0ZXI9JWQgYmFsYW5jZT0lZAoAbmV0d29yayBzaW1wbGV4OiAAJWQgACVzJWQgbm9kZXMgJWQgZWRnZXMgJWQgaXRlciAlLjJmIHNlYwoAdXBkYXRlOiBtaXNtYXRjaGVkIGxjYSBpbiB0cmVldXBkYXRlcwoAVHJlZV9lZGdlLnNpemUgPT0gTl9ub2RlcyAtIDEAbnMuYwBmZWFzaWJsZV90cmVlACFUUkVFX0VER0UoZSkAbWVyZ2VfdHJlZXMAKHIwLT5oZWFwX2luZGV4ID4gLTEpIHx8IChyMS0+aGVhcF9pbmRleCA+IC0xKQBTVHNldFVuaW9uAHItPmhlYXBfaW5kZXggPj0gMABhZGRfdHJlZV9lZGdlOiBtaXNzaW5nIHRyZWUgZWRnZQoAYWRkX3RyZWVfZWRnZTogZW1wdHkgb3V0ZWRnZSBsaXN0CgBhZGRfdHJlZV9lZGdlOiBlbXB0eSBpbmVkZ2UgbGlzdAoAdHJvdWJsZSBpbiBpbml0X3JhbmsKAAklcyAlZAoAc2VhcmNoc2l6ZQBncmFwaCAAIABub2RlIABzdG9wCgAlLjVnAHBvcwByZWN0cwB4bHAAbHAAaGVhZF9scAB0YWlsX2xwAGx3aWR0aABsaGVpZ2h0AGJiACUuNWcsJS41ZywlLjVnACwlLjVnACUuNWcsJS41ZwBzYW1wbGVwb2ludHMAJS41ZyAlLjVnAHMsJS41ZywlLjVnIABlLCUuNWcsJS41ZyAAJS41ZywlLjVnLCUuNWcsJS41ZwAlLjJmACUuNWcsJS41ZywlLjVnLCUuNWcgAC9wYXRoYm94IHsKICAgIC9YIGV4Y2ggbmVnICUuNWcgc3ViIGRlZgogICAgL1kgZXhjaCAlLjVnIHN1YiBkZWYKICAgIC94IGV4Y2ggbmVnICUuNWcgc3ViIGRlZgogICAgL3kgZXhjaCAlLjVnIHN1YiBkZWYKICAgIG5ld3BhdGggeCB5IG1vdmV0bwogICAgWCB5IGxpbmV0bwogICAgWCBZIGxpbmV0bwogICAgeCBZIGxpbmV0bwogICAgY2xvc2VwYXRoIHN0cm9rZQp9IGRlZgoAL3BhdGhib3ggewogICAgL1kgZXhjaCAlLjVnIHN1YiBkZWYKICAgIC9YIGV4Y2ggJS41ZyBzdWIgZGVmCiAgICAveSBleGNoICUuNWcgc3ViIGRlZgogICAgL3ggZXhjaCAlLjVnIHN1YiBkZWYKICAgIG5ld3BhdGggeCB5IG1vdmV0bwogICAgWCB5IGxpbmV0bwogICAgWCBZIGxpbmV0bwogICAgeCBZIGxpbmV0bwogICAgY2xvc2VwYXRoIHN0cm9rZQogfSBkZWYKL2RiZ3N0YXJ0IHsgZ3NhdmUgJS41ZyAlLjVnIHRyYW5zbGF0ZSB9IGRlZgovYXJyb3dsZW5ndGggMTAgZGVmCi9hcnJvd3dpZHRoIGFycm93bGVuZ3RoIDIgZGl2IGRlZgovYXJyb3doZWFkIHsKICAgIGdzYXZlCiAgICByb3RhdGUKICAgIGN1cnJlbnRwb2ludAogICAgbmV3cGF0aAogICAgbW92ZXRvCiAgICBhcnJvd2xlbmd0aCBhcnJvd3dpZHRoIDIgZGl2IHJsaW5ldG8KICAgIDAgYXJyb3d3aWR0aCBuZWcgcmxpbmV0bwogICAgY2xvc2VwYXRoIGZpbGwKICAgIGdyZXN0b3JlCn0gYmluZCBkZWYKL21ha2VhcnJvdyB7CiAgICBjdXJyZW50cG9pbnQgZXhjaCBwb3Agc3ViIGV4Y2ggY3VycmVudHBvaW50IHBvcCBzdWIgYXRhbgogICAgYXJyb3doZWFkCn0gYmluZCBkZWYKL3BvaW50IHsgICAgbmV3cGF0aCAgICAyIDAgMzYwIGFyYyBmaWxsfSBkZWYvbWFrZXZlYyB7CiAgICAvWSBleGNoIGRlZgogICAgL1ggZXhjaCBkZWYKICAgIC95IGV4Y2ggZGVmCiAgICAveCBleGNoIGRlZgogICAgbmV3cGF0aCB4IHkgbW92ZXRvCiAgICBYIFkgbGluZXRvIHN0cm9rZQogICAgWCBZIG1vdmV0bwogICAgeCB5IG1ha2VhcnJvdwp9IGRlZgoAbG9zdCAlcyAlcyBlZGdlCgBubyBwb3NpdGlvbiBmb3IgZWRnZSB3aXRoIGxhYmVsICVzAG5vIHBvc2l0aW9uIGZvciBlZGdlIHdpdGggdGFpbCBsYWJlbCAlcwBubyBwb3NpdGlvbiBmb3IgZWRnZSB3aXRoIGhlYWQgbGFiZWwgJXMAbm8gcG9zaXRpb24gZm9yIGVkZ2Ugd2l0aCB4bGFiZWwgJXMAZm9yY2VsYWJlbHMAJWQgb3V0IG9mICVkIGxhYmVscyBwb3NpdGlvbmVkLgoAJWQgb3V0IG9mICVkIGV4dGVyaW9yIGxhYmVscyBwb3NpdGlvbmVkLgoAJWQgb2JqcyAlZCB4bGFiZWxzIGZvcmNlPSVkIGJiPSglLjAyZiwlLjAyZikgKCUuMDJmLCUuMDJmKQoAb2JqZWN0cwoAIFslZF0gKCUuMDJmLCUuMDJmKSAoJS4wMmYsJS4wMmYpICVwICIlcyIKAHhsYWJlbHMKACBbJWRdICVwIHNldCAlZCAoJS4wMmYsJS4wMmYpICglLjAyZiwlLjAyZikgJXMKAHNoYXBlZmlsZSBub3Qgc2V0IG9yIG5vdCBmb3VuZCBmb3IgZXBzZiBub2RlICVzCgBjb3VsZG4ndCBvcGVuIGVwc2YgZmlsZSAlcwoAJSUlJUJvdW5kaW5nQm94OiAlZCAlZCAlZCAlZAByZWFkAEJvdW5kaW5nQm94IG5vdCBmb3VuZCBpbiBlcHNmIGZpbGUgJXMKAGNhbid0IGZpbmQgbGlicmFyeSBmaWxlICVzCgBjYW4ndCBvcGVuIGxpYnJhcnkgZmlsZSAlcwoARU9GAEJFR0lOAEVORABUUkFJTEVSAC91c2VyX3NoYXBlXyVkIHsKACUlQmVnaW5Eb2N1bWVudDoKACUlRW5kRG9jdW1lbnQKAH0gYmluZCBkZWYKAFVURi04IGlucHV0IHVzZXMgbm9uLUxhdGluMSBjaGFyYWN0ZXJzIHdoaWNoIGNhbm5vdCBiZSBoYW5kbGVkIGJ5IHRoaXMgUG9zdFNjcmlwdCBkcml2ZXIKAGNhbm5vdCByZS1hbGxvY2F0ZSBwcwoAcm91dGVzcGxpbmVzaW5pdDogY2Fubm90IGFsbG9jYXRlIHBzCgByb3V0ZXNwbGluZXM6ICVkIGVkZ2VzLCAlZCBib3hlcyAlLjJmIHNlYwoAaW4gcm91dGVzcGxpbmVzLCBjYW5ub3QgZmluZCBOT1JNQUwgZWRnZQoAaW4gcm91dGVzcGxpbmVzLCBpbGxlZ2FsIHZhbHVlcyBvZiBwcmV2ICVkIGFuZCBuZXh0ICVkLCBsaW5lICVkCgBpbiByb3V0ZXNwbGluZXMsIGVkZ2UgaXMgYSBsb29wIGF0ICVzCgBpbiByb3V0ZXNwbGluZXMsIFBzaG9ydGVzdHBhdGggZmFpbGVkCgBpbiByb3V0ZXNwbGluZXMsIFByb3V0ZXNwbGluZSBmYWlsZWQKAFVuYWJsZSB0byByZWNsYWltIGJveCBzcGFjZSBpbiBzcGxpbmUgcm91dGluZyBmb3IgZWRnZSAiJXMiIC0+ICIlcyIuIFNvbWV0aGluZyBpcyBwcm9iYWJseSBzZXJpb3VzbHkgd3JvbmcuCgBpbiBjaGVja3BhdGgsIGJveCAwIGhhcyBMTCBjb29yZCA+IFVSIGNvb3JkCgBpbiBjaGVja3BhdGgsIGJveCAlZCBoYXMgTEwgY29vcmQgPiBVUiBjb29yZAoAaW4gY2hlY2twYXRoLCBib3hlcyAlZCBhbmQgJWQgZG9uJ3QgdG91Y2gKAGluIGNoZWNrcGF0aCwgc3RhcnQgcG9ydCBub3QgaW4gZmlyc3QgYm94CgBpbiBjaGVja3BhdGgsIGVuZCBwb3J0IG5vdCBpbiBsYXN0IGJveAoAJWQgYm94ZXM6CgAlZCAoJS41ZywgJS41ZyksICglLjVnLCAlLjVnKQoAY29uc3RyYWluZWQAbm90IGNvbnN0cmFpbmVkAHN0YXJ0IHBvcnQ6ICglLjVnLCAlLjVnKSwgdGFuZ2VudCBhbmdsZTogJS41ZywgJXMKAGVuZCBwb3J0OiAoJS41ZywgJS41ZyksIHRhbmdlbnQgYW5nbGU6ICUuNWcsICVzCgBzaWRlcyA9PSA0AHNoYXBlcy5jAHJvdW5kX2Nvcm5lcnMAYmFkIGxhYmVsIGZvcm1hdCAlcwoAXE4AbWFyZ2luACVsZiwlbGYAcmVndWxhcgBjdXN0b20Ac2hhcGVmaWxlADxuaWw+AE5vIG9yIGltcHJvcGVyIHNoYXBlZmlsZT0iJXMiIGZvciBub2RlICIlcyIKAE5vIG9yIGltcHJvcGVyIGltYWdlPSIlcyIgZm9yIG5vZGUgIiVzIgoAbGFiZWxsb2MAc2hhcGUAbm9kZSAnJXMnLCBncmFwaCAnJXMnIHNpemUgdG9vIHNtYWxsIGZvciBsYWJlbAoAZXBzZgB1c2luZyAlcyBmb3IgdW5rbm93biBzaGFwZSAlcwoAYm94AHBvbHlnb24Ab3ZhbABjaXJjbGUAcG9pbnQAZWdnAHRyaWFuZ2xlAHBsYWludGV4dABwbGFpbgBkaWFtb25kAHRyYXBleml1bQBwYXJhbGxlbG9ncmFtAGhvdXNlAHBlbnRhZ29uAGhleGFnb24Ac2VwdGFnb24Ab2N0YWdvbgBub3RlAHRhYgBmb2xkZXIAYm94M2QAY29tcG9uZW50AGN5bGluZGVyAHJlY3QAcmVjdGFuZ2xlAHNxdWFyZQBkb3VibGVjaXJjbGUAZG91Ymxlb2N0YWdvbgB0cmlwbGVvY3RhZ29uAGludnRyaWFuZ2xlAGludnRyYXBleml1bQBpbnZob3VzZQB1bmRlcmxpbmUATWRpYW1vbmQATXNxdWFyZQBNY2lyY2xlAHByb21vdGVyAGNkcwB0ZXJtaW5hdG9yAHV0cgBpbnN1bGF0b3IAcmlib3NpdGUAcm5hc3RhYgBwcm90ZWFzZXNpdGUAcHJvdGVpbnN0YWIAcHJpbWVyc2l0ZQByZXN0cmljdGlvbnNpdGUAZml2ZXBvdmVyaGFuZwB0aHJlZXBvdmVyaGFuZwBub3ZlcmhhbmcAYXNzZW1ibHkAc2lnbmF0dXJlAHJwcm9tb3RlcgBsYXJyb3cAcmFycm93AGxwcm9tb3RlcgByZWNvcmQATXJlY29yZABzdGFyACM4MDgwODAAI2ZjZmNmYwAjMzAzMDMwACNlOGU4ZTgAI2UwZTBlMAAjZjBmMGYwACMxMDEwMTAAI2Y4ZjhmOABpbiBub2RlICVzCgByb3VuZGVkAGRpYWdvbmFscwByYWRpYWwAc3RyaXBlZAB3ZWRnZWQAXwBub2RlICVzLCBwb3J0ICVzLCB1bnJlY29nbml6ZWQgY29tcGFzcyBwb2ludCAnJXMnIC0gaWdub3JlZAoAbm9kZSAlcywgcG9ydCAlcyB1bnJlY29nbml6ZWQKACUuNWcgJS41ZyB0cmFuc2xhdGUgbmV3cGF0aCB1c2VyX3NoYXBlXyVkCgBpbnZpcwAAZmlsbGVkAABzAGUAdwBzcGxpbmVzLmMAYmVnaW5wYXRoAFAtPmVuZC50aGV0YSA8IDIgKiBNX1BJAGVuZHBhdGgAbWFrZVNlbGZFZGdlAGdldHNwbGluZXBvaW50czogbm8gc3BsaW5lIHBvaW50cyBhdmFpbGFibGUgZm9yIGVkZ2UgKCVzLCVzKQoAcG9seWxpbmVNaWRwb2ludABzcGFuLT5mb250AHRleHRzcGFuLmMAdGV4dHNwYW5fc2l6ZQBmb250LT5uYW1lAGZvbnRuYW1lOiAiJXMiIHJlc29sdmVkIHRvOiAlcwoAZm9udG5hbWU6IHVuYWJsZSB0byByZXNvbHZlICIlcyIKAGNvdXIAYXJpYWwAaGVsdmV0aWNhAFtpbnRlcm5hbCB0aW1lc10AW2ludGVybmFsIGNvdXJpZXJdAFtpbnRlcm5hbCBhcmlhbF0AQXZhbnRHYXJkZS1Cb29rAFVSVyBHb3RoaWMgTABib29rAHNhbnMtU2VyaWYAQXZhbnRHYXJkZS1Cb29rT2JsaXF1ZQBvYmxpcXVlAGl0YWxpYwBBdmFudEdhcmRlLURlbWkAZGVtaQBBdmFudEdhcmRlLURlbWlPYmxpcXVlAEJvb2ttYW4tRGVtaQBVUlcgQm9va21hbiBMAHNlcmlmAEJvb2ttYW4tRGVtaUl0YWxpYwBCb29rbWFuLUxpZ2h0AGxpZ2h0AEJvb2ttYW4tTGlnaHRJdGFsaWMAQ291cmllcgBtb25vc3BhY2UAQ291cmllci1Cb2xkAENvdXJpZXItQm9sZE9ibGlxdWUAQ291cmllci1PYmxpcXVlAEhlbHZldGljYQBIZWx2ZXRpY2EtQm9sZABIZWx2ZXRpY2EtQm9sZE9ibGlxdWUASGVsdmV0aWNhLU5hcnJvdwBjb25kZW5zZWQASGVsdmV0aWNhLU5hcnJvdy1Cb2xkAEhlbHZldGljYS1OYXJyb3ctQm9sZE9ibGlxdWUASGVsdmV0aWNhLU5hcnJvdy1PYmxpcXVlAEhlbHZldGljYS1PYmxpcXVlAE5ld0NlbnR1cnlTY2hsYmstQm9sZABDZW50dXJ5IFNjaG9vbGJvb2sgTABOZXdDZW50dXJ5U2NobGJrLUJvbGRJdGFsaWMATmV3Q2VudHVyeVNjaGxiay1JdGFsaWMATmV3Q2VudHVyeVNjaGxiay1Sb21hbgByb21hbgBQYWxhdGluby1Cb2xkAFBhbGF0aW5vIExpbm90eXBlAFBhbGF0aW5vLUJvbGRJdGFsaWMAUGFsYXRpbm8tSXRhbGljAFBhbGF0aW5vLVJvbWFuAFN5bWJvbABmYW50YXN5AFRpbWVzLUJvbGQAVGltZXMAVGltZXMtQm9sZEl0YWxpYwBUaW1lcy1JdGFsaWMAWmFwZkNoYW5jZXJ5LU1lZGl1bUl0YWxpYwBVUlcgQ2hhbmNlcnkgTABtZWRpdW0AWmFwZkRpbmdiYXRzAERpbmdiYXRzAG5vAHRydWUAeWVzAHV0aWxzLmMAdSA9PSBVRl9maW5kKHUpAFVGX3NldG5hbWUAAWZpbGUgbG9hZGluZyBpcyBkaXNhYmxlZCBiZWNhdXNlIHRoZSBlbnZpcm9ubWVudCBjb250YWlucyBTRVJWRVJfTkFNRT0iJXMiCmFuZCB0aGUgR1ZfRklMRV9QQVRIIHZhcmlhYmxlIGlzIHVuc2V0IG9yIGVtcHR5LgoAUGF0aCBwcm92aWRlZCB0byBmaWxlOiAiJXMiIGhhcyBiZWVuIGlnbm9yZWQgYmVjYXVzZSBmaWxlcyBhcmUgb25seSBwZXJtaXR0ZWQgdG8gYmUgbG9hZGVkIGZyb20gdGhlIGRpcmVjdG9yaWVzIGluICIlcyIgd2hlbiBydW5uaW5nIGluIGFuIGh0dHAgc2VydmVyLgoAJXMlcyVzAC8AOgBlbGxpcHNlAFRpbWVzLVJvbWFuAGNsdXN0ZXIAX19jbHVzdGVybm9kZXMAVHdvIGNsdXN0ZXJzIG5hbWVkICVzIC0gdGhlIHNlY29uZCB3aWxsIGJlIGlnbm9yZWQKAG1hcE4AQUVsaWcAQWFjdXRlAEFjaXJjAEFncmF2ZQBBbHBoYQBBcmluZwBBdGlsZGUAQXVtbABCZXRhAENjZWRpbABDaGkARGFnZ2VyAERlbHRhAEVUSABFYWN1dGUARWNpcmMARWdyYXZlAEVwc2lsb24ARXRhAEV1bWwAR2FtbWEASWFjdXRlAEljaXJjAElncmF2ZQBJb3RhAEl1bWwAS2FwcGEATGFtYmRhAE11AE50aWxkZQBOdQBPRWxpZwBPYWN1dGUAT2NpcmMAT2dyYXZlAE9tZWdhAE9taWNyb24AT3NsYXNoAE90aWxkZQBPdW1sAFBoaQBQaQBQcmltZQBQc2kAUmhvAFNjYXJvbgBTaWdtYQBUSE9STgBUYXUAVGhldGEAVWFjdXRlAFVjaXJjAFVncmF2ZQBVcHNpbG9uAFV1bWwAWGkAWWFjdXRlAFl1bWwAWmV0YQBhYWN1dGUAYWNpcmMAYWN1dGUAYWVsaWcAYWdyYXZlAGFsZWZzeW0AYWxwaGEAYW1wAGFuZABhbmcAYXJpbmcAYXN5bXAAYXRpbGRlAGF1bWwAYmRxdW8AYmV0YQBicnZiYXIAYnVsbABjYXAAY2NlZGlsAGNlZGlsAGNlbnQAY2hpAGNpcmMAY2x1YnMAY29uZwBjb3B5AGNyYXJyAGN1cABjdXJyZW4AZEFycgBkYWdnZXIAZGFycgBkZWcAZGVsdGEAZGlhbXMAZGl2aWRlAGVhY3V0ZQBlY2lyYwBlZ3JhdmUAZW1wdHkAZW1zcABlbnNwAGVwc2lsb24AZXF1aXYAZXRhAGV0aABldW1sAGV1cm8AZXhpc3QAZm5vZgBmb3JhbGwAZnJhYzEyAGZyYWMxNABmcmFjMzQAZnJhc2wAZ2FtbWEAZ2UAZ3QAaEFycgBoYXJyAGhlYXJ0cwBoZWxsaXAAaWFjdXRlAGljaXJjAGlleGNsAGlncmF2ZQBpbWFnZQBpbmZpbgBpbnQAaW90YQBpcXVlc3QAaXNpbgBpdW1sAGthcHBhAGxBcnIAbGFtYmRhAGxhbmcAbGFxdW8AbGFycgBsY2VpbABsZHF1bwBsZQBsZmxvb3IAbG93YXN0AGxvegBscm0AbHNhcXVvAGxzcXVvAGx0AG1hY3IAbWRhc2gAbWljcm8AbWlkZG90AG11AG5hYmxhAG5ic3AAbmRhc2gAbmUAbmkAbm90AG5vdGluAG5zdWIAbnRpbGRlAG51AG9hY3V0ZQBvY2lyYwBvZWxpZwBvZ3JhdmUAb2xpbmUAb21lZ2EAb21pY3JvbgBvcGx1cwBvcgBvcmRmAG9yZG0Ab3NsYXNoAG90aWxkZQBvdGltZXMAb3VtbABwYXJhAHBhcnQAcGVybWlsAHBlcnAAcGhpAHBpAHBpdgBwbHVzbW4AcG91bmQAcHJpbWUAcHJvZABwcm9wAHBzaQBxdW90AHJBcnIAcmFkaWMAcmFuZwByYXF1bwByYXJyAHJjZWlsAHJkcXVvAHJlYWwAcmVnAHJmbG9vcgByaG8AcmxtAHJzYXF1bwByc3F1bwBzYnF1bwBzY2Fyb24Ac2RvdABzZWN0AHNoeQBzaWdtYQBzaWdtYWYAc2ltAHNwYWRlcwBzdWIAc3ViZQBzdW0Ac3VwAHN1cDEAc3VwMgBzdXAzAHN1cGUAc3psaWcAdGF1AHRoZXJlNAB0aGV0YQB0aGV0YXN5bQB0aGluc3AAdGhvcm4AdGlsZGUAdGltZXMAdHJhZGUAdUFycgB1YWN1dGUAdWFycgB1Y2lyYwB1Z3JhdmUAdW1sAHVwc2loAHVwc2lsb24AdXVtbAB3ZWllcnAAeGkAeWFjdXRlAHllbgB5dW1sAHpldGEAendqAHp3bmoAVVRGOCBjb2RlcyA+IDQgYnl0ZXMgYXJlIG5vdCBjdXJyZW50bHkgc3VwcG9ydGVkIChncmFwaCAlcykgLSB0cmVhdGVkIGFzIExhdGluLTEuIFBlcmhhcHMgIi1HY2hhcnNldD1sYXRpbjEiIGlzIG5lZWRlZD8KAEludmFsaWQgJWQtYnl0ZSBVVEY4IGZvdW5kIGluIGlucHV0IG9mIGdyYXBoICVzIC0gdHJlYXRlZCBhcyBMYXRpbi0xLiBQZXJoYXBzICItR2NoYXJzZXQ9bGF0aW4xIiBpcyBuZWVkZWQ/CgBiei5zaXplAG92ZXJsYXBfYmV6aWVyAHVydmVkAG9tcG91bmQAYWxzZQBpbmUAb25lAG8AcnRobwBvbHlsaW5lAHBsaW5lAHJ1ZQBlcwBVbmtub3duICJzcGxpbmVzIiB2YWx1ZTogIiVzIiAtIGlnbm9yZWQKAHNwbGluZXMAb2RiAE9ydGhvZ29uYWwgZWRnZXMgZG8gbm90IGN1cnJlbnRseSBoYW5kbGUgZWRnZSBsYWJlbHMuIFRyeSB1c2luZyB4bGFiZWxzLgoAb3J0aG8gJXMgJXMKAGNoYW5pAG9ydGhvLmMAY2hhblNlYXJjaABjcAAlJSFQUy1BZG9iZS0yLjAKJSUlJUJvdW5kaW5nQm94OiAoYXRlbmQpCi9wb2ludCB7CiAgL1kgZXhjaCBkZWYKICAvWCBleGNoIGRlZgogIG5ld3BhdGgKICBYIFkgMyAwIDM2MCBhcmMgZmlsbAp9IGRlZgovY2VsbCB7CiAgL1kgZXhjaCBkZWYKICAvWCBleGNoIGRlZgogIC95IGV4Y2ggZGVmCiAgL3ggZXhjaCBkZWYKICBuZXdwYXRoCiAgeCB5IG1vdmV0bwogIHggWSBsaW5ldG8KICBYIFkgbGluZXRvCiAgWCB5IGxpbmV0bwogIGNsb3NlcGF0aCBzdHJva2UKfSBkZWYKL25vZGUgewogL3UgZXhjaCBkZWYKIC9yIGV4Y2ggZGVmCiAvZCBleGNoIGRlZgogL2wgZXhjaCBkZWYKIG5ld3BhdGggbCBkIG1vdmV0bwogciBkIGxpbmV0byByIHUgbGluZXRvIGwgdSBsaW5ldG8KIGNsb3NlcGF0aCBmaWxsCn0gZGVmCgoAJWQgJWQgdHJhbnNsYXRlCgAwLjggMC44IDAuOCBzZXRyZ2Jjb2xvcgoAc2hvd3BhZ2UKJSUlJVRyYWlsZXIKJSUlJUJvdW5kaW5nQm94OiAlZCAlZCAlZCAlZAoAbmV3cGF0aCAlZCAlZCBtb3ZldG8KACVkICVkIGxpbmV0bwoAJWQgJWQgbGluZXRvIHN0cm9rZQoAY2hhbm5lbCAlZCAoJWYsJWYpCgAgLT4KACAgICAgACgoJWYsJWYpLCglZiwlZikpICVzICVzAEJfUklHSFQAQl9ET1dOAEJfTEVGVABCX1VQAEJfTk9ERQBzZWcAbmV4dF9zZWcAZGVjaWRlX3BvaW50AGluY29tcGFyYWJsZSBzZWdtZW50cyAhISAtLSBBYm9ydGluZwoAczEtPmNvbW1fY29vcmQ9PXMyLT5jb21tX2Nvb3JkAGlzX3BhcmFsbGVsAGdyYXBoIEcgewoAIG5vZGVbc2hhcGU9cG9pbnRdCgAgICVkIFtwb3M9IiVkLCVkIl0KACAgJWQgLS0gJWRbbGVuPSIlZiJdCgB9CgBjb2xvciAlcwAlcyBpcyBub3QgYSBrbm93biBjb2xvci4KAGVycm9yIGluIGNvbHhsYXRlKCkKAHNvbGlkAGludmlzaWJsZQBib2xkAHNldGxpbmV3aWR0aABmaWxsZWQAdW5maWxsZWQAdGFwZXJlZABndnJlbmRlcl9zZXRfc3R5bGU6IHVuc3VwcG9ydGVkIHN0eWxlICVzIC0gaWdub3JpbmcKAGd2cmVuZGVyLmMAZ3ZyZW5kZXJfdXNlcnNoYXBlAG5hbWUAbmFtZVswXQB3aWR0aABoZWlnaHQAYm90aABqb2IAZ3Zsb2FkaW1hZ2UuYwBndmxvYWRpbWFnZQB1cwB1cy0+bmFtZQB1cy0+bmFtZVswXQBObyBsb2FkaW1hZ2UgcGx1Z2luIGZvciAiJXMiCgBRAExlZnQAS1BfTGVmdABSaWdodABLUF9SaWdodABVcABLUF9VcABEb3duAEtQX0Rvd24AcGx1cwBLUF9BZGQAbWludXMAS1BfU3VidHJhY3QARgB0b29sdGlwAGVkZ2UAdGFpbHBvcnQAaGVhZHBvcnQAa2V5AGhyZWYAVVJMAG5vZGUAZGlncmFwaABncmFwaABzdWJncmFwaABfTFRYX2xpYnJhcnkAdGV4dGxheW91dABvYmpwLT5sYmwAeGxhYmVscy5jAHhsYWRqdXN0AHhsaW50ZXJzZWN0aW9ucwBscCAhPSBjbHAAZ2V0aW50cnN4aQBvYmpwMS0+c3oueCA9PSAwICYmIG9ianAxLT5zei55ID09IDAAbGJsZW5jbG9zaW5nAHZwAHhsaGR4dW5sb2FkAHNpemU9PWZyZWVkAHJlY3QuYm91bmRhcnlbMl0gPCBJTlRfTUFYAG9ianBscG1rcwByZWN0LmJvdW5kYXJ5WzNdIDwgSU5UX01BWABvdXQgb2YgbWVtb3J5CgAjJTJ4JTJ4JTJ4JTJ4ACVsZiVsZiVsZgAvYWNjZW50My8xAC9hY2NlbnQzLzIAL2FjY2VudDMvMwAvYWNjZW50NC8xAC9hY2NlbnQ0LzIAL2FjY2VudDQvMwAvYWNjZW50NC80AC9hY2NlbnQ1LzEAL2FjY2VudDUvMgAvYWNjZW50NS8zAC9hY2NlbnQ1LzQAL2FjY2VudDUvNQAvYWNjZW50Ni8xAC9hY2NlbnQ2LzIAL2FjY2VudDYvMwAvYWNjZW50Ni80AC9hY2NlbnQ2LzUAL2FjY2VudDYvNgAvYWNjZW50Ny8xAC9hY2NlbnQ3LzIAL2FjY2VudDcvMwAvYWNjZW50Ny80AC9hY2NlbnQ3LzUAL2FjY2VudDcvNgAvYWNjZW50Ny83AC9hY2NlbnQ4LzEAL2FjY2VudDgvMgAvYWNjZW50OC8zAC9hY2NlbnQ4LzQAL2FjY2VudDgvNQAvYWNjZW50OC82AC9hY2NlbnQ4LzcAL2FjY2VudDgvOAAvYmx1ZXMzLzEAL2JsdWVzMy8yAC9ibHVlczMvMwAvYmx1ZXM0LzEAL2JsdWVzNC8yAC9ibHVlczQvMwAvYmx1ZXM0LzQAL2JsdWVzNS8xAC9ibHVlczUvMgAvYmx1ZXM1LzMAL2JsdWVzNS80AC9ibHVlczUvNQAvYmx1ZXM2LzEAL2JsdWVzNi8yAC9ibHVlczYvMwAvYmx1ZXM2LzQAL2JsdWVzNi81AC9ibHVlczYvNgAvYmx1ZXM3LzEAL2JsdWVzNy8yAC9ibHVlczcvMwAvYmx1ZXM3LzQAL2JsdWVzNy81AC9ibHVlczcvNgAvYmx1ZXM3LzcAL2JsdWVzOC8xAC9ibHVlczgvMgAvYmx1ZXM4LzMAL2JsdWVzOC80AC9ibHVlczgvNQAvYmx1ZXM4LzYAL2JsdWVzOC83AC9ibHVlczgvOAAvYmx1ZXM5LzEAL2JsdWVzOS8yAC9ibHVlczkvMwAvYmx1ZXM5LzQAL2JsdWVzOS81AC9ibHVlczkvNgAvYmx1ZXM5LzcAL2JsdWVzOS84AC9ibHVlczkvOQAvYnJiZzEwLzEAL2JyYmcxMC8xMAAvYnJiZzEwLzIAL2JyYmcxMC8zAC9icmJnMTAvNAAvYnJiZzEwLzUAL2JyYmcxMC82AC9icmJnMTAvNwAvYnJiZzEwLzgAL2JyYmcxMC85AC9icmJnMTEvMQAvYnJiZzExLzEwAC9icmJnMTEvMTEAL2JyYmcxMS8yAC9icmJnMTEvMwAvYnJiZzExLzQAL2JyYmcxMS81AC9icmJnMTEvNgAvYnJiZzExLzcAL2JyYmcxMS84AC9icmJnMTEvOQAvYnJiZzMvMQAvYnJiZzMvMgAvYnJiZzMvMwAvYnJiZzQvMQAvYnJiZzQvMgAvYnJiZzQvMwAvYnJiZzQvNAAvYnJiZzUvMQAvYnJiZzUvMgAvYnJiZzUvMwAvYnJiZzUvNAAvYnJiZzUvNQAvYnJiZzYvMQAvYnJiZzYvMgAvYnJiZzYvMwAvYnJiZzYvNAAvYnJiZzYvNQAvYnJiZzYvNgAvYnJiZzcvMQAvYnJiZzcvMgAvYnJiZzcvMwAvYnJiZzcvNAAvYnJiZzcvNQAvYnJiZzcvNgAvYnJiZzcvNwAvYnJiZzgvMQAvYnJiZzgvMgAvYnJiZzgvMwAvYnJiZzgvNAAvYnJiZzgvNQAvYnJiZzgvNgAvYnJiZzgvNwAvYnJiZzgvOAAvYnJiZzkvMQAvYnJiZzkvMgAvYnJiZzkvMwAvYnJiZzkvNAAvYnJiZzkvNQAvYnJiZzkvNgAvYnJiZzkvNwAvYnJiZzkvOAAvYnJiZzkvOQAvYnVnbjMvMQAvYnVnbjMvMgAvYnVnbjMvMwAvYnVnbjQvMQAvYnVnbjQvMgAvYnVnbjQvMwAvYnVnbjQvNAAvYnVnbjUvMQAvYnVnbjUvMgAvYnVnbjUvMwAvYnVnbjUvNAAvYnVnbjUvNQAvYnVnbjYvMQAvYnVnbjYvMgAvYnVnbjYvMwAvYnVnbjYvNAAvYnVnbjYvNQAvYnVnbjYvNgAvYnVnbjcvMQAvYnVnbjcvMgAvYnVnbjcvMwAvYnVnbjcvNAAvYnVnbjcvNQAvYnVnbjcvNgAvYnVnbjcvNwAvYnVnbjgvMQAvYnVnbjgvMgAvYnVnbjgvMwAvYnVnbjgvNAAvYnVnbjgvNQAvYnVnbjgvNgAvYnVnbjgvNwAvYnVnbjgvOAAvYnVnbjkvMQAvYnVnbjkvMgAvYnVnbjkvMwAvYnVnbjkvNAAvYnVnbjkvNQAvYnVnbjkvNgAvYnVnbjkvNwAvYnVnbjkvOAAvYnVnbjkvOQAvYnVwdTMvMQAvYnVwdTMvMgAvYnVwdTMvMwAvYnVwdTQvMQAvYnVwdTQvMgAvYnVwdTQvMwAvYnVwdTQvNAAvYnVwdTUvMQAvYnVwdTUvMgAvYnVwdTUvMwAvYnVwdTUvNAAvYnVwdTUvNQAvYnVwdTYvMQAvYnVwdTYvMgAvYnVwdTYvMwAvYnVwdTYvNAAvYnVwdTYvNQAvYnVwdTYvNgAvYnVwdTcvMQAvYnVwdTcvMgAvYnVwdTcvMwAvYnVwdTcvNAAvYnVwdTcvNQAvYnVwdTcvNgAvYnVwdTcvNwAvYnVwdTgvMQAvYnVwdTgvMgAvYnVwdTgvMwAvYnVwdTgvNAAvYnVwdTgvNQAvYnVwdTgvNgAvYnVwdTgvNwAvYnVwdTgvOAAvYnVwdTkvMQAvYnVwdTkvMgAvYnVwdTkvMwAvYnVwdTkvNAAvYnVwdTkvNQAvYnVwdTkvNgAvYnVwdTkvNwAvYnVwdTkvOAAvYnVwdTkvOQAvZGFyazIzLzEAL2RhcmsyMy8yAC9kYXJrMjMvMwAvZGFyazI0LzEAL2RhcmsyNC8yAC9kYXJrMjQvMwAvZGFyazI0LzQAL2RhcmsyNS8xAC9kYXJrMjUvMgAvZGFyazI1LzMAL2RhcmsyNS80AC9kYXJrMjUvNQAvZGFyazI2LzEAL2RhcmsyNi8yAC9kYXJrMjYvMwAvZGFyazI2LzQAL2RhcmsyNi81AC9kYXJrMjYvNgAvZGFyazI3LzEAL2RhcmsyNy8yAC9kYXJrMjcvMwAvZGFyazI3LzQAL2RhcmsyNy81AC9kYXJrMjcvNgAvZGFyazI3LzcAL2RhcmsyOC8xAC9kYXJrMjgvMgAvZGFyazI4LzMAL2RhcmsyOC80AC9kYXJrMjgvNQAvZGFyazI4LzYAL2RhcmsyOC83AC9kYXJrMjgvOAAvZ25idTMvMQAvZ25idTMvMgAvZ25idTMvMwAvZ25idTQvMQAvZ25idTQvMgAvZ25idTQvMwAvZ25idTQvNAAvZ25idTUvMQAvZ25idTUvMgAvZ25idTUvMwAvZ25idTUvNAAvZ25idTUvNQAvZ25idTYvMQAvZ25idTYvMgAvZ25idTYvMwAvZ25idTYvNAAvZ25idTYvNQAvZ25idTYvNgAvZ25idTcvMQAvZ25idTcvMgAvZ25idTcvMwAvZ25idTcvNAAvZ25idTcvNQAvZ25idTcvNgAvZ25idTcvNwAvZ25idTgvMQAvZ25idTgvMgAvZ25idTgvMwAvZ25idTgvNAAvZ25idTgvNQAvZ25idTgvNgAvZ25idTgvNwAvZ25idTgvOAAvZ25idTkvMQAvZ25idTkvMgAvZ25idTkvMwAvZ25idTkvNAAvZ25idTkvNQAvZ25idTkvNgAvZ25idTkvNwAvZ25idTkvOAAvZ25idTkvOQAvZ3JlZW5zMy8xAC9ncmVlbnMzLzIAL2dyZWVuczMvMwAvZ3JlZW5zNC8xAC9ncmVlbnM0LzIAL2dyZWVuczQvMwAvZ3JlZW5zNC80AC9ncmVlbnM1LzEAL2dyZWVuczUvMgAvZ3JlZW5zNS8zAC9ncmVlbnM1LzQAL2dyZWVuczUvNQAvZ3JlZW5zNi8xAC9ncmVlbnM2LzIAL2dyZWVuczYvMwAvZ3JlZW5zNi80AC9ncmVlbnM2LzUAL2dyZWVuczYvNgAvZ3JlZW5zNy8xAC9ncmVlbnM3LzIAL2dyZWVuczcvMwAvZ3JlZW5zNy80AC9ncmVlbnM3LzUAL2dyZWVuczcvNgAvZ3JlZW5zNy83AC9ncmVlbnM4LzEAL2dyZWVuczgvMgAvZ3JlZW5zOC8zAC9ncmVlbnM4LzQAL2dyZWVuczgvNQAvZ3JlZW5zOC82AC9ncmVlbnM4LzcAL2dyZWVuczgvOAAvZ3JlZW5zOS8xAC9ncmVlbnM5LzIAL2dyZWVuczkvMwAvZ3JlZW5zOS80AC9ncmVlbnM5LzUAL2dyZWVuczkvNgAvZ3JlZW5zOS83AC9ncmVlbnM5LzgAL2dyZWVuczkvOQAvZ3JleXMzLzEAL2dyZXlzMy8yAC9ncmV5czMvMwAvZ3JleXM0LzEAL2dyZXlzNC8yAC9ncmV5czQvMwAvZ3JleXM0LzQAL2dyZXlzNS8xAC9ncmV5czUvMgAvZ3JleXM1LzMAL2dyZXlzNS80AC9ncmV5czUvNQAvZ3JleXM2LzEAL2dyZXlzNi8yAC9ncmV5czYvMwAvZ3JleXM2LzQAL2dyZXlzNi81AC9ncmV5czYvNgAvZ3JleXM3LzEAL2dyZXlzNy8yAC9ncmV5czcvMwAvZ3JleXM3LzQAL2dyZXlzNy81AC9ncmV5czcvNgAvZ3JleXM3LzcAL2dyZXlzOC8xAC9ncmV5czgvMgAvZ3JleXM4LzMAL2dyZXlzOC80AC9ncmV5czgvNQAvZ3JleXM4LzYAL2dyZXlzOC83AC9ncmV5czgvOAAvZ3JleXM5LzEAL2dyZXlzOS8yAC9ncmV5czkvMwAvZ3JleXM5LzQAL2dyZXlzOS81AC9ncmV5czkvNgAvZ3JleXM5LzcAL2dyZXlzOS84AC9ncmV5czkvOQAvb3JhbmdlczMvMQAvb3JhbmdlczMvMgAvb3JhbmdlczMvMwAvb3JhbmdlczQvMQAvb3JhbmdlczQvMgAvb3JhbmdlczQvMwAvb3JhbmdlczQvNAAvb3JhbmdlczUvMQAvb3JhbmdlczUvMgAvb3JhbmdlczUvMwAvb3JhbmdlczUvNAAvb3JhbmdlczUvNQAvb3JhbmdlczYvMQAvb3JhbmdlczYvMgAvb3JhbmdlczYvMwAvb3JhbmdlczYvNAAvb3JhbmdlczYvNQAvb3JhbmdlczYvNgAvb3JhbmdlczcvMQAvb3JhbmdlczcvMgAvb3JhbmdlczcvMwAvb3JhbmdlczcvNAAvb3JhbmdlczcvNQAvb3JhbmdlczcvNgAvb3JhbmdlczcvNwAvb3JhbmdlczgvMQAvb3JhbmdlczgvMgAvb3JhbmdlczgvMwAvb3JhbmdlczgvNAAvb3JhbmdlczgvNQAvb3JhbmdlczgvNgAvb3JhbmdlczgvNwAvb3JhbmdlczgvOAAvb3JhbmdlczkvMQAvb3JhbmdlczkvMgAvb3JhbmdlczkvMwAvb3JhbmdlczkvNAAvb3JhbmdlczkvNQAvb3JhbmdlczkvNgAvb3JhbmdlczkvNwAvb3JhbmdlczkvOAAvb3JhbmdlczkvOQAvb3JyZDMvMQAvb3JyZDMvMgAvb3JyZDMvMwAvb3JyZDQvMQAvb3JyZDQvMgAvb3JyZDQvMwAvb3JyZDQvNAAvb3JyZDUvMQAvb3JyZDUvMgAvb3JyZDUvMwAvb3JyZDUvNAAvb3JyZDUvNQAvb3JyZDYvMQAvb3JyZDYvMgAvb3JyZDYvMwAvb3JyZDYvNAAvb3JyZDYvNQAvb3JyZDYvNgAvb3JyZDcvMQAvb3JyZDcvMgAvb3JyZDcvMwAvb3JyZDcvNAAvb3JyZDcvNQAvb3JyZDcvNgAvb3JyZDcvNwAvb3JyZDgvMQAvb3JyZDgvMgAvb3JyZDgvMwAvb3JyZDgvNAAvb3JyZDgvNQAvb3JyZDgvNgAvb3JyZDgvNwAvb3JyZDgvOAAvb3JyZDkvMQAvb3JyZDkvMgAvb3JyZDkvMwAvb3JyZDkvNAAvb3JyZDkvNQAvb3JyZDkvNgAvb3JyZDkvNwAvb3JyZDkvOAAvb3JyZDkvOQAvcGFpcmVkMTAvMQAvcGFpcmVkMTAvMTAAL3BhaXJlZDEwLzIAL3BhaXJlZDEwLzMAL3BhaXJlZDEwLzQAL3BhaXJlZDEwLzUAL3BhaXJlZDEwLzYAL3BhaXJlZDEwLzcAL3BhaXJlZDEwLzgAL3BhaXJlZDEwLzkAL3BhaXJlZDExLzEAL3BhaXJlZDExLzEwAC9wYWlyZWQxMS8xMQAvcGFpcmVkMTEvMgAvcGFpcmVkMTEvMwAvcGFpcmVkMTEvNAAvcGFpcmVkMTEvNQAvcGFpcmVkMTEvNgAvcGFpcmVkMTEvNwAvcGFpcmVkMTEvOAAvcGFpcmVkMTEvOQAvcGFpcmVkMTIvMQAvcGFpcmVkMTIvMTAAL3BhaXJlZDEyLzExAC9wYWlyZWQxMi8xMgAvcGFpcmVkMTIvMgAvcGFpcmVkMTIvMwAvcGFpcmVkMTIvNAAvcGFpcmVkMTIvNQAvcGFpcmVkMTIvNgAvcGFpcmVkMTIvNwAvcGFpcmVkMTIvOAAvcGFpcmVkMTIvOQAvcGFpcmVkMy8xAC9wYWlyZWQzLzIAL3BhaXJlZDMvMwAvcGFpcmVkNC8xAC9wYWlyZWQ0LzIAL3BhaXJlZDQvMwAvcGFpcmVkNC80AC9wYWlyZWQ1LzEAL3BhaXJlZDUvMgAvcGFpcmVkNS8zAC9wYWlyZWQ1LzQAL3BhaXJlZDUvNQAvcGFpcmVkNi8xAC9wYWlyZWQ2LzIAL3BhaXJlZDYvMwAvcGFpcmVkNi80AC9wYWlyZWQ2LzUAL3BhaXJlZDYvNgAvcGFpcmVkNy8xAC9wYWlyZWQ3LzIAL3BhaXJlZDcvMwAvcGFpcmVkNy80AC9wYWlyZWQ3LzUAL3BhaXJlZDcvNgAvcGFpcmVkNy83AC9wYWlyZWQ4LzEAL3BhaXJlZDgvMgAvcGFpcmVkOC8zAC9wYWlyZWQ4LzQAL3BhaXJlZDgvNQAvcGFpcmVkOC82AC9wYWlyZWQ4LzcAL3BhaXJlZDgvOAAvcGFpcmVkOS8xAC9wYWlyZWQ5LzIAL3BhaXJlZDkvMwAvcGFpcmVkOS80AC9wYWlyZWQ5LzUAL3BhaXJlZDkvNgAvcGFpcmVkOS83AC9wYWlyZWQ5LzgAL3BhaXJlZDkvOQAvcGFzdGVsMTMvMQAvcGFzdGVsMTMvMgAvcGFzdGVsMTMvMwAvcGFzdGVsMTQvMQAvcGFzdGVsMTQvMgAvcGFzdGVsMTQvMwAvcGFzdGVsMTQvNAAvcGFzdGVsMTUvMQAvcGFzdGVsMTUvMgAvcGFzdGVsMTUvMwAvcGFzdGVsMTUvNAAvcGFzdGVsMTUvNQAvcGFzdGVsMTYvMQAvcGFzdGVsMTYvMgAvcGFzdGVsMTYvMwAvcGFzdGVsMTYvNAAvcGFzdGVsMTYvNQAvcGFzdGVsMTYvNgAvcGFzdGVsMTcvMQAvcGFzdGVsMTcvMgAvcGFzdGVsMTcvMwAvcGFzdGVsMTcvNAAvcGFzdGVsMTcvNQAvcGFzdGVsMTcvNgAvcGFzdGVsMTcvNwAvcGFzdGVsMTgvMQAvcGFzdGVsMTgvMgAvcGFzdGVsMTgvMwAvcGFzdGVsMTgvNAAvcGFzdGVsMTgvNQAvcGFzdGVsMTgvNgAvcGFzdGVsMTgvNwAvcGFzdGVsMTgvOAAvcGFzdGVsMTkvMQAvcGFzdGVsMTkvMgAvcGFzdGVsMTkvMwAvcGFzdGVsMTkvNAAvcGFzdGVsMTkvNQAvcGFzdGVsMTkvNgAvcGFzdGVsMTkvNwAvcGFzdGVsMTkvOAAvcGFzdGVsMTkvOQAvcGFzdGVsMjMvMQAvcGFzdGVsMjMvMgAvcGFzdGVsMjMvMwAvcGFzdGVsMjQvMQAvcGFzdGVsMjQvMgAvcGFzdGVsMjQvMwAvcGFzdGVsMjQvNAAvcGFzdGVsMjUvMQAvcGFzdGVsMjUvMgAvcGFzdGVsMjUvMwAvcGFzdGVsMjUvNAAvcGFzdGVsMjUvNQAvcGFzdGVsMjYvMQAvcGFzdGVsMjYvMgAvcGFzdGVsMjYvMwAvcGFzdGVsMjYvNAAvcGFzdGVsMjYvNQAvcGFzdGVsMjYvNgAvcGFzdGVsMjcvMQAvcGFzdGVsMjcvMgAvcGFzdGVsMjcvMwAvcGFzdGVsMjcvNAAvcGFzdGVsMjcvNQAvcGFzdGVsMjcvNgAvcGFzdGVsMjcvNwAvcGFzdGVsMjgvMQAvcGFzdGVsMjgvMgAvcGFzdGVsMjgvMwAvcGFzdGVsMjgvNAAvcGFzdGVsMjgvNQAvcGFzdGVsMjgvNgAvcGFzdGVsMjgvNwAvcGFzdGVsMjgvOAAvcGl5ZzEwLzEAL3BpeWcxMC8xMAAvcGl5ZzEwLzIAL3BpeWcxMC8zAC9waXlnMTAvNAAvcGl5ZzEwLzUAL3BpeWcxMC82AC9waXlnMTAvNwAvcGl5ZzEwLzgAL3BpeWcxMC85AC9waXlnMTEvMQAvcGl5ZzExLzEwAC9waXlnMTEvMTEAL3BpeWcxMS8yAC9waXlnMTEvMwAvcGl5ZzExLzQAL3BpeWcxMS81AC9waXlnMTEvNgAvcGl5ZzExLzcAL3BpeWcxMS84AC9waXlnMTEvOQAvcGl5ZzMvMQAvcGl5ZzMvMgAvcGl5ZzMvMwAvcGl5ZzQvMQAvcGl5ZzQvMgAvcGl5ZzQvMwAvcGl5ZzQvNAAvcGl5ZzUvMQAvcGl5ZzUvMgAvcGl5ZzUvMwAvcGl5ZzUvNAAvcGl5ZzUvNQAvcGl5ZzYvMQAvcGl5ZzYvMgAvcGl5ZzYvMwAvcGl5ZzYvNAAvcGl5ZzYvNQAvcGl5ZzYvNgAvcGl5ZzcvMQAvcGl5ZzcvMgAvcGl5ZzcvMwAvcGl5ZzcvNAAvcGl5ZzcvNQAvcGl5ZzcvNgAvcGl5ZzcvNwAvcGl5ZzgvMQAvcGl5ZzgvMgAvcGl5ZzgvMwAvcGl5ZzgvNAAvcGl5ZzgvNQAvcGl5ZzgvNgAvcGl5ZzgvNwAvcGl5ZzgvOAAvcGl5ZzkvMQAvcGl5ZzkvMgAvcGl5ZzkvMwAvcGl5ZzkvNAAvcGl5ZzkvNQAvcGl5ZzkvNgAvcGl5ZzkvNwAvcGl5ZzkvOAAvcGl5ZzkvOQAvcHJnbjEwLzEAL3ByZ24xMC8xMAAvcHJnbjEwLzIAL3ByZ24xMC8zAC9wcmduMTAvNAAvcHJnbjEwLzUAL3ByZ24xMC82AC9wcmduMTAvNwAvcHJnbjEwLzgAL3ByZ24xMC85AC9wcmduMTEvMQAvcHJnbjExLzEwAC9wcmduMTEvMTEAL3ByZ24xMS8yAC9wcmduMTEvMwAvcHJnbjExLzQAL3ByZ24xMS81AC9wcmduMTEvNgAvcHJnbjExLzcAL3ByZ24xMS84AC9wcmduMTEvOQAvcHJnbjMvMQAvcHJnbjMvMgAvcHJnbjMvMwAvcHJnbjQvMQAvcHJnbjQvMgAvcHJnbjQvMwAvcHJnbjQvNAAvcHJnbjUvMQAvcHJnbjUvMgAvcHJnbjUvMwAvcHJnbjUvNAAvcHJnbjUvNQAvcHJnbjYvMQAvcHJnbjYvMgAvcHJnbjYvMwAvcHJnbjYvNAAvcHJnbjYvNQAvcHJnbjYvNgAvcHJnbjcvMQAvcHJnbjcvMgAvcHJnbjcvMwAvcHJnbjcvNAAvcHJnbjcvNQAvcHJnbjcvNgAvcHJnbjcvNwAvcHJnbjgvMQAvcHJnbjgvMgAvcHJnbjgvMwAvcHJnbjgvNAAvcHJnbjgvNQAvcHJnbjgvNgAvcHJnbjgvNwAvcHJnbjgvOAAvcHJnbjkvMQAvcHJnbjkvMgAvcHJnbjkvMwAvcHJnbjkvNAAvcHJnbjkvNQAvcHJnbjkvNgAvcHJnbjkvNwAvcHJnbjkvOAAvcHJnbjkvOQAvcHVidTMvMQAvcHVidTMvMgAvcHVidTMvMwAvcHVidTQvMQAvcHVidTQvMgAvcHVidTQvMwAvcHVidTQvNAAvcHVidTUvMQAvcHVidTUvMgAvcHVidTUvMwAvcHVidTUvNAAvcHVidTUvNQAvcHVidTYvMQAvcHVidTYvMgAvcHVidTYvMwAvcHVidTYvNAAvcHVidTYvNQAvcHVidTYvNgAvcHVidTcvMQAvcHVidTcvMgAvcHVidTcvMwAvcHVidTcvNAAvcHVidTcvNQAvcHVidTcvNgAvcHVidTcvNwAvcHVidTgvMQAvcHVidTgvMgAvcHVidTgvMwAvcHVidTgvNAAvcHVidTgvNQAvcHVidTgvNgAvcHVidTgvNwAvcHVidTgvOAAvcHVidTkvMQAvcHVidTkvMgAvcHVidTkvMwAvcHVidTkvNAAvcHVidTkvNQAvcHVidTkvNgAvcHVidTkvNwAvcHVidTkvOAAvcHVidTkvOQAvcHVidWduMy8xAC9wdWJ1Z24zLzIAL3B1YnVnbjMvMwAvcHVidWduNC8xAC9wdWJ1Z240LzIAL3B1YnVnbjQvMwAvcHVidWduNC80AC9wdWJ1Z241LzEAL3B1YnVnbjUvMgAvcHVidWduNS8zAC9wdWJ1Z241LzQAL3B1YnVnbjUvNQAvcHVidWduNi8xAC9wdWJ1Z242LzIAL3B1YnVnbjYvMwAvcHVidWduNi80AC9wdWJ1Z242LzUAL3B1YnVnbjYvNgAvcHVidWduNy8xAC9wdWJ1Z243LzIAL3B1YnVnbjcvMwAvcHVidWduNy80AC9wdWJ1Z243LzUAL3B1YnVnbjcvNgAvcHVidWduNy83AC9wdWJ1Z244LzEAL3B1YnVnbjgvMgAvcHVidWduOC8zAC9wdWJ1Z244LzQAL3B1YnVnbjgvNQAvcHVidWduOC82AC9wdWJ1Z244LzcAL3B1YnVnbjgvOAAvcHVidWduOS8xAC9wdWJ1Z245LzIAL3B1YnVnbjkvMwAvcHVidWduOS80AC9wdWJ1Z245LzUAL3B1YnVnbjkvNgAvcHVidWduOS83AC9wdWJ1Z245LzgAL3B1YnVnbjkvOQAvcHVvcjEwLzEAL3B1b3IxMC8xMAAvcHVvcjEwLzIAL3B1b3IxMC8zAC9wdW9yMTAvNAAvcHVvcjEwLzUAL3B1b3IxMC82AC9wdW9yMTAvNwAvcHVvcjEwLzgAL3B1b3IxMC85AC9wdW9yMTEvMQAvcHVvcjExLzEwAC9wdW9yMTEvMTEAL3B1b3IxMS8yAC9wdW9yMTEvMwAvcHVvcjExLzQAL3B1b3IxMS81AC9wdW9yMTEvNgAvcHVvcjExLzcAL3B1b3IxMS84AC9wdW9yMTEvOQAvcHVvcjMvMQAvcHVvcjMvMgAvcHVvcjMvMwAvcHVvcjQvMQAvcHVvcjQvMgAvcHVvcjQvMwAvcHVvcjQvNAAvcHVvcjUvMQAvcHVvcjUvMgAvcHVvcjUvMwAvcHVvcjUvNAAvcHVvcjUvNQAvcHVvcjYvMQAvcHVvcjYvMgAvcHVvcjYvMwAvcHVvcjYvNAAvcHVvcjYvNQAvcHVvcjYvNgAvcHVvcjcvMQAvcHVvcjcvMgAvcHVvcjcvMwAvcHVvcjcvNAAvcHVvcjcvNQAvcHVvcjcvNgAvcHVvcjcvNwAvcHVvcjgvMQAvcHVvcjgvMgAvcHVvcjgvMwAvcHVvcjgvNAAvcHVvcjgvNQAvcHVvcjgvNgAvcHVvcjgvNwAvcHVvcjgvOAAvcHVvcjkvMQAvcHVvcjkvMgAvcHVvcjkvMwAvcHVvcjkvNAAvcHVvcjkvNQAvcHVvcjkvNgAvcHVvcjkvNwAvcHVvcjkvOAAvcHVvcjkvOQAvcHVyZDMvMQAvcHVyZDMvMgAvcHVyZDMvMwAvcHVyZDQvMQAvcHVyZDQvMgAvcHVyZDQvMwAvcHVyZDQvNAAvcHVyZDUvMQAvcHVyZDUvMgAvcHVyZDUvMwAvcHVyZDUvNAAvcHVyZDUvNQAvcHVyZDYvMQAvcHVyZDYvMgAvcHVyZDYvMwAvcHVyZDYvNAAvcHVyZDYvNQAvcHVyZDYvNgAvcHVyZDcvMQAvcHVyZDcvMgAvcHVyZDcvMwAvcHVyZDcvNAAvcHVyZDcvNQAvcHVyZDcvNgAvcHVyZDcvNwAvcHVyZDgvMQAvcHVyZDgvMgAvcHVyZDgvMwAvcHVyZDgvNAAvcHVyZDgvNQAvcHVyZDgvNgAvcHVyZDgvNwAvcHVyZDgvOAAvcHVyZDkvMQAvcHVyZDkvMgAvcHVyZDkvMwAvcHVyZDkvNAAvcHVyZDkvNQAvcHVyZDkvNgAvcHVyZDkvNwAvcHVyZDkvOAAvcHVyZDkvOQAvcHVycGxlczMvMQAvcHVycGxlczMvMgAvcHVycGxlczMvMwAvcHVycGxlczQvMQAvcHVycGxlczQvMgAvcHVycGxlczQvMwAvcHVycGxlczQvNAAvcHVycGxlczUvMQAvcHVycGxlczUvMgAvcHVycGxlczUvMwAvcHVycGxlczUvNAAvcHVycGxlczUvNQAvcHVycGxlczYvMQAvcHVycGxlczYvMgAvcHVycGxlczYvMwAvcHVycGxlczYvNAAvcHVycGxlczYvNQAvcHVycGxlczYvNgAvcHVycGxlczcvMQAvcHVycGxlczcvMgAvcHVycGxlczcvMwAvcHVycGxlczcvNAAvcHVycGxlczcvNQAvcHVycGxlczcvNgAvcHVycGxlczcvNwAvcHVycGxlczgvMQAvcHVycGxlczgvMgAvcHVycGxlczgvMwAvcHVycGxlczgvNAAvcHVycGxlczgvNQAvcHVycGxlczgvNgAvcHVycGxlczgvNwAvcHVycGxlczgvOAAvcHVycGxlczkvMQAvcHVycGxlczkvMgAvcHVycGxlczkvMwAvcHVycGxlczkvNAAvcHVycGxlczkvNQAvcHVycGxlczkvNgAvcHVycGxlczkvNwAvcHVycGxlczkvOAAvcHVycGxlczkvOQAvcmRidTEwLzEAL3JkYnUxMC8xMAAvcmRidTEwLzIAL3JkYnUxMC8zAC9yZGJ1MTAvNAAvcmRidTEwLzUAL3JkYnUxMC82AC9yZGJ1MTAvNwAvcmRidTEwLzgAL3JkYnUxMC85AC9yZGJ1MTEvMQAvcmRidTExLzEwAC9yZGJ1MTEvMTEAL3JkYnUxMS8yAC9yZGJ1MTEvMwAvcmRidTExLzQAL3JkYnUxMS81AC9yZGJ1MTEvNgAvcmRidTExLzcAL3JkYnUxMS84AC9yZGJ1MTEvOQAvcmRidTMvMQAvcmRidTMvMgAvcmRidTMvMwAvcmRidTQvMQAvcmRidTQvMgAvcmRidTQvMwAvcmRidTQvNAAvcmRidTUvMQAvcmRidTUvMgAvcmRidTUvMwAvcmRidTUvNAAvcmRidTUvNQAvcmRidTYvMQAvcmRidTYvMgAvcmRidTYvMwAvcmRidTYvNAAvcmRidTYvNQAvcmRidTYvNgAvcmRidTcvMQAvcmRidTcvMgAvcmRidTcvMwAvcmRidTcvNAAvcmRidTcvNQAvcmRidTcvNgAvcmRidTcvNwAvcmRidTgvMQAvcmRidTgvMgAvcmRidTgvMwAvcmRidTgvNAAvcmRidTgvNQAvcmRidTgvNgAvcmRidTgvNwAvcmRidTgvOAAvcmRidTkvMQAvcmRidTkvMgAvcmRidTkvMwAvcmRidTkvNAAvcmRidTkvNQAvcmRidTkvNgAvcmRidTkvNwAvcmRidTkvOAAvcmRidTkvOQAvcmRneTEwLzEAL3JkZ3kxMC8xMAAvcmRneTEwLzIAL3JkZ3kxMC8zAC9yZGd5MTAvNAAvcmRneTEwLzUAL3JkZ3kxMC82AC9yZGd5MTAvNwAvcmRneTEwLzgAL3JkZ3kxMC85AC9yZGd5MTEvMQAvcmRneTExLzEwAC9yZGd5MTEvMTEAL3JkZ3kxMS8yAC9yZGd5MTEvMwAvcmRneTExLzQAL3JkZ3kxMS81AC9yZGd5MTEvNgAvcmRneTExLzcAL3JkZ3kxMS84AC9yZGd5MTEvOQAvcmRneTMvMQAvcmRneTMvMgAvcmRneTMvMwAvcmRneTQvMQAvcmRneTQvMgAvcmRneTQvMwAvcmRneTQvNAAvcmRneTUvMQAvcmRneTUvMgAvcmRneTUvMwAvcmRneTUvNAAvcmRneTUvNQAvcmRneTYvMQAvcmRneTYvMgAvcmRneTYvMwAvcmRneTYvNAAvcmRneTYvNQAvcmRneTYvNgAvcmRneTcvMQAvcmRneTcvMgAvcmRneTcvMwAvcmRneTcvNAAvcmRneTcvNQAvcmRneTcvNgAvcmRneTcvNwAvcmRneTgvMQAvcmRneTgvMgAvcmRneTgvMwAvcmRneTgvNAAvcmRneTgvNQAvcmRneTgvNgAvcmRneTgvNwAvcmRneTgvOAAvcmRneTkvMQAvcmRneTkvMgAvcmRneTkvMwAvcmRneTkvNAAvcmRneTkvNQAvcmRneTkvNgAvcmRneTkvNwAvcmRneTkvOAAvcmRneTkvOQAvcmRwdTMvMQAvcmRwdTMvMgAvcmRwdTMvMwAvcmRwdTQvMQAvcmRwdTQvMgAvcmRwdTQvMwAvcmRwdTQvNAAvcmRwdTUvMQAvcmRwdTUvMgAvcmRwdTUvMwAvcmRwdTUvNAAvcmRwdTUvNQAvcmRwdTYvMQAvcmRwdTYvMgAvcmRwdTYvMwAvcmRwdTYvNAAvcmRwdTYvNQAvcmRwdTYvNgAvcmRwdTcvMQAvcmRwdTcvMgAvcmRwdTcvMwAvcmRwdTcvNAAvcmRwdTcvNQAvcmRwdTcvNgAvcmRwdTcvNwAvcmRwdTgvMQAvcmRwdTgvMgAvcmRwdTgvMwAvcmRwdTgvNAAvcmRwdTgvNQAvcmRwdTgvNgAvcmRwdTgvNwAvcmRwdTgvOAAvcmRwdTkvMQAvcmRwdTkvMgAvcmRwdTkvMwAvcmRwdTkvNAAvcmRwdTkvNQAvcmRwdTkvNgAvcmRwdTkvNwAvcmRwdTkvOAAvcmRwdTkvOQAvcmR5bGJ1MTAvMQAvcmR5bGJ1MTAvMTAAL3JkeWxidTEwLzIAL3JkeWxidTEwLzMAL3JkeWxidTEwLzQAL3JkeWxidTEwLzUAL3JkeWxidTEwLzYAL3JkeWxidTEwLzcAL3JkeWxidTEwLzgAL3JkeWxidTEwLzkAL3JkeWxidTExLzEAL3JkeWxidTExLzEwAC9yZHlsYnUxMS8xMQAvcmR5bGJ1MTEvMgAvcmR5bGJ1MTEvMwAvcmR5bGJ1MTEvNAAvcmR5bGJ1MTEvNQAvcmR5bGJ1MTEvNgAvcmR5bGJ1MTEvNwAvcmR5bGJ1MTEvOAAvcmR5bGJ1MTEvOQAvcmR5bGJ1My8xAC9yZHlsYnUzLzIAL3JkeWxidTMvMwAvcmR5bGJ1NC8xAC9yZHlsYnU0LzIAL3JkeWxidTQvMwAvcmR5bGJ1NC80AC9yZHlsYnU1LzEAL3JkeWxidTUvMgAvcmR5bGJ1NS8zAC9yZHlsYnU1LzQAL3JkeWxidTUvNQAvcmR5bGJ1Ni8xAC9yZHlsYnU2LzIAL3JkeWxidTYvMwAvcmR5bGJ1Ni80AC9yZHlsYnU2LzUAL3JkeWxidTYvNgAvcmR5bGJ1Ny8xAC9yZHlsYnU3LzIAL3JkeWxidTcvMwAvcmR5bGJ1Ny80AC9yZHlsYnU3LzUAL3JkeWxidTcvNgAvcmR5bGJ1Ny83AC9yZHlsYnU4LzEAL3JkeWxidTgvMgAvcmR5bGJ1OC8zAC9yZHlsYnU4LzQAL3JkeWxidTgvNQAvcmR5bGJ1OC82AC9yZHlsYnU4LzcAL3JkeWxidTgvOAAvcmR5bGJ1OS8xAC9yZHlsYnU5LzIAL3JkeWxidTkvMwAvcmR5bGJ1OS80AC9yZHlsYnU5LzUAL3JkeWxidTkvNgAvcmR5bGJ1OS83AC9yZHlsYnU5LzgAL3JkeWxidTkvOQAvcmR5bGduMTAvMQAvcmR5bGduMTAvMTAAL3JkeWxnbjEwLzIAL3JkeWxnbjEwLzMAL3JkeWxnbjEwLzQAL3JkeWxnbjEwLzUAL3JkeWxnbjEwLzYAL3JkeWxnbjEwLzcAL3JkeWxnbjEwLzgAL3JkeWxnbjEwLzkAL3JkeWxnbjExLzEAL3JkeWxnbjExLzEwAC9yZHlsZ24xMS8xMQAvcmR5bGduMTEvMgAvcmR5bGduMTEvMwAvcmR5bGduMTEvNAAvcmR5bGduMTEvNQAvcmR5bGduMTEvNgAvcmR5bGduMTEvNwAvcmR5bGduMTEvOAAvcmR5bGduMTEvOQAvcmR5bGduMy8xAC9yZHlsZ24zLzIAL3JkeWxnbjMvMwAvcmR5bGduNC8xAC9yZHlsZ240LzIAL3JkeWxnbjQvMwAvcmR5bGduNC80AC9yZHlsZ241LzEAL3JkeWxnbjUvMgAvcmR5bGduNS8zAC9yZHlsZ241LzQAL3JkeWxnbjUvNQAvcmR5bGduNi8xAC9yZHlsZ242LzIAL3JkeWxnbjYvMwAvcmR5bGduNi80AC9yZHlsZ242LzUAL3JkeWxnbjYvNgAvcmR5bGduNy8xAC9yZHlsZ243LzIAL3JkeWxnbjcvMwAvcmR5bGduNy80AC9yZHlsZ243LzUAL3JkeWxnbjcvNgAvcmR5bGduNy83AC9yZHlsZ244LzEAL3JkeWxnbjgvMgAvcmR5bGduOC8zAC9yZHlsZ244LzQAL3JkeWxnbjgvNQAvcmR5bGduOC82AC9yZHlsZ244LzcAL3JkeWxnbjgvOAAvcmR5bGduOS8xAC9yZHlsZ245LzIAL3JkeWxnbjkvMwAvcmR5bGduOS80AC9yZHlsZ245LzUAL3JkeWxnbjkvNgAvcmR5bGduOS83AC9yZHlsZ245LzgAL3JkeWxnbjkvOQAvcmVkczMvMQAvcmVkczMvMgAvcmVkczMvMwAvcmVkczQvMQAvcmVkczQvMgAvcmVkczQvMwAvcmVkczQvNAAvcmVkczUvMQAvcmVkczUvMgAvcmVkczUvMwAvcmVkczUvNAAvcmVkczUvNQAvcmVkczYvMQAvcmVkczYvMgAvcmVkczYvMwAvcmVkczYvNAAvcmVkczYvNQAvcmVkczYvNgAvcmVkczcvMQAvcmVkczcvMgAvcmVkczcvMwAvcmVkczcvNAAvcmVkczcvNQAvcmVkczcvNgAvcmVkczcvNwAvcmVkczgvMQAvcmVkczgvMgAvcmVkczgvMwAvcmVkczgvNAAvcmVkczgvNQAvcmVkczgvNgAvcmVkczgvNwAvcmVkczgvOAAvcmVkczkvMQAvcmVkczkvMgAvcmVkczkvMwAvcmVkczkvNAAvcmVkczkvNQAvcmVkczkvNgAvcmVkczkvNwAvcmVkczkvOAAvcmVkczkvOQAvc2V0MTMvMQAvc2V0MTMvMgAvc2V0MTMvMwAvc2V0MTQvMQAvc2V0MTQvMgAvc2V0MTQvMwAvc2V0MTQvNAAvc2V0MTUvMQAvc2V0MTUvMgAvc2V0MTUvMwAvc2V0MTUvNAAvc2V0MTUvNQAvc2V0MTYvMQAvc2V0MTYvMgAvc2V0MTYvMwAvc2V0MTYvNAAvc2V0MTYvNQAvc2V0MTYvNgAvc2V0MTcvMQAvc2V0MTcvMgAvc2V0MTcvMwAvc2V0MTcvNAAvc2V0MTcvNQAvc2V0MTcvNgAvc2V0MTcvNwAvc2V0MTgvMQAvc2V0MTgvMgAvc2V0MTgvMwAvc2V0MTgvNAAvc2V0MTgvNQAvc2V0MTgvNgAvc2V0MTgvNwAvc2V0MTgvOAAvc2V0MTkvMQAvc2V0MTkvMgAvc2V0MTkvMwAvc2V0MTkvNAAvc2V0MTkvNQAvc2V0MTkvNgAvc2V0MTkvNwAvc2V0MTkvOAAvc2V0MTkvOQAvc2V0MjMvMQAvc2V0MjMvMgAvc2V0MjMvMwAvc2V0MjQvMQAvc2V0MjQvMgAvc2V0MjQvMwAvc2V0MjQvNAAvc2V0MjUvMQAvc2V0MjUvMgAvc2V0MjUvMwAvc2V0MjUvNAAvc2V0MjUvNQAvc2V0MjYvMQAvc2V0MjYvMgAvc2V0MjYvMwAvc2V0MjYvNAAvc2V0MjYvNQAvc2V0MjYvNgAvc2V0MjcvMQAvc2V0MjcvMgAvc2V0MjcvMwAvc2V0MjcvNAAvc2V0MjcvNQAvc2V0MjcvNgAvc2V0MjcvNwAvc2V0MjgvMQAvc2V0MjgvMgAvc2V0MjgvMwAvc2V0MjgvNAAvc2V0MjgvNQAvc2V0MjgvNgAvc2V0MjgvNwAvc2V0MjgvOAAvc2V0MzEwLzEAL3NldDMxMC8xMAAvc2V0MzEwLzIAL3NldDMxMC8zAC9zZXQzMTAvNAAvc2V0MzEwLzUAL3NldDMxMC82AC9zZXQzMTAvNwAvc2V0MzEwLzgAL3NldDMxMC85AC9zZXQzMTEvMQAvc2V0MzExLzEwAC9zZXQzMTEvMTEAL3NldDMxMS8yAC9zZXQzMTEvMwAvc2V0MzExLzQAL3NldDMxMS81AC9zZXQzMTEvNgAvc2V0MzExLzcAL3NldDMxMS84AC9zZXQzMTEvOQAvc2V0MzEyLzEAL3NldDMxMi8xMAAvc2V0MzEyLzExAC9zZXQzMTIvMTIAL3NldDMxMi8yAC9zZXQzMTIvMwAvc2V0MzEyLzQAL3NldDMxMi81AC9zZXQzMTIvNgAvc2V0MzEyLzcAL3NldDMxMi84AC9zZXQzMTIvOQAvc2V0MzMvMQAvc2V0MzMvMgAvc2V0MzMvMwAvc2V0MzQvMQAvc2V0MzQvMgAvc2V0MzQvMwAvc2V0MzQvNAAvc2V0MzUvMQAvc2V0MzUvMgAvc2V0MzUvMwAvc2V0MzUvNAAvc2V0MzUvNQAvc2V0MzYvMQAvc2V0MzYvMgAvc2V0MzYvMwAvc2V0MzYvNAAvc2V0MzYvNQAvc2V0MzYvNgAvc2V0MzcvMQAvc2V0MzcvMgAvc2V0MzcvMwAvc2V0MzcvNAAvc2V0MzcvNQAvc2V0MzcvNgAvc2V0MzcvNwAvc2V0MzgvMQAvc2V0MzgvMgAvc2V0MzgvMwAvc2V0MzgvNAAvc2V0MzgvNQAvc2V0MzgvNgAvc2V0MzgvNwAvc2V0MzgvOAAvc2V0MzkvMQAvc2V0MzkvMgAvc2V0MzkvMwAvc2V0MzkvNAAvc2V0MzkvNQAvc2V0MzkvNgAvc2V0MzkvNwAvc2V0MzkvOAAvc2V0MzkvOQAvc3BlY3RyYWwxMC8xAC9zcGVjdHJhbDEwLzEwAC9zcGVjdHJhbDEwLzIAL3NwZWN0cmFsMTAvMwAvc3BlY3RyYWwxMC80AC9zcGVjdHJhbDEwLzUAL3NwZWN0cmFsMTAvNgAvc3BlY3RyYWwxMC83AC9zcGVjdHJhbDEwLzgAL3NwZWN0cmFsMTAvOQAvc3BlY3RyYWwxMS8xAC9zcGVjdHJhbDExLzEwAC9zcGVjdHJhbDExLzExAC9zcGVjdHJhbDExLzIAL3NwZWN0cmFsMTEvMwAvc3BlY3RyYWwxMS80AC9zcGVjdHJhbDExLzUAL3NwZWN0cmFsMTEvNgAvc3BlY3RyYWwxMS83AC9zcGVjdHJhbDExLzgAL3NwZWN0cmFsMTEvOQAvc3BlY3RyYWwzLzEAL3NwZWN0cmFsMy8yAC9zcGVjdHJhbDMvMwAvc3BlY3RyYWw0LzEAL3NwZWN0cmFsNC8yAC9zcGVjdHJhbDQvMwAvc3BlY3RyYWw0LzQAL3NwZWN0cmFsNS8xAC9zcGVjdHJhbDUvMgAvc3BlY3RyYWw1LzMAL3NwZWN0cmFsNS80AC9zcGVjdHJhbDUvNQAvc3BlY3RyYWw2LzEAL3NwZWN0cmFsNi8yAC9zcGVjdHJhbDYvMwAvc3BlY3RyYWw2LzQAL3NwZWN0cmFsNi81AC9zcGVjdHJhbDYvNgAvc3BlY3RyYWw3LzEAL3NwZWN0cmFsNy8yAC9zcGVjdHJhbDcvMwAvc3BlY3RyYWw3LzQAL3NwZWN0cmFsNy81AC9zcGVjdHJhbDcvNgAvc3BlY3RyYWw3LzcAL3NwZWN0cmFsOC8xAC9zcGVjdHJhbDgvMgAvc3BlY3RyYWw4LzMAL3NwZWN0cmFsOC80AC9zcGVjdHJhbDgvNQAvc3BlY3RyYWw4LzYAL3NwZWN0cmFsOC83AC9zcGVjdHJhbDgvOAAvc3BlY3RyYWw5LzEAL3NwZWN0cmFsOS8yAC9zcGVjdHJhbDkvMwAvc3BlY3RyYWw5LzQAL3NwZWN0cmFsOS81AC9zcGVjdHJhbDkvNgAvc3BlY3RyYWw5LzcAL3NwZWN0cmFsOS84AC9zcGVjdHJhbDkvOQAvc3ZnL2FsaWNlYmx1ZQAvc3ZnL2FudGlxdWV3aGl0ZQAvc3ZnL2FxdWEAL3N2Zy9hcXVhbWFyaW5lAC9zdmcvYXp1cmUAL3N2Zy9iZWlnZQAvc3ZnL2Jpc3F1ZQAvc3ZnL2JsYWNrAC9zdmcvYmxhbmNoZWRhbG1vbmQAL3N2Zy9ibHVlAC9zdmcvYmx1ZXZpb2xldAAvc3ZnL2Jyb3duAC9zdmcvYnVybHl3b29kAC9zdmcvY2FkZXRibHVlAC9zdmcvY2hhcnRyZXVzZQAvc3ZnL2Nob2NvbGF0ZQAvc3ZnL2NvcmFsAC9zdmcvY29ybmZsb3dlcmJsdWUAL3N2Zy9jb3Juc2lsawAvc3ZnL2NyaW1zb24AL3N2Zy9jeWFuAC9zdmcvZGFya2JsdWUAL3N2Zy9kYXJrY3lhbgAvc3ZnL2Rhcmtnb2xkZW5yb2QAL3N2Zy9kYXJrZ3JheQAvc3ZnL2RhcmtncmVlbgAvc3ZnL2RhcmtncmV5AC9zdmcvZGFya2toYWtpAC9zdmcvZGFya21hZ2VudGEAL3N2Zy9kYXJrb2xpdmVncmVlbgAvc3ZnL2RhcmtvcmFuZ2UAL3N2Zy9kYXJrb3JjaGlkAC9zdmcvZGFya3JlZAAvc3ZnL2RhcmtzYWxtb24AL3N2Zy9kYXJrc2VhZ3JlZW4AL3N2Zy9kYXJrc2xhdGVibHVlAC9zdmcvZGFya3NsYXRlZ3JheQAvc3ZnL2RhcmtzbGF0ZWdyZXkAL3N2Zy9kYXJrdHVycXVvaXNlAC9zdmcvZGFya3Zpb2xldAAvc3ZnL2RlZXBwaW5rAC9zdmcvZGVlcHNreWJsdWUAL3N2Zy9kaW1ncmF5AC9zdmcvZGltZ3JleQAvc3ZnL2RvZGdlcmJsdWUAL3N2Zy9maXJlYnJpY2sAL3N2Zy9mbG9yYWx3aGl0ZQAvc3ZnL2ZvcmVzdGdyZWVuAC9zdmcvZnVjaHNpYQAvc3ZnL2dhaW5zYm9ybwAvc3ZnL2dob3N0d2hpdGUAL3N2Zy9nb2xkAC9zdmcvZ29sZGVucm9kAC9zdmcvZ3JheQAvc3ZnL2dyZWVuAC9zdmcvZ3JlZW55ZWxsb3cAL3N2Zy9ncmV5AC9zdmcvaG9uZXlkZXcAL3N2Zy9ob3RwaW5rAC9zdmcvaW5kaWFucmVkAC9zdmcvaW5kaWdvAC9zdmcvaXZvcnkAL3N2Zy9raGFraQAvc3ZnL2xhdmVuZGVyAC9zdmcvbGF2ZW5kZXJibHVzaAAvc3ZnL2xhd25ncmVlbgAvc3ZnL2xlbW9uY2hpZmZvbgAvc3ZnL2xpZ2h0Ymx1ZQAvc3ZnL2xpZ2h0Y29yYWwAL3N2Zy9saWdodGN5YW4AL3N2Zy9saWdodGdvbGRlbnJvZHllbGxvdwAvc3ZnL2xpZ2h0Z3JheQAvc3ZnL2xpZ2h0Z3JlZW4AL3N2Zy9saWdodGdyZXkAL3N2Zy9saWdodHBpbmsAL3N2Zy9saWdodHNhbG1vbgAvc3ZnL2xpZ2h0c2VhZ3JlZW4AL3N2Zy9saWdodHNreWJsdWUAL3N2Zy9saWdodHNsYXRlZ3JheQAvc3ZnL2xpZ2h0c2xhdGVncmV5AC9zdmcvbGlnaHRzdGVlbGJsdWUAL3N2Zy9saWdodHllbGxvdwAvc3ZnL2xpbWUAL3N2Zy9saW1lZ3JlZW4AL3N2Zy9saW5lbgAvc3ZnL21hZ2VudGEAL3N2Zy9tYXJvb24AL3N2Zy9tZWRpdW1hcXVhbWFyaW5lAC9zdmcvbWVkaXVtYmx1ZQAvc3ZnL21lZGl1bW9yY2hpZAAvc3ZnL21lZGl1bXB1cnBsZQAvc3ZnL21lZGl1bXNlYWdyZWVuAC9zdmcvbWVkaXVtc2xhdGVibHVlAC9zdmcvbWVkaXVtc3ByaW5nZ3JlZW4AL3N2Zy9tZWRpdW10dXJxdW9pc2UAL3N2Zy9tZWRpdW12aW9sZXRyZWQAL3N2Zy9taWRuaWdodGJsdWUAL3N2Zy9taW50Y3JlYW0AL3N2Zy9taXN0eXJvc2UAL3N2Zy9tb2NjYXNpbgAvc3ZnL25hdmFqb3doaXRlAC9zdmcvbmF2eQAvc3ZnL29sZGxhY2UAL3N2Zy9vbGl2ZQAvc3ZnL29saXZlZHJhYgAvc3ZnL29yYW5nZQAvc3ZnL29yYW5nZXJlZAAvc3ZnL29yY2hpZAAvc3ZnL3BhbGVnb2xkZW5yb2QAL3N2Zy9wYWxlZ3JlZW4AL3N2Zy9wYWxldHVycXVvaXNlAC9zdmcvcGFsZXZpb2xldHJlZAAvc3ZnL3BhcGF5YXdoaXAAL3N2Zy9wZWFjaHB1ZmYAL3N2Zy9wZXJ1AC9zdmcvcGluawAvc3ZnL3BsdW0AL3N2Zy9wb3dkZXJibHVlAC9zdmcvcHVycGxlAC9zdmcvcmVkAC9zdmcvcm9zeWJyb3duAC9zdmcvcm95YWxibHVlAC9zdmcvc2FkZGxlYnJvd24AL3N2Zy9zYWxtb24AL3N2Zy9zYW5keWJyb3duAC9zdmcvc2VhZ3JlZW4AL3N2Zy9zZWFzaGVsbAAvc3ZnL3NpZW5uYQAvc3ZnL3NpbHZlcgAvc3ZnL3NreWJsdWUAL3N2Zy9zbGF0ZWJsdWUAL3N2Zy9zbGF0ZWdyYXkAL3N2Zy9zbGF0ZWdyZXkAL3N2Zy9zbm93AC9zdmcvc3ByaW5nZ3JlZW4AL3N2Zy9zdGVlbGJsdWUAL3N2Zy90YW4AL3N2Zy90ZWFsAC9zdmcvdGhpc3RsZQAvc3ZnL3RvbWF0bwAvc3ZnL3R1cnF1b2lzZQAvc3ZnL3Zpb2xldAAvc3ZnL3doZWF0AC9zdmcvd2hpdGUAL3N2Zy93aGl0ZXNtb2tlAC9zdmcveWVsbG93AC9zdmcveWVsbG93Z3JlZW4AL3lsZ24zLzEAL3lsZ24zLzIAL3lsZ24zLzMAL3lsZ240LzEAL3lsZ240LzIAL3lsZ240LzMAL3lsZ240LzQAL3lsZ241LzEAL3lsZ241LzIAL3lsZ241LzMAL3lsZ241LzQAL3lsZ241LzUAL3lsZ242LzEAL3lsZ242LzIAL3lsZ242LzMAL3lsZ242LzQAL3lsZ242LzUAL3lsZ242LzYAL3lsZ243LzEAL3lsZ243LzIAL3lsZ243LzMAL3lsZ243LzQAL3lsZ243LzUAL3lsZ243LzYAL3lsZ243LzcAL3lsZ244LzEAL3lsZ244LzIAL3lsZ244LzMAL3lsZ244LzQAL3lsZ244LzUAL3lsZ244LzYAL3lsZ244LzcAL3lsZ244LzgAL3lsZ245LzEAL3lsZ245LzIAL3lsZ245LzMAL3lsZ245LzQAL3lsZ245LzUAL3lsZ245LzYAL3lsZ245LzcAL3lsZ245LzgAL3lsZ245LzkAL3lsZ25idTMvMQAveWxnbmJ1My8yAC95bGduYnUzLzMAL3lsZ25idTQvMQAveWxnbmJ1NC8yAC95bGduYnU0LzMAL3lsZ25idTQvNAAveWxnbmJ1NS8xAC95bGduYnU1LzIAL3lsZ25idTUvMwAveWxnbmJ1NS80AC95bGduYnU1LzUAL3lsZ25idTYvMQAveWxnbmJ1Ni8yAC95bGduYnU2LzMAL3lsZ25idTYvNAAveWxnbmJ1Ni81AC95bGduYnU2LzYAL3lsZ25idTcvMQAveWxnbmJ1Ny8yAC95bGduYnU3LzMAL3lsZ25idTcvNAAveWxnbmJ1Ny81AC95bGduYnU3LzYAL3lsZ25idTcvNwAveWxnbmJ1OC8xAC95bGduYnU4LzIAL3lsZ25idTgvMwAveWxnbmJ1OC80AC95bGduYnU4LzUAL3lsZ25idTgvNgAveWxnbmJ1OC83AC95bGduYnU4LzgAL3lsZ25idTkvMQAveWxnbmJ1OS8yAC95bGduYnU5LzMAL3lsZ25idTkvNAAveWxnbmJ1OS81AC95bGduYnU5LzYAL3lsZ25idTkvNwAveWxnbmJ1OS84AC95bGduYnU5LzkAL3lsb3JicjMvMQAveWxvcmJyMy8yAC95bG9yYnIzLzMAL3lsb3JicjQvMQAveWxvcmJyNC8yAC95bG9yYnI0LzMAL3lsb3JicjQvNAAveWxvcmJyNS8xAC95bG9yYnI1LzIAL3lsb3JicjUvMwAveWxvcmJyNS80AC95bG9yYnI1LzUAL3lsb3JicjYvMQAveWxvcmJyNi8yAC95bG9yYnI2LzMAL3lsb3JicjYvNAAveWxvcmJyNi81AC95bG9yYnI2LzYAL3lsb3JicjcvMQAveWxvcmJyNy8yAC95bG9yYnI3LzMAL3lsb3JicjcvNAAveWxvcmJyNy81AC95bG9yYnI3LzYAL3lsb3JicjcvNwAveWxvcmJyOC8xAC95bG9yYnI4LzIAL3lsb3JicjgvMwAveWxvcmJyOC80AC95bG9yYnI4LzUAL3lsb3JicjgvNgAveWxvcmJyOC83AC95bG9yYnI4LzgAL3lsb3JicjkvMQAveWxvcmJyOS8yAC95bG9yYnI5LzMAL3lsb3JicjkvNAAveWxvcmJyOS81AC95bG9yYnI5LzYAL3lsb3JicjkvNwAveWxvcmJyOS84AC95bG9yYnI5LzkAL3lsb3JyZDMvMQAveWxvcnJkMy8yAC95bG9ycmQzLzMAL3lsb3JyZDQvMQAveWxvcnJkNC8yAC95bG9ycmQ0LzMAL3lsb3JyZDQvNAAveWxvcnJkNS8xAC95bG9ycmQ1LzIAL3lsb3JyZDUvMwAveWxvcnJkNS80AC95bG9ycmQ1LzUAL3lsb3JyZDYvMQAveWxvcnJkNi8yAC95bG9ycmQ2LzMAL3lsb3JyZDYvNAAveWxvcnJkNi81AC95bG9ycmQ2LzYAL3lsb3JyZDcvMQAveWxvcnJkNy8yAC95bG9ycmQ3LzMAL3lsb3JyZDcvNAAveWxvcnJkNy81AC95bG9ycmQ3LzYAL3lsb3JyZDcvNwAveWxvcnJkOC8xAC95bG9ycmQ4LzIAL3lsb3JyZDgvMwAveWxvcnJkOC80AC95bG9ycmQ4LzUAL3lsb3JyZDgvNgAveWxvcnJkOC83AC95bG9ycmQ4LzgAL3lsb3JyZDkvMQAveWxvcnJkOS8yAC95bG9ycmQ5LzMAL3lsb3JyZDkvNAAveWxvcnJkOS81AC95bG9ycmQ5LzYAL3lsb3JyZDkvNwAveWxvcnJkOS84AC95bG9ycmQ5LzkAYWxpY2VibHVlAGFudGlxdWV3aGl0ZQBhbnRpcXVld2hpdGUxAGFudGlxdWV3aGl0ZTIAYW50aXF1ZXdoaXRlMwBhbnRpcXVld2hpdGU0AGFxdWFtYXJpbmUAYXF1YW1hcmluZTEAYXF1YW1hcmluZTIAYXF1YW1hcmluZTMAYXF1YW1hcmluZTQAYXp1cmUAYXp1cmUxAGF6dXJlMgBhenVyZTMAYXp1cmU0AGJlaWdlAGJpc3F1ZQBiaXNxdWUxAGJpc3F1ZTIAYmlzcXVlMwBiaXNxdWU0AGJsYW5jaGVkYWxtb25kAGJsdWUAYmx1ZTEAYmx1ZTIAYmx1ZTMAYmx1ZTQAYmx1ZXZpb2xldABicm93bgBicm93bjEAYnJvd24yAGJyb3duMwBicm93bjQAYnVybHl3b29kAGJ1cmx5d29vZDEAYnVybHl3b29kMgBidXJseXdvb2QzAGJ1cmx5d29vZDQAY2FkZXRibHVlAGNhZGV0Ymx1ZTEAY2FkZXRibHVlMgBjYWRldGJsdWUzAGNhZGV0Ymx1ZTQAY2hhcnRyZXVzZQBjaGFydHJldXNlMQBjaGFydHJldXNlMgBjaGFydHJldXNlMwBjaGFydHJldXNlNABjaG9jb2xhdGUAY2hvY29sYXRlMQBjaG9jb2xhdGUyAGNob2NvbGF0ZTMAY2hvY29sYXRlNABjb3JhbABjb3JhbDEAY29yYWwyAGNvcmFsMwBjb3JhbDQAY29ybmZsb3dlcmJsdWUAY29ybnNpbGsAY29ybnNpbGsxAGNvcm5zaWxrMgBjb3Juc2lsazMAY29ybnNpbGs0AGNyaW1zb24AY3lhbgBjeWFuMQBjeWFuMgBjeWFuMwBjeWFuNABkYXJrZ29sZGVucm9kAGRhcmtnb2xkZW5yb2QxAGRhcmtnb2xkZW5yb2QyAGRhcmtnb2xkZW5yb2QzAGRhcmtnb2xkZW5yb2Q0AGRhcmtncmVlbgBkYXJra2hha2kAZGFya29saXZlZ3JlZW4AZGFya29saXZlZ3JlZW4xAGRhcmtvbGl2ZWdyZWVuMgBkYXJrb2xpdmVncmVlbjMAZGFya29saXZlZ3JlZW40AGRhcmtvcmFuZ2UAZGFya29yYW5nZTEAZGFya29yYW5nZTIAZGFya29yYW5nZTMAZGFya29yYW5nZTQAZGFya29yY2hpZABkYXJrb3JjaGlkMQBkYXJrb3JjaGlkMgBkYXJrb3JjaGlkMwBkYXJrb3JjaGlkNABkYXJrc2FsbW9uAGRhcmtzZWFncmVlbgBkYXJrc2VhZ3JlZW4xAGRhcmtzZWFncmVlbjIAZGFya3NlYWdyZWVuMwBkYXJrc2VhZ3JlZW40AGRhcmtzbGF0ZWJsdWUAZGFya3NsYXRlZ3JheQBkYXJrc2xhdGVncmF5MQBkYXJrc2xhdGVncmF5MgBkYXJrc2xhdGVncmF5MwBkYXJrc2xhdGVncmF5NABkYXJrc2xhdGVncmV5AGRhcmt0dXJxdW9pc2UAZGFya3Zpb2xldABkZWVwcGluawBkZWVwcGluazEAZGVlcHBpbmsyAGRlZXBwaW5rMwBkZWVwcGluazQAZGVlcHNreWJsdWUAZGVlcHNreWJsdWUxAGRlZXBza3libHVlMgBkZWVwc2t5Ymx1ZTMAZGVlcHNreWJsdWU0AGRpbWdyYXkAZGltZ3JleQBkb2RnZXJibHVlAGRvZGdlcmJsdWUxAGRvZGdlcmJsdWUyAGRvZGdlcmJsdWUzAGRvZGdlcmJsdWU0AGZpcmVicmljawBmaXJlYnJpY2sxAGZpcmVicmljazIAZmlyZWJyaWNrMwBmaXJlYnJpY2s0AGZsb3JhbHdoaXRlAGZvcmVzdGdyZWVuAGdhaW5zYm9ybwBnaG9zdHdoaXRlAGdvbGQAZ29sZDEAZ29sZDIAZ29sZDMAZ29sZDQAZ29sZGVucm9kAGdvbGRlbnJvZDEAZ29sZGVucm9kMgBnb2xkZW5yb2QzAGdvbGRlbnJvZDQAZ3JheQBncmF5MABncmF5MQBncmF5MTAAZ3JheTEwMABncmF5MTEAZ3JheTEyAGdyYXkxMwBncmF5MTQAZ3JheTE1AGdyYXkxNgBncmF5MTcAZ3JheTE4AGdyYXkxOQBncmF5MgBncmF5MjAAZ3JheTIxAGdyYXkyMgBncmF5MjMAZ3JheTI0AGdyYXkyNQBncmF5MjYAZ3JheTI3AGdyYXkyOABncmF5MjkAZ3JheTMAZ3JheTMwAGdyYXkzMQBncmF5MzIAZ3JheTMzAGdyYXkzNABncmF5MzUAZ3JheTM2AGdyYXkzNwBncmF5MzgAZ3JheTM5AGdyYXk0AGdyYXk0MABncmF5NDEAZ3JheTQyAGdyYXk0MwBncmF5NDQAZ3JheTQ1AGdyYXk0NgBncmF5NDcAZ3JheTQ4AGdyYXk0OQBncmF5NQBncmF5NTAAZ3JheTUxAGdyYXk1MgBncmF5NTMAZ3JheTU0AGdyYXk1NQBncmF5NTYAZ3JheTU3AGdyYXk1OABncmF5NTkAZ3JheTYAZ3JheTYwAGdyYXk2MQBncmF5NjIAZ3JheTYzAGdyYXk2NABncmF5NjUAZ3JheTY2AGdyYXk2NwBncmF5NjgAZ3JheTY5AGdyYXk3AGdyYXk3MABncmF5NzEAZ3JheTcyAGdyYXk3MwBncmF5NzQAZ3JheTc1AGdyYXk3NgBncmF5NzcAZ3JheTc4AGdyYXk3OQBncmF5OABncmF5ODAAZ3JheTgxAGdyYXk4MgBncmF5ODMAZ3JheTg0AGdyYXk4NQBncmF5ODYAZ3JheTg3AGdyYXk4OABncmF5ODkAZ3JheTkAZ3JheTkwAGdyYXk5MQBncmF5OTIAZ3JheTkzAGdyYXk5NABncmF5OTUAZ3JheTk2AGdyYXk5NwBncmF5OTgAZ3JheTk5AGdyZWVuAGdyZWVuMQBncmVlbjIAZ3JlZW4zAGdyZWVuNABncmVlbnllbGxvdwBncmV5AGdyZXkwAGdyZXkxAGdyZXkxMABncmV5MTAwAGdyZXkxMQBncmV5MTIAZ3JleTEzAGdyZXkxNABncmV5MTUAZ3JleTE2AGdyZXkxNwBncmV5MTgAZ3JleTE5AGdyZXkyAGdyZXkyMABncmV5MjEAZ3JleTIyAGdyZXkyMwBncmV5MjQAZ3JleTI1AGdyZXkyNgBncmV5MjcAZ3JleTI4AGdyZXkyOQBncmV5MwBncmV5MzAAZ3JleTMxAGdyZXkzMgBncmV5MzMAZ3JleTM0AGdyZXkzNQBncmV5MzYAZ3JleTM3AGdyZXkzOABncmV5MzkAZ3JleTQAZ3JleTQwAGdyZXk0MQBncmV5NDIAZ3JleTQzAGdyZXk0NABncmV5NDUAZ3JleTQ2AGdyZXk0NwBncmV5NDgAZ3JleTQ5AGdyZXk1AGdyZXk1MABncmV5NTEAZ3JleTUyAGdyZXk1MwBncmV5NTQAZ3JleTU1AGdyZXk1NgBncmV5NTcAZ3JleTU4AGdyZXk1OQBncmV5NgBncmV5NjAAZ3JleTYxAGdyZXk2MgBncmV5NjMAZ3JleTY0AGdyZXk2NQBncmV5NjYAZ3JleTY3AGdyZXk2OABncmV5NjkAZ3JleTcAZ3JleTcwAGdyZXk3MQBncmV5NzIAZ3JleTczAGdyZXk3NABncmV5NzUAZ3JleTc2AGdyZXk3NwBncmV5NzgAZ3JleTc5AGdyZXk4AGdyZXk4MABncmV5ODEAZ3JleTgyAGdyZXk4MwBncmV5ODQAZ3JleTg1AGdyZXk4NgBncmV5ODcAZ3JleTg4AGdyZXk4OQBncmV5OQBncmV5OTAAZ3JleTkxAGdyZXk5MgBncmV5OTMAZ3JleTk0AGdyZXk5NQBncmV5OTYAZ3JleTk3AGdyZXk5OABncmV5OTkAaG9uZXlkZXcAaG9uZXlkZXcxAGhvbmV5ZGV3MgBob25leWRldzMAaG9uZXlkZXc0AGhvdHBpbmsAaG90cGluazEAaG90cGluazIAaG90cGluazMAaG90cGluazQAaW5kaWFucmVkAGluZGlhbnJlZDEAaW5kaWFucmVkMgBpbmRpYW5yZWQzAGluZGlhbnJlZDQAaW5kaWdvAGludmlzAGl2b3J5AGl2b3J5MQBpdm9yeTIAaXZvcnkzAGl2b3J5NABraGFraQBraGFraTEAa2hha2kyAGtoYWtpMwBraGFraTQAbGF2ZW5kZXIAbGF2ZW5kZXJibHVzaABsYXZlbmRlcmJsdXNoMQBsYXZlbmRlcmJsdXNoMgBsYXZlbmRlcmJsdXNoMwBsYXZlbmRlcmJsdXNoNABsYXduZ3JlZW4AbGVtb25jaGlmZm9uAGxlbW9uY2hpZmZvbjEAbGVtb25jaGlmZm9uMgBsZW1vbmNoaWZmb24zAGxlbW9uY2hpZmZvbjQAbGlnaHRibHVlAGxpZ2h0Ymx1ZTEAbGlnaHRibHVlMgBsaWdodGJsdWUzAGxpZ2h0Ymx1ZTQAbGlnaHRjb3JhbABsaWdodGN5YW4AbGlnaHRjeWFuMQBsaWdodGN5YW4yAGxpZ2h0Y3lhbjMAbGlnaHRjeWFuNABsaWdodGdvbGRlbnJvZABsaWdodGdvbGRlbnJvZDEAbGlnaHRnb2xkZW5yb2QyAGxpZ2h0Z29sZGVucm9kMwBsaWdodGdvbGRlbnJvZDQAbGlnaHRnb2xkZW5yb2R5ZWxsb3cAbGlnaHRncmF5AGxpZ2h0Z3JleQBsaWdodHBpbmsAbGlnaHRwaW5rMQBsaWdodHBpbmsyAGxpZ2h0cGluazMAbGlnaHRwaW5rNABsaWdodHNhbG1vbgBsaWdodHNhbG1vbjEAbGlnaHRzYWxtb24yAGxpZ2h0c2FsbW9uMwBsaWdodHNhbG1vbjQAbGlnaHRzZWFncmVlbgBsaWdodHNreWJsdWUAbGlnaHRza3libHVlMQBsaWdodHNreWJsdWUyAGxpZ2h0c2t5Ymx1ZTMAbGlnaHRza3libHVlNABsaWdodHNsYXRlYmx1ZQBsaWdodHNsYXRlZ3JheQBsaWdodHNsYXRlZ3JleQBsaWdodHN0ZWVsYmx1ZQBsaWdodHN0ZWVsYmx1ZTEAbGlnaHRzdGVlbGJsdWUyAGxpZ2h0c3RlZWxibHVlMwBsaWdodHN0ZWVsYmx1ZTQAbGlnaHR5ZWxsb3cAbGlnaHR5ZWxsb3cxAGxpZ2h0eWVsbG93MgBsaWdodHllbGxvdzMAbGlnaHR5ZWxsb3c0AGxpbWVncmVlbgBsaW5lbgBtYWdlbnRhAG1hZ2VudGExAG1hZ2VudGEyAG1hZ2VudGEzAG1hZ2VudGE0AG1hcm9vbgBtYXJvb24xAG1hcm9vbjIAbWFyb29uMwBtYXJvb240AG1lZGl1bWFxdWFtYXJpbmUAbWVkaXVtYmx1ZQBtZWRpdW1vcmNoaWQAbWVkaXVtb3JjaGlkMQBtZWRpdW1vcmNoaWQyAG1lZGl1bW9yY2hpZDMAbWVkaXVtb3JjaGlkNABtZWRpdW1wdXJwbGUAbWVkaXVtcHVycGxlMQBtZWRpdW1wdXJwbGUyAG1lZGl1bXB1cnBsZTMAbWVkaXVtcHVycGxlNABtZWRpdW1zZWFncmVlbgBtZWRpdW1zbGF0ZWJsdWUAbWVkaXVtc3ByaW5nZ3JlZW4AbWVkaXVtdHVycXVvaXNlAG1lZGl1bXZpb2xldHJlZABtaWRuaWdodGJsdWUAbWludGNyZWFtAG1pc3R5cm9zZQBtaXN0eXJvc2UxAG1pc3R5cm9zZTIAbWlzdHlyb3NlMwBtaXN0eXJvc2U0AG1vY2Nhc2luAG5hdmFqb3doaXRlAG5hdmFqb3doaXRlMQBuYXZham93aGl0ZTIAbmF2YWpvd2hpdGUzAG5hdmFqb3doaXRlNABuYXZ5AG5hdnlibHVlAG5vbmUAb2xkbGFjZQBvbGl2ZWRyYWIAb2xpdmVkcmFiMQBvbGl2ZWRyYWIyAG9saXZlZHJhYjMAb2xpdmVkcmFiNABvcmFuZ2UAb3JhbmdlMQBvcmFuZ2UyAG9yYW5nZTMAb3JhbmdlNABvcmFuZ2VyZWQAb3JhbmdlcmVkMQBvcmFuZ2VyZWQyAG9yYW5nZXJlZDMAb3JhbmdlcmVkNABvcmNoaWQAb3JjaGlkMQBvcmNoaWQyAG9yY2hpZDMAb3JjaGlkNABwYWxlZ29sZGVucm9kAHBhbGVncmVlbgBwYWxlZ3JlZW4xAHBhbGVncmVlbjIAcGFsZWdyZWVuMwBwYWxlZ3JlZW40AHBhbGV0dXJxdW9pc2UAcGFsZXR1cnF1b2lzZTEAcGFsZXR1cnF1b2lzZTIAcGFsZXR1cnF1b2lzZTMAcGFsZXR1cnF1b2lzZTQAcGFsZXZpb2xldHJlZABwYWxldmlvbGV0cmVkMQBwYWxldmlvbGV0cmVkMgBwYWxldmlvbGV0cmVkMwBwYWxldmlvbGV0cmVkNABwYXBheWF3aGlwAHBlYWNocHVmZgBwZWFjaHB1ZmYxAHBlYWNocHVmZjIAcGVhY2hwdWZmMwBwZWFjaHB1ZmY0AHBlcnUAcGluawBwaW5rMQBwaW5rMgBwaW5rMwBwaW5rNABwbHVtAHBsdW0xAHBsdW0yAHBsdW0zAHBsdW00AHBvd2RlcmJsdWUAcHVycGxlAHB1cnBsZTEAcHVycGxlMgBwdXJwbGUzAHB1cnBsZTQAcmVkAHJlZDEAcmVkMgByZWQzAHJlZDQAcm9zeWJyb3duAHJvc3licm93bjEAcm9zeWJyb3duMgByb3N5YnJvd24zAHJvc3licm93bjQAcm95YWxibHVlAHJveWFsYmx1ZTEAcm95YWxibHVlMgByb3lhbGJsdWUzAHJveWFsYmx1ZTQAc2FkZGxlYnJvd24Ac2FsbW9uAHNhbG1vbjEAc2FsbW9uMgBzYWxtb24zAHNhbG1vbjQAc2FuZHlicm93bgBzZWFncmVlbgBzZWFncmVlbjEAc2VhZ3JlZW4yAHNlYWdyZWVuMwBzZWFncmVlbjQAc2Vhc2hlbGwAc2Vhc2hlbGwxAHNlYXNoZWxsMgBzZWFzaGVsbDMAc2Vhc2hlbGw0AHNpZW5uYQBzaWVubmExAHNpZW5uYTIAc2llbm5hMwBzaWVubmE0AHNreWJsdWUAc2t5Ymx1ZTEAc2t5Ymx1ZTIAc2t5Ymx1ZTMAc2t5Ymx1ZTQAc2xhdGVibHVlAHNsYXRlYmx1ZTEAc2xhdGVibHVlMgBzbGF0ZWJsdWUzAHNsYXRlYmx1ZTQAc2xhdGVncmF5AHNsYXRlZ3JheTEAc2xhdGVncmF5MgBzbGF0ZWdyYXkzAHNsYXRlZ3JheTQAc2xhdGVncmV5AHNub3cAc25vdzEAc25vdzIAc25vdzMAc25vdzQAc3ByaW5nZ3JlZW4Ac3ByaW5nZ3JlZW4xAHNwcmluZ2dyZWVuMgBzcHJpbmdncmVlbjMAc3ByaW5nZ3JlZW40AHN0ZWVsYmx1ZQBzdGVlbGJsdWUxAHN0ZWVsYmx1ZTIAc3RlZWxibHVlMwBzdGVlbGJsdWU0AHRhbgB0YW4xAHRhbjIAdGFuMwB0YW40AHRoaXN0bGUAdGhpc3RsZTEAdGhpc3RsZTIAdGhpc3RsZTMAdGhpc3RsZTQAdG9tYXRvAHRvbWF0bzEAdG9tYXRvMgB0b21hdG8zAHRvbWF0bzQAdHVycXVvaXNlAHR1cnF1b2lzZTEAdHVycXVvaXNlMgB0dXJxdW9pc2UzAHR1cnF1b2lzZTQAdmlvbGV0AHZpb2xldHJlZAB2aW9sZXRyZWQxAHZpb2xldHJlZDIAdmlvbGV0cmVkMwB2aW9sZXRyZWQ0AHdoZWF0AHdoZWF0MQB3aGVhdDIAd2hlYXQzAHdoZWF0NAB3aGl0ZQB3aGl0ZXNtb2tlAHllbGxvdwB5ZWxsb3cxAHllbGxvdzIAeWVsbG93MwB5ZWxsb3c0AHllbGxvd2dyZWVuAGxhY2sAaGl0ZQBpZ2h0Z3JleQBYMTEvAC8lcy8lcwBpbWFnZXNjYWxlAGZhbHNlAGJsYWNrAGRvdHRlZABkYXNoZWQAY3AtPnNyYwBodG1sdGFibGUuYwBlbWl0X2h0bWxfaW1nAGNwLT5zcmNbMF0AdHJhbnNwYXJlbnQAXyVkACVkADEAMgAzADQANQA2ADcAOAA5ADEwADExADEyADEzADE0ADE1ADE2ADE3ADE4ADE5ADIwAEFnbm9kZWluZm9fdABBZ2VkZ2VpbmZvX3QAcm93ZwBjb2xnAEFncmFwaGluZm9fdAA8VEFCTEU+AGRlbHggPj0gMABwb3NfaHRtbF90YmwAZGVseSA+PSAwAHRhYmxlIHNpemUgdG9vIHNtYWxsIGZvciBjb250ZW50CgBmaXhlZCB0YWJsZSBzaXplIHdpdGggdW5zcGVjaWZpZWQgd2lkdGggb3IgaGVpZ2h0CgBjZWxsIHNpemUgdG9vIHNtYWxsIGZvciBjb250ZW50CgBmaXhlZCBjZWxsIHNpemUgd2l0aCB1bnNwZWNpZmllZCB3aWR0aCBvciBoZWlnaHQKAE5vIG9yIGltcHJvcGVyIGltYWdlIGZpbGU9IiVzIgoAcGVuY29sb3IAY29sb3IALT4ALS0AZlBRLmMAUFFjaGVjawBIZWFwIG92ZXJmbG93CgAlIVBTLUFkb2JlLTIuMAovbm9kZSB7CiAgL1kgZXhjaCBkZWYKICAvWCBleGNoIGRlZgogIC95IGV4Y2ggZGVmCiAgL3ggZXhjaCBkZWYKICBuZXdwYXRoCiAgeCB5IG1vdmV0bwogIHggWSBsaW5ldG8KICBYIFkgbGluZXRvCiAgWCB5IGxpbmV0bwogIGNsb3NlcGF0aCBmaWxsCn0gZGVmCi9jZWxsIHsKICAvWSBleGNoIGRlZgogIC9YIGV4Y2ggZGVmCiAgL3kgZXhjaCBkZWYKICAveCBleGNoIGRlZgogIG5ld3BhdGgKICB4IHkgbW92ZXRvCiAgeCBZIGxpbmV0bwogIFggWSBsaW5ldG8KICBYIHkgbGluZXRvCiAgY2xvc2VwYXRoIHN0cm9rZQp9IGRlZgoAc2hvd3BhZ2UKAGZhaWxlZCBhdCBub2RlICVkWzBdCgBucC0+Y2VsbHNbMF0AbWF6ZS5jAGNoa1NncmFwaABmYWlsZWQgYXQgbm9kZSAlZFsxXQoAbnAtPmNlbGxzWzFdAGRpdGVtcwBmaW5kU1ZlcnQAJSUlJVBhZ2U6IDEgMQolJSUlUGFnZUJvdW5kaW5nQm94OiAlZCAlZCAlZCAlZAoAJWYgJWYgdHJhbnNsYXRlCgAwIDAgMSBzZXRyZ2Jjb2xvcgoAJWYgJWYgJWYgJWYgbm9kZQoAMCAwIDAgc2V0cmdiY29sb3IKACVmICVmICVmICVmIGNlbGwKADEgMCAwIHNldHJnYmNvbG9yCgB1bmV4cGVjdGVkIGNhc2UgaW4gbG9jYXRlX2VuZHBvaW50CgAwAHRyYXBlem9pZC5jAGxvY2F0ZV9lbmRwb2ludABhZGRfc2VnbWVudDogZXJyb3IKAG5ld25vZGU6IFF1ZXJ5LXRhYmxlIG92ZXJmbG93CgBuZXdub2RlAG5ld3RyYXA6IFRyYXBlem9pZC10YWJsZSBvdmVyZmxvdyAlZAoAbmV3dHJhcABpbmRleC5jAFJUcmVlU2VhcmNoAG4tPmxldmVsID49IDAAUlRyZWVJbnNlcnQAbGV2ZWwgPj0gMCAmJiBsZXZlbCA8PSAoKm4pLT5sZXZlbAByLT5ib3VuZGFyeVtpXSA8PSByLT5ib3VuZGFyeVtOVU1ESU1TICsgaV0AciAmJiBuICYmIG5ldwBSVHJlZUluc2VydDIAbGV2ZWwgPj0gMCAmJiBsZXZlbCA8PSBuLT5sZXZlbABGQUxTRQBub2RlLmMATm9kZUNvdmVyAHIgJiYgbgBQaWNrQnJhbmNoAEFkZEJyYW5jaABpIDwgTk9ERUNBUkQAbmV3AG4gJiYgaSA+PSAwICYmIGkgPCBOT0RFQ0FSRABEaXNjb25CcmFuY2gAcgByZWN0YW5nbGUuYwBSZWN0QXJlYQByICYmIHJyAENvbWJpbmVSZWN0AHIgJiYgcwBPdmVybGFwAG4Ac3BsaXQucS5jAFNwbGl0Tm9kZQBiAG4tPmNvdW50ICsgKCpubiktPmNvdW50ID09IE5PREVDQVJEICsgMQBMb2FkTm9kZXMAcQBwAHJ0cC0+c3BsaXQuUGFydGl0aW9uc1swXS5wYXJ0aXRpb25baV0gPT0gMCB8fCBydHAtPnNwbGl0LlBhcnRpdGlvbnNbMF0ucGFydGl0aW9uW2ldID09IDEAcnRwLT5zcGxpdC5QYXJ0aXRpb25zWzBdLmNvdW50WzBdICsgcnRwLT5zcGxpdC5QYXJ0aXRpb25zWzBdLmNvdW50WzFdID09IE5PREVDQVJEICsgMQBNZXRob2RaZXJvAHJ0cC0+c3BsaXQuUGFydGl0aW9uc1swXS5jb3VudFswXSA+PSBydHAtPk1pbkZpbGwgJiYgcnRwLT5zcGxpdC5QYXJ0aXRpb25zWzBdLmNvdW50WzFdID49IHJ0cC0+TWluRmlsbAAhcnRwLT5zcGxpdC5QYXJ0aXRpb25zWzBdLnRha2VuW2ldAENsYXNzaWZ5AEdldEJyYW5jaGVzAG4tPmJyYW5jaFtpXS5jaGlsZAAAAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyAhIiMkJSYnKAICAgICAhAMWQEAH1AIAwcSExRXFhcIC2kMHwoFDA4pESsPLRAvMCAyBjQ1GxwdHgsMISIjJCUmJygMGBkXBAobHBogKgohIiMkJSYnKAwKDlMKLFgxWFhYWFhYDBscDy5YMyEiIyQlJicoGxz/U///ISIjJCUmJygM//8F////CRT//////wwbHP8QFRYhIiMkJSYnKBsc/////yEiIyQlJicoDP8SExQRFhf///////8MGxz///8SISIjJCUmJygbHP////8hIiMkJSYnKAz///////8T////////DBsc/////yEiIyQlJicoGxz/////ISIjJCUmJygSExQVFhcYGf///////////yMkJSYnGxITFBYXIjZoAR84ViEgAhsbG14bGzc5cDbSwk8EPCJHIj8iRCIiWCJlIiIFBl9gOQQHCAkKCwwNDgRmZ11qbQUGb1g7cQcICQoLDA0OBHI8W3M+YUYbEhMUFhcEBQY/QWJJBwgJCgsMDQ4FBgBcAAAHCAkKCwwNDgQAAE8AAABTQgAAAAAABAUGAERUVQcICQoLDA0OBQYAAAAABwgJCgsMDQ4EACosLkcxMwAAAAAAAAQFBgAAAEoHCAkKCwwNDgUGAAAAAAcICQoLDA0OBAAAAAAAAEwAAAAAAAAEBQYAAAAABwgJCgsMDQ4FBgAAAAAHCAkKCwwNDikrLS8wMjQ1AAAAAAAAAAAAKSstMDIABC8AJCMAEhQWGhweIBgABQcvLy8ALy8AAAkIKAAAASICBgAAAAAACAAAAAAAAAAAAAAAAAAlAyYTCikVCyoXDi0ZERsMKx0NLB8PIRAAMwAwAC9DADEALwA1LidCMkEAOjgAPDRFADYAQAAAPwBENzs5PQACAwMBAQIBAQEDAwMDAwMDAwEBAQEBAQEBAQEBAQEBAQECAQECAAYBAwMDAwMBAAECAwAEAQIDAAQABAAEAAMCAQIBAgFTeW50YXggZXJyb3I6IG5vbi1zcGFjZSBzdHJpbmcgdXNlZCBiZWZvcmUgPFRBQkxFPgBTeW50YXggZXJyb3I6IG5vbi1zcGFjZSBzdHJpbmcgdXNlZCBhZnRlciA8L1RBQkxFPgAAKSoqKissLC0tLS0tLS0tLS0uLzAxMjM0NTY3ODk6Ozw9Pj4/P0FAQkJCQkJCQ0NERERGRUdHR0lISkhLSExITU1OTk9P/wMPEBEjOiQ9JUAVQyZFJ0gYSxlNGigcTh0eUFFSWVpsa25jZFdpc3ludGF4IGVycm9yAG1lbW9yeSBleGhhdXN0ZWQAJXMgaW4gbGluZSAlZCAKAE5vdCBidWlsdCB3aXRoIGxpYmV4cGF0LiBUYWJsZSBmb3JtYXR0aW5nIGlzIG5vdCBhdmFpbGFibGUuCgByb3V0ZS5jAGxpYnBhdGgvJXM6JWQ6ICVzCgBzaG9ydGVzdC5jAHNvdXJjZSBwb2ludCBub3QgaW4gYW55IHRyaWFuZ2xlAGRlc3RpbmF0aW9uIHBvaW50IG5vdCBpbiBhbnkgdHJpYW5nbGUAY2Fubm90IGZpbmQgdHJpYW5nbGUgcGF0aABjYW5ub3QgbWFsbG9jIG9wcwBjYW5ub3QgcmVhbGxvYyBvcHMAdHJpYW5ndWxhdGlvbiBmYWlsZWQAY2Fubm90IG1hbGxvYyB0cmlzAGNhbm5vdCByZWFsbG9jIHRyaXMAY2Fubm90IG1hbGxvYyBkcS5wbmxzAGNhbm5vdCByZWFsbG9jIGRxLnBubHMAY2Fubm90IG1hbGxvYyBwbmxzAGNhbm5vdCBtYWxsb2MgcG5scHMAY2Fubm90IHJlYWxsb2MgcG5scwBjYW5ub3QgcmVhbGxvYyBwbmxwcwBUISIZDQECAxFLHAwQBAsdEh4naG5vcHFiIAUGDxMUFRoIFgcoJBcYCQoOGx8lI4OCfSYqKzw9Pj9DR0pNWFlaW1xdXl9gYWNkZWZnaWprbHJzdHl6e3wASWxsZWdhbCBieXRlIHNlcXVlbmNlAERvbWFpbiBlcnJvcgBSZXN1bHQgbm90IHJlcHJlc2VudGFibGUATm90IGEgdHR5AFBlcm1pc3Npb24gZGVuaWVkAE9wZXJhdGlvbiBub3QgcGVybWl0dGVkAE5vIHN1Y2ggZmlsZSBvciBkaXJlY3RvcnkATm8gc3VjaCBwcm9jZXNzAEZpbGUgZXhpc3RzAFZhbHVlIHRvbyBsYXJnZSBmb3IgZGF0YSB0eXBlAE5vIHNwYWNlIGxlZnQgb24gZGV2aWNlAE91dCBvZiBtZW1vcnkAUmVzb3VyY2UgYnVzeQBJbnRlcnJ1cHRlZCBzeXN0ZW0gY2FsbABSZXNvdXJjZSB0ZW1wb3JhcmlseSB1bmF2YWlsYWJsZQBJbnZhbGlkIHNlZWsAQ3Jvc3MtZGV2aWNlIGxpbmsAUmVhZC1vbmx5IGZpbGUgc3lzdGVtAERpcmVjdG9yeSBub3QgZW1wdHkAQ29ubmVjdGlvbiByZXNldCBieSBwZWVyAE9wZXJhdGlvbiB0aW1lZCBvdXQAQ29ubmVjdGlvbiByZWZ1c2VkAEhvc3QgaXMgZG93bgBIb3N0IGlzIHVucmVhY2hhYmxlAEFkZHJlc3MgaW4gdXNlAEJyb2tlbiBwaXBlAEkvTyBlcnJvcgBObyBzdWNoIGRldmljZSBvciBhZGRyZXNzAEJsb2NrIGRldmljZSByZXF1aXJlZABObyBzdWNoIGRldmljZQBOb3QgYSBkaXJlY3RvcnkASXMgYSBkaXJlY3RvcnkAVGV4dCBmaWxlIGJ1c3kARXhlYyBmb3JtYXQgZXJyb3IASW52YWxpZCBhcmd1bWVudABBcmd1bWVudCBsaXN0IHRvbyBsb25nAFN5bWJvbGljIGxpbmsgbG9vcABGaWxlbmFtZSB0b28gbG9uZwBUb28gbWFueSBvcGVuIGZpbGVzIGluIHN5c3RlbQBObyBmaWxlIGRlc2NyaXB0b3JzIGF2YWlsYWJsZQBCYWQgZmlsZSBkZXNjcmlwdG9yAE5vIGNoaWxkIHByb2Nlc3MAQmFkIGFkZHJlc3MARmlsZSB0b28gbGFyZ2UAVG9vIG1hbnkgbGlua3MATm8gbG9ja3MgYXZhaWxhYmxlAFJlc291cmNlIGRlYWRsb2NrIHdvdWxkIG9jY3VyAFN0YXRlIG5vdCByZWNvdmVyYWJsZQBQcmV2aW91cyBvd25lciBkaWVkAE9wZXJhdGlvbiBjYW5jZWxlZABGdW5jdGlvbiBub3QgaW1wbGVtZW50ZWQATm8gbWVzc2FnZSBvZiBkZXNpcmVkIHR5cGUASWRlbnRpZmllciByZW1vdmVkAERldmljZSBub3QgYSBzdHJlYW0ATm8gZGF0YSBhdmFpbGFibGUARGV2aWNlIHRpbWVvdXQAT3V0IG9mIHN0cmVhbXMgcmVzb3VyY2VzAExpbmsgaGFzIGJlZW4gc2V2ZXJlZABQcm90b2NvbCBlcnJvcgBCYWQgbWVzc2FnZQBGaWxlIGRlc2NyaXB0b3IgaW4gYmFkIHN0YXRlAE5vdCBhIHNvY2tldABEZXN0aW5hdGlvbiBhZGRyZXNzIHJlcXVpcmVkAE1lc3NhZ2UgdG9vIGxhcmdlAFByb3RvY29sIHdyb25nIHR5cGUgZm9yIHNvY2tldABQcm90b2NvbCBub3QgYXZhaWxhYmxlAFByb3RvY29sIG5vdCBzdXBwb3J0ZWQAU29ja2V0IHR5cGUgbm90IHN1cHBvcnRlZABOb3Qgc3VwcG9ydGVkAFByb3RvY29sIGZhbWlseSBub3Qgc3VwcG9ydGVkAEFkZHJlc3MgZmFtaWx5IG5vdCBzdXBwb3J0ZWQgYnkgcHJvdG9jb2wAQWRkcmVzcyBub3QgYXZhaWxhYmxlAE5ldHdvcmsgaXMgZG93bgBOZXR3b3JrIHVucmVhY2hhYmxlAENvbm5lY3Rpb24gcmVzZXQgYnkgbmV0d29yawBDb25uZWN0aW9uIGFib3J0ZWQATm8gYnVmZmVyIHNwYWNlIGF2YWlsYWJsZQBTb2NrZXQgaXMgY29ubmVjdGVkAFNvY2tldCBub3QgY29ubmVjdGVkAENhbm5vdCBzZW5kIGFmdGVyIHNvY2tldCBzaHV0ZG93bgBPcGVyYXRpb24gYWxyZWFkeSBpbiBwcm9ncmVzcwBPcGVyYXRpb24gaW4gcHJvZ3Jlc3MAU3RhbGUgZmlsZSBoYW5kbGUAUmVtb3RlIEkvTyBlcnJvcgBRdW90YSBleGNlZWRlZABObyBtZWRpdW0gZm91bmQAV3JvbmcgbWVkaXVtIHR5cGUATm8gZXJyb3IgaW5mb3JtYXRpb24AABIQExQVFhcYGRobHB0eHyAhEBAiIxAkJSYnKCkqKxAsLS4RLzARETEREREyMzQ1Njc4OREQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQOhAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQOxA8PT4/QEEQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQQhAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQQxAQRBBFRkcQSBBJEBAQEEpLTE0QEE4QT1AQEBAQURAQEBAQEBAQEBAQEBBSEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBBTEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQVFVWVxAQWFkQEBAQEBAQEBAQEBAQEBAQEBAQEBAQWhBbXF1eX2BhYhAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////////////////////////////////wAAAAD+/wD8AQAA+AEAAHgAAAAA//vf+wAAgAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPAD8/+Cv/////////////9///////yBAsAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAD8AwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD8AAAAAACG/v///wBASQAAAAAAGADf/wDIAAAAAAAAAAEAPAAAAAAAAAAAAAAAABDgAR4AYP+/AAAAAAAA/wcAAAAAAAAAAAAAAAAAAAAAAAAA+M8DAAAAAwAg/38AAABOAAAAAAAAAAAAAAAAAAAAAAD8AAAAAAAAAAAAEAAgHgAwAAEAAAAAAAAAABAAIAAAAAD8DwAAAAAAAAAQACAAAAAAAAAAAAAAAAAAEAAgAAAAAAMAAAAAAAAAABAAIAAAAAD9AAAAAAAAAAAAACAAAAAA/wcAAAAAAAAAAAAgAAAAAAD/AAAAAAAAABAAIAAAAAAAAAAAAAAAAAAAACAAAAAAPwIAAAAAAAAAAAAEAAAAABAAAAAAAACAAIDA3wAMAAAAAAAAAAAAAAAAAB8AAAAAAAD+////APz//wAAAAAAAAAA/AAAAAAAAMD/3/8HAAAAAAAAAAAAAIAGAPwAABg+AACAvwDMAAAAAAAAAAAAAAAIAAAAAAAAAAAAAABg////HwAA/wMAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgAAABAAAYAAAAAAAAAAAAOAAAAAAQAAAAcAAAAAAAAAAAAAAAAAAAADAAAP5/LwAA/wP/fwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOMQAAAAAAAAAAAAAAAAAAAAAAAMT/////AAAAwAAAAAAAAAAAAQDgnwAAAAB/PwAAAAAAAAAAAAAAAAAAAAAQABAAAPz///8fAAAAAAAMAAAAAAAAQAAM8AAAAAAAAMD4AAAAAAAAAMAAAAAAAAAAAP8A////IRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////38AAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKAD4ADgAOAAYID4/////P//////fx/88X//fwAA////AwAA/////wEAewPQwa9CAAwfvP//AAAAAAAC//////////////////////////////////////////////////////////8PAP////9/AAAA/wcAAP////////////8/AAAAAAAA/P///v////////////////////////////////////////////////////8f/wMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADghwP+AAAAAAAAAAAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAD//////3//DwAAAAAAAAAA////+/////////////8PAP//////////////////////////////////PwAAAP8PHv///wH8weAAAAAAAAAAAAAAAB4BAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAD//wAAAAD/////DwAAAP///3////////////////////////////////////9/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////8AAAAAAAAAAAAAAAAAAAAAAAD///////9/AAAAAAAAwADgAAAAAAAAAAAAAACAD3AAAAAAAAAAAAAAAAAAAP8A//9/AAMAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAABECAAAAA//AwAAAAAAAPAAAAAAAAAAAAAQwAAA//8DBwAAAAAA+AAAAAAIgAAAAAAAAAAAAAAIAP8/AMAAAAAAAAAAAAAAAAAAAADwAACACwAAAAAAAACAAgAAwAAAQwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAIAAAAAAAAAAAAAAAAAAAAA/P8DAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAw////A38A//////f/fw8AAAAAAAAAAAAAAAAAAAAAAID+/wD8AQAA+AEAAPg/AAAAAAAAAAAAAAAAAAAAf38AMIf//////4//AAAAAAAA4P//B/8PAAAAAAAA//////8/AAAAAA8AAAAAAAAAAAAAAAAAAIAAAAAAAAABAAAAAAAAAAAAAAAAAAAAgP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAwI8AAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIf/AP8BAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/gAAAP8AAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///38AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAP/z/PwAAAAMAAAAAAAD+AwAAAAAAAAAAAAAAAAAYAA8AAAAAAAAAAAAAAAAAAADhAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAHAAAAAAAAAAAAAAAAAP///////////////////////////////////////z8A/////3/+////////////////////////////PwAAAAD//////////z8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////9/AP//AwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAACAAAAAgAACAAAAAgAACAAAAAgAAAAAIAAAACAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMA//////8P////////////////DwD/f/5//v/+/wAAAAD/B////3//////////D///////BwAAAAAAAAAAwP///wcA//////8H/wEDAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////wEAv///////////H///DwD/////3wcAAP//AQD/////////f/3/////////////////////////////Hv////////8/DwD///8AAAAAAAAAAAAAAAAAAAAAAAD4///////////h/wAAAAAAAP//////////PwAAAAAAAAD//////////////////w8AAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////////////////////////////////8AAQIDBAUGBwgJ/////////woLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIj////////CgsMDQ4PEBESExQVFhcYGRobHB0eHyAhIiP/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAECBAcDBgUAEhETFBUWFxgZGhscHR4fICERIiMkESUmJygpKissES0uLxAQMBAQEBAQEBAxMjMQNDUQEBERERERERERERERERERERERERERERERERE2ERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERNxERERE4ETk6Ozw9PhERERERERERERERERERERERERERERERERERERERERERERERERERERERERE/EBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEUBBEUJDREVGR0hJEBAQSktMTU4QEBBPUBAQEBBREBAQEBAQEBAQERERUlMQEBAQEBAQEBAQEBERERFUEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQERFVEBAQEFYQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQVxAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQWFlaWxAQEBAQEBAQEBAQEBAQEBAQEBAQEBBcEBAQEBAQEBAQEBAQEBAQEBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////////////////////////////////AAAAAAAAAAD+//8H/v//BwAAAAAABCAE//9/////f//////////////////////////////////D/wMAH1AAAAAAAAAAAAAAIAAAAAAA3zxA1///+////////////7///////////////////////wP8/////////////////////////wD+////fwL+/////wAAAAAA/7+2AP///wcHAAAA/wf//////////v/D////////////////7x/+4f+fAAD///////8A4P///////////////wMA//////8HMAT////8/x8AAP///wEAAAAAAAAAAP0fAAAAAAAA8AP/f//////////v/9/h/8///v7un/n///3F459ZgLDP/wMA7of5///9bcOHGQJewP8/AO6/+////e3jvxsBAM//AADun/n///3t458ZwLDP/wIA7Mc91hjH/8PHHYEAwP8AAO7f/f///e/j3x1gA8//AADs3/3///3v498dYEDP/wYA7N/9/////+ffXYAAz/8A/Oz/f/z///svf4Bf/wAADAD+/////3//Bz8g/wMAAAAAliXw/q7s/ztfIP/zAAAAAAEAAAD/AwAA//7///8f/v8D///+////HwAAAAAAAAAA////////f/n/A///58H//39A/zP/////vyD///////f///////////89fz3//////z3/////PX89/3//////////Pf//////////hwAAAAD//wAA/////////////x8A/v//////////////////////////////////////////////////////////n////v//B////////////8cBAP/fDwD//w8A//8PAP/fDQD////////P//8BgBD/AwAAAAD/A///////////////AP//////B///////////PwD///8f/w//AcD/////Px8A//////8P////A/8DAAAAAP///w//////////f/7/HwD/A/8DgAAAAAAAAAAAAAAA////////7//vD/8DAAAAAP//////8////////7//AwD///////8/AP/j//////8/AAAAAAAAAAAAAAAAAN5vAP///////////////////////////////wAAAAAAAAAA//8/P/////8/P/+q////P////////99f3B/PD/8f3B8AAAAAAAAAAAAAAAAAAAKAAAD/HwAAAAAAAAAAAAAAAIT8Lz5Qvf/z4EMAAP//////AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMD///////8DAAD//////3///////3//////////////////////H3gMAP////+/IP////////+AAAD//38Af39/f39/f3//////AAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAA/gM+H/7///////////9/4P7/////////////9+D/////P/7/////////////fwAA////BwAAAAAAAP///////////////////////////////z8AAAAAAAAAAAD/////////////////////////////////HwAAAAAAAP//////////////////////HwAAAAAAAAAA//////8//x////8PAAD//////3/wj////4D/////////////AAAAAID//P///////////////3kPAP8HAAAAAAAAAAAA/7v3////AAAA////////DwD//////////w8A/wMAAPwI//////8H/////wcA////H/////////f/AID/AwAAAAD///////9/AP8//wP//38E/////////38FAAA4//88AH5+fgB/fwAAAAAAAAAAAAAAAAAAAAAAAP//////B/8D//////////////////////////8PAP//f/j//////w//////////////////P/////////////////8DAAAAAH8A+OD//X9f2/////////////////8DAAAA+P///////////////z8AAP///////////P///////wAAAAAA/w8AAAAAAAAAAAAAAAAAAN//////////////////////HwAA/wP+//8H/v//B8D/////////////f/z8/BwAAAAA/+///3///7f/P/8/AAAAAP///////////////////wcAAAAAAAAAAP///////x8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8f////////AQAAAAAA////fwAA////BwAAAAAAAP///z//////D/8+AAAAAAD/////////////////////////P/8DAAAAAAAAAAAAAD/9/////7+R//8/AAAAAAAAAAAAAAAAAAAAAAAAAAAA//8/AP///wMAAAAAAAAAAP/////////AAAAAAAAAAABv8O/+//8PAAAAAAD///8fAAAAAAAAAAAAAAAAAAAAAP///////z8A//8/AP//BwAAAAAAAAAAAAAAAAAAAAAA////////////AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////z8AAADA/wAA/P///////wEAAP///wH/A////////8f/AAAAAAAAAAD//////////x4A/wMAAAAAAAAAAAAAAAAAAAAAAAAAAP///////z8A/wMAAAAAAAD/////////////////fwAAAAAAAAAAAAAAAAAAAAAAAP///////////////wcAAAAAAAAAAAAAAAAAAAAAAAAA//////9/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////HwD//////38AAPj/AAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////3///////////32Te/+vv/////////7/n39////97X/z9//////////////////////////////////////////////////////8//////f//9/////f//9/////f//9/////f/////3////9///3z////////+////+W/vcKhOqWqpb3917/+/8P7vv/DwAAAAAAAAAATENfQUxMAExDX0NUWVBFAAAAAExDX05VTUVSSUMAAExDX1RJTUUAAAAAAExDX0NPTExBVEUAAExDX01PTkVUQVJZAExDX01FU1NBR0VTAExBTkcAQy5VVEYtOABQT1NJWABNVVNMX0xPQ1BBVEgAEQAKABEREQAAAAAFAAAAAAAACQAAAAALAAAAAAAAAAARAA8KERERAwoHAAETCQsLAAAJBgsAAAsABhEAAAAREREAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAEQAKChEREQAKAAACAAkLAAAACQALAAALAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAADAAAAAAJDAAAAAAADAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAANAAAABA0AAAAACQ4AAAAAAA4AAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAADwAAAAAPAAAAAAkQAAAAAAAQAAAQAAASAAAAEhISAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAASEhIAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAAKAAAAAAoAAAAACQsAAAAAAAsAAAsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAMAAAAAAkMAAAAAAAMAAAMAAAtKyAgIDBYMHgAKG51bGwpAC0wWCswWCAwWC0weCsweCAweABpbmYASU5GAE5BTgAwMTIzNDU2Nzg5QUJDREVGLgBhbG51bQBhbHBoYQBibGFuawBjbnRybABkaWdpdABncmFwaABsb3dlcgBwcmludABwdW5jdABzcGFjZQB1cHBlcgB4ZGlnaXQAQy5VVEYtOAAAAAAAAAAAAEMAL3Byb2Mvc2VsZi9mZC8AcndhAGluZmluaXR5AG5hbgAJAAoADQAMAAcAGwBbWzphbG51bTpdX10AW15bOmFsbnVtOl1fXQBbWzpzcGFjZTpdXQBbXls6c3BhY2U6XV0AW1s6ZGlnaXQ6XV0AW15bOmRpZ2l0Ol1dAC90bXAvdG1wZmlsZV9YWFhYWFgAdys=";var tempDoublePtr=STATICTOP;STATICTOP+=16;function ___assert_fail(condition,filename,line,func){abort("Assertion failed: "+Pointer_stringify(condition)+", at: "+[filename?Pointer_stringify(filename):"unknown filename",line,func?Pointer_stringify(func):"unknown function"])}function _emscripten_get_now(){abort()}function _emscripten_get_now_is_monotonic(){return ENVIRONMENT_IS_NODE||typeof dateNow!=="undefined"||(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)&&self["performance"]&&self["performance"]["now"]}var ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:42,EIDRM:43,ECHRNG:44,EL2NSYNC:45,EL3HLT:46,EL3RST:47,ELNRNG:48,EUNATCH:49,ENOCSI:50,EL2HLT:51,EDEADLK:35,ENOLCK:37,EBADE:52,EBADR:53,EXFULL:54,ENOANO:55,EBADRQC:56,EBADSLT:57,EDEADLOCK:35,EBFONT:59,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:72,EDOTDOT:73,EBADMSG:74,ENOTUNIQ:76,EBADFD:77,EREMCHG:78,ELIBACC:79,ELIBBAD:80,ELIBSCN:81,ELIBMAX:82,ELIBEXEC:83,ENOSYS:38,ENOTEMPTY:39,ENAMETOOLONG:36,ELOOP:40,EOPNOTSUPP:95,EPFNOSUPPORT:96,ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:97,EPROTOTYPE:91,ENOTSOCK:88,ENOPROTOOPT:92,ESHUTDOWN:108,ECONNREFUSED:111,EADDRINUSE:98,ECONNABORTED:103,ENETUNREACH:101,ENETDOWN:100,ETIMEDOUT:110,EHOSTDOWN:112,EHOSTUNREACH:113,EINPROGRESS:115,EALREADY:114,EDESTADDRREQ:89,EMSGSIZE:90,EPROTONOSUPPORT:93,ESOCKTNOSUPPORT:94,EADDRNOTAVAIL:99,ENETRESET:102,EISCONN:106,ENOTCONN:107,ETOOMANYREFS:109,EUSERS:87,EDQUOT:122,ESTALE:116,ENOTSUP:95,ENOMEDIUM:123,EILSEQ:84,EOVERFLOW:75,ECANCELED:125,ENOTRECOVERABLE:131,EOWNERDEAD:130,ESTRPIPE:86};function ___setErrNo(value){if(Module["___errno_location"])HEAP32[Module["___errno_location"]()>>2]=value;return value}function _clock_gettime(clk_id,tp){var now;if(clk_id===0){now=Date.now()}else if(clk_id===1&&_emscripten_get_now_is_monotonic()){now=_emscripten_get_now()}else{___setErrNo(ERRNO_CODES.EINVAL);return-1}HEAP32[tp>>2]=now/1e3|0;HEAP32[tp+4>>2]=now%1e3*1e3*1e3|0;return 0}function ___clock_gettime(){return _clock_gettime.apply(null,arguments)}function ___lock(){}function ___map_file(pathname,size){___setErrNo(ERRNO_CODES.EPERM);return-1}var ERRNO_MESSAGES={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"File locking deadlock error",36:"File or path name too long",37:"No record locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many symbolic links",42:"No message of desired type",43:"Identifier removed",44:"Channel number out of range",45:"Level 2 not synchronized",46:"Level 3 halted",47:"Level 3 reset",48:"Link number out of range",49:"Protocol driver not attached",50:"No CSI structure available",51:"Level 2 halted",52:"Invalid exchange",53:"Invalid request descriptor",54:"Exchange full",55:"No anode",56:"Invalid request code",57:"Invalid slot",59:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network",65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",72:"Multihop attempted",73:"Cross mount point (not really error)",74:"Trying to read unreadable message",75:"Value too large for defined data type",76:"Given log. name not unique",77:"f.d. invalid for this operation",78:"Remote address changed",79:"Can access a needed shared lib",80:"Accessing a corrupted shared lib",81:".lib section in a.out corrupted",82:"Attempting to link in too many libs",83:"Attempting to exec a shared library",84:"Illegal byte sequence",86:"Streams pipe error",87:"Too many users",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Unknown protocol",94:"Socket type not supported",95:"Not supported",96:"Protocol family not supported",97:"Address family not supported by protocol family",98:"Address already in use",99:"Address not available",100:"Network interface is not configured",101:"Network is unreachable",102:"Connection reset by network",103:"Connection aborted",104:"Connection reset by peer",105:"No buffer space available",106:"Socket is already connected",107:"Socket is not connected",108:"Can't send after socket shutdown",109:"Too many references",110:"Connection timed out",111:"Connection refused",112:"Host is down",113:"Host is unreachable",114:"Socket already connected",115:"Connection already in progress",116:"Stale file handle",122:"Quota exceeded",123:"No medium (in tape drive)",125:"Operation canceled",130:"Previous owner died",131:"State not recoverable"};var PATH={splitPath:(function(filename){var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return splitPathRe.exec(filename).slice(1)}),normalizeArray:(function(parts,allowAboveRoot){var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last==="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up;up--){parts.unshift("..")}}return parts}),normalize:(function(path){var isAbsolute=path.charAt(0)==="/",trailingSlash=path.substr(-1)==="/";path=PATH.normalizeArray(path.split("/").filter((function(p){return!!p})),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path}),dirname:(function(path){var result=PATH.splitPath(path),root=result[0],dir=result[1];if(!root&&!dir){return"."}if(dir){dir=dir.substr(0,dir.length-1)}return root+dir}),basename:(function(path){if(path==="/")return"/";var lastSlash=path.lastIndexOf("/");if(lastSlash===-1)return path;return path.substr(lastSlash+1)}),extname:(function(path){return PATH.splitPath(path)[3]}),join:(function(){var paths=Array.prototype.slice.call(arguments,0);return PATH.normalize(paths.join("/"))}),join2:(function(l,r){return PATH.normalize(l+"/"+r)}),resolve:(function(){var resolvedPath="",resolvedAbsolute=false;for(var i=arguments.length-1;i>=-1&&!resolvedAbsolute;i--){var path=i>=0?arguments[i]:FS.cwd();if(typeof path!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!path){return""}resolvedPath=path+"/"+resolvedPath;resolvedAbsolute=path.charAt(0)==="/"}resolvedPath=PATH.normalizeArray(resolvedPath.split("/").filter((function(p){return!!p})),!resolvedAbsolute).join("/");return(resolvedAbsolute?"/":"")+resolvedPath||"."}),relative:(function(from,to){from=PATH.resolve(from).substr(1);to=PATH.resolve(to).substr(1);function trim(arr){var start=0;for(;start=0;end--){if(arr[end]!=="")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split("/"));var toParts=trim(to.split("/"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;i0){result=buf.slice(0,bytesRead).toString("utf-8")}else{result=null}}else if(typeof window!="undefined"&&typeof window.prompt=="function"){result=window.prompt("Input: ");if(result!==null){result+="\n"}}else if(typeof readline=="function"){result=readline();if(result!==null){result+="\n"}}if(!result){return null}tty.input=intArrayFromString(result,true)}return tty.input.shift()}),put_char:(function(tty,val){if(val===null||val===10){Module["print"](UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}}),flush:(function(tty){if(tty.output&&tty.output.length>0){Module["print"](UTF8ArrayToString(tty.output,0));tty.output=[]}})},default_tty1_ops:{put_char:(function(tty,val){if(val===null||val===10){Module["printErr"](UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}}),flush:(function(tty){if(tty.output&&tty.output.length>0){Module["printErr"](UTF8ArrayToString(tty.output,0));tty.output=[]}})}};var MEMFS={ops_table:null,mount:(function(mount){return MEMFS.createNode(null,"/",16384|511,0)}),createNode:(function(parent,name,mode,dev){if(FS.isBlkdev(mode)||FS.isFIFO(mode)){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}if(!MEMFS.ops_table){MEMFS.ops_table={dir:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,lookup:MEMFS.node_ops.lookup,mknod:MEMFS.node_ops.mknod,rename:MEMFS.node_ops.rename,unlink:MEMFS.node_ops.unlink,rmdir:MEMFS.node_ops.rmdir,readdir:MEMFS.node_ops.readdir,symlink:MEMFS.node_ops.symlink},stream:{llseek:MEMFS.stream_ops.llseek}},file:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:{llseek:MEMFS.stream_ops.llseek,read:MEMFS.stream_ops.read,write:MEMFS.stream_ops.write,allocate:MEMFS.stream_ops.allocate,mmap:MEMFS.stream_ops.mmap,msync:MEMFS.stream_ops.msync}},link:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,readlink:MEMFS.node_ops.readlink},stream:{}},chrdev:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:FS.chrdev_stream_ops}}}var node=FS.createNode(parent,name,mode,dev);if(FS.isDir(node.mode)){node.node_ops=MEMFS.ops_table.dir.node;node.stream_ops=MEMFS.ops_table.dir.stream;node.contents={}}else if(FS.isFile(node.mode)){node.node_ops=MEMFS.ops_table.file.node;node.stream_ops=MEMFS.ops_table.file.stream;node.usedBytes=0;node.contents=null}else if(FS.isLink(node.mode)){node.node_ops=MEMFS.ops_table.link.node;node.stream_ops=MEMFS.ops_table.link.stream}else if(FS.isChrdev(node.mode)){node.node_ops=MEMFS.ops_table.chrdev.node;node.stream_ops=MEMFS.ops_table.chrdev.stream}node.timestamp=Date.now();if(parent){parent.contents[name]=node}return node}),getFileDataAsRegularArray:(function(node){if(node.contents&&node.contents.subarray){var arr=[];for(var i=0;inode.contents.length){node.contents=MEMFS.getFileDataAsRegularArray(node);node.usedBytes=node.contents.length}if(!node.contents||node.contents.subarray){var prevCapacity=node.contents?node.contents.length:0;if(prevCapacity>=newCapacity)return;var CAPACITY_DOUBLING_MAX=1024*1024;newCapacity=Math.max(newCapacity,prevCapacity*(prevCapacity0)node.contents.set(oldContents.subarray(0,node.usedBytes),0);return}if(!node.contents&&newCapacity>0)node.contents=[];while(node.contents.lengthnewSize)node.contents.length=newSize;else while(node.contents.length=stream.node.usedBytes)return 0;var size=Math.min(stream.node.usedBytes-position,length);assert(size>=0);if(size>8&&contents.subarray){buffer.set(contents.subarray(position,position+size),offset)}else{for(var i=0;i0||position+lengthe2.timestamp){create.push(key);total++}}));var remove=[];Object.keys(dst.entries).forEach((function(key){var e=dst.entries[key];var e2=src.entries[key];if(!e2){remove.push(key);total++}}));if(!total){return callback(null)}var completed=0;var db=src.type==="remote"?src.db:dst.db;var transaction=db.transaction([IDBFS.DB_STORE_NAME],"readwrite");var store=transaction.objectStore(IDBFS.DB_STORE_NAME);function done(err){if(err){if(!done.errored){done.errored=true;return callback(err)}return}if(++completed>=total){return callback(null)}}transaction.onerror=(function(e){done(this.error);e.preventDefault()});create.sort().forEach((function(path){if(dst.type==="local"){IDBFS.loadRemoteEntry(store,path,(function(err,entry){if(err)return done(err);IDBFS.storeLocalEntry(path,entry,done)}))}else{IDBFS.loadLocalEntry(path,(function(err,entry){if(err)return done(err);IDBFS.storeRemoteEntry(store,path,entry,done)}))}}));remove.sort().reverse().forEach((function(path){if(dst.type==="local"){IDBFS.removeLocalEntry(path,done)}else{IDBFS.removeRemoteEntry(store,path,done)}}))})};var NODEFS={isWindows:false,staticInit:(function(){NODEFS.isWindows=!!process.platform.match(/^win/);var flags=process["binding"]("constants");if(flags["fs"]){flags=flags["fs"]}NODEFS.flagsForNodeMap={"1024":flags["O_APPEND"],"64":flags["O_CREAT"],"128":flags["O_EXCL"],"0":flags["O_RDONLY"],"2":flags["O_RDWR"],"4096":flags["O_SYNC"],"512":flags["O_TRUNC"],"1":flags["O_WRONLY"]}}),bufferFrom:(function(arrayBuffer){return Buffer.alloc?Buffer.from(arrayBuffer):new Buffer(arrayBuffer)}),mount:(function(mount){assert(ENVIRONMENT_IS_NODE);return NODEFS.createNode(null,"/",NODEFS.getMode(mount.opts.root),0)}),createNode:(function(parent,name,mode,dev){if(!FS.isDir(mode)&&!FS.isFile(mode)&&!FS.isLink(mode)){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}var node=FS.createNode(parent,name,mode);node.node_ops=NODEFS.node_ops;node.stream_ops=NODEFS.stream_ops;return node}),getMode:(function(path){var stat;try{stat=fs.lstatSync(path);if(NODEFS.isWindows){stat.mode=stat.mode|(stat.mode&292)>>2}}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}return stat.mode}),realPath:(function(node){var parts=[];while(node.parent!==node){parts.push(node.name);node=node.parent}parts.push(node.mount.opts.root);parts.reverse();return PATH.join.apply(null,parts)}),flagsForNode:(function(flags){flags&=~2097152;flags&=~2048;flags&=~32768;flags&=~524288;var newFlags=0;for(var k in NODEFS.flagsForNodeMap){if(flags&k){newFlags|=NODEFS.flagsForNodeMap[k];flags^=k}}if(!flags){return newFlags}else{throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}}),node_ops:{getattr:(function(node){var path=NODEFS.realPath(node);var stat;try{stat=fs.lstatSync(path)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}if(NODEFS.isWindows&&!stat.blksize){stat.blksize=4096}if(NODEFS.isWindows&&!stat.blocks){stat.blocks=(stat.size+stat.blksize-1)/stat.blksize|0}return{dev:stat.dev,ino:stat.ino,mode:stat.mode,nlink:stat.nlink,uid:stat.uid,gid:stat.gid,rdev:stat.rdev,size:stat.size,atime:stat.atime,mtime:stat.mtime,ctime:stat.ctime,blksize:stat.blksize,blocks:stat.blocks}}),setattr:(function(node,attr){var path=NODEFS.realPath(node);try{if(attr.mode!==undefined){fs.chmodSync(path,attr.mode);node.mode=attr.mode}if(attr.timestamp!==undefined){var date=new Date(attr.timestamp);fs.utimesSync(path,date,date)}if(attr.size!==undefined){fs.truncateSync(path,attr.size)}}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),lookup:(function(parent,name){var path=PATH.join2(NODEFS.realPath(parent),name);var mode=NODEFS.getMode(path);return NODEFS.createNode(parent,name,mode)}),mknod:(function(parent,name,mode,dev){var node=NODEFS.createNode(parent,name,mode,dev);var path=NODEFS.realPath(node);try{if(FS.isDir(node.mode)){fs.mkdirSync(path,node.mode)}else{fs.writeFileSync(path,"",{mode:node.mode})}}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}return node}),rename:(function(oldNode,newDir,newName){var oldPath=NODEFS.realPath(oldNode);var newPath=PATH.join2(NODEFS.realPath(newDir),newName);try{fs.renameSync(oldPath,newPath)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),unlink:(function(parent,name){var path=PATH.join2(NODEFS.realPath(parent),name);try{fs.unlinkSync(path)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),rmdir:(function(parent,name){var path=PATH.join2(NODEFS.realPath(parent),name);try{fs.rmdirSync(path)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),readdir:(function(node){var path=NODEFS.realPath(node);try{return fs.readdirSync(path)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),symlink:(function(parent,newName,oldPath){var newPath=PATH.join2(NODEFS.realPath(parent),newName);try{fs.symlinkSync(oldPath,newPath)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),readlink:(function(node){var path=NODEFS.realPath(node);try{path=fs.readlinkSync(path);path=NODEJS_PATH.relative(NODEJS_PATH.resolve(node.mount.opts.root),path);return path}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}})},stream_ops:{open:(function(stream){var path=NODEFS.realPath(stream.node);try{if(FS.isFile(stream.node.mode)){stream.nfd=fs.openSync(path,NODEFS.flagsForNode(stream.flags))}}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),close:(function(stream){try{if(FS.isFile(stream.node.mode)&&stream.nfd){fs.closeSync(stream.nfd)}}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),read:(function(stream,buffer,offset,length,position){if(length===0)return 0;try{return fs.readSync(stream.nfd,NODEFS.bufferFrom(buffer.buffer),offset,length,position)}catch(e){throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),write:(function(stream,buffer,offset,length,position){try{return fs.writeSync(stream.nfd,NODEFS.bufferFrom(buffer.buffer),offset,length,position)}catch(e){throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),llseek:(function(stream,offset,whence){var position=offset;if(whence===1){position+=stream.position}else if(whence===2){if(FS.isFile(stream.node.mode)){try{var stat=fs.fstatSync(stream.nfd);position+=stat.size}catch(e){throw new FS.ErrnoError(ERRNO_CODES[e.code])}}}if(position<0){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}return position})}};var WORKERFS={DIR_MODE:16895,FILE_MODE:33279,reader:null,mount:(function(mount){assert(ENVIRONMENT_IS_WORKER);if(!WORKERFS.reader)WORKERFS.reader=new FileReaderSync;var root=WORKERFS.createNode(null,"/",WORKERFS.DIR_MODE,0);var createdParents={};function ensureParent(path){var parts=path.split("/");var parent=root;for(var i=0;i=stream.node.size)return 0;var chunk=stream.node.contents.slice(position,position+length);var ab=WORKERFS.reader.readAsArrayBuffer(chunk);buffer.set(new Uint8Array(ab),offset);return chunk.size}),write:(function(stream,buffer,offset,length,position){throw new FS.ErrnoError(ERRNO_CODES.EIO)}),llseek:(function(stream,offset,whence){var position=offset;if(whence===1){position+=stream.position}else if(whence===2){if(FS.isFile(stream.node.mode)){position+=stream.node.size}}if(position<0){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}return position})}};STATICTOP+=16;STATICTOP+=16;STATICTOP+=16;var FS={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,trackingDelegate:{},tracking:{openFlags:{READ:1,WRITE:2}},ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,handleFSError:(function(e){if(!(e instanceof FS.ErrnoError))throw e+" : "+stackTrace();return ___setErrNo(e.errno)}),lookupPath:(function(path,opts){path=PATH.resolve(FS.cwd(),path);opts=opts||{};if(!path)return{path:"",node:null};var defaults={follow_mount:true,recurse_count:0};for(var key in defaults){if(opts[key]===undefined){opts[key]=defaults[key]}}if(opts.recurse_count>8){throw new FS.ErrnoError(ERRNO_CODES.ELOOP)}var parts=PATH.normalizeArray(path.split("/").filter((function(p){return!!p})),false);var current=FS.root;var current_path="/";for(var i=0;i40){throw new FS.ErrnoError(ERRNO_CODES.ELOOP)}}}}return{path:current_path,node:current}}),getPath:(function(node){var path;while(true){if(FS.isRoot(node)){var mount=node.mount.mountpoint;if(!path)return mount;return mount[mount.length-1]!=="/"?mount+"/"+path:mount+path}path=path?node.name+"/"+path:node.name;node=node.parent}}),hashName:(function(parentid,name){var hash=0;for(var i=0;i>>0)%FS.nameTable.length}),hashAddNode:(function(node){var hash=FS.hashName(node.parent.id,node.name);node.name_next=FS.nameTable[hash];FS.nameTable[hash]=node}),hashRemoveNode:(function(node){var hash=FS.hashName(node.parent.id,node.name);if(FS.nameTable[hash]===node){FS.nameTable[hash]=node.name_next}else{var current=FS.nameTable[hash];while(current){if(current.name_next===node){current.name_next=node.name_next;break}current=current.name_next}}}),lookupNode:(function(parent,name){var err=FS.mayLookup(parent);if(err){throw new FS.ErrnoError(err,parent)}var hash=FS.hashName(parent.id,name);for(var node=FS.nameTable[hash];node;node=node.name_next){var nodeName=node.name;if(node.parent.id===parent.id&&nodeName===name){return node}}return FS.lookup(parent,name)}),createNode:(function(parent,name,mode,rdev){if(!FS.FSNode){FS.FSNode=(function(parent,name,mode,rdev){if(!parent){parent=this}this.parent=parent;this.mount=parent.mount;this.mounted=null;this.id=FS.nextInode++;this.name=name;this.mode=mode;this.node_ops={};this.stream_ops={};this.rdev=rdev});FS.FSNode.prototype={};var readMode=292|73;var writeMode=146;Object.defineProperties(FS.FSNode.prototype,{read:{get:(function(){return(this.mode&readMode)===readMode}),set:(function(val){val?this.mode|=readMode:this.mode&=~readMode})},write:{get:(function(){return(this.mode&writeMode)===writeMode}),set:(function(val){val?this.mode|=writeMode:this.mode&=~writeMode})},isFolder:{get:(function(){return FS.isDir(this.mode)})},isDevice:{get:(function(){return FS.isChrdev(this.mode)})}})}var node=new FS.FSNode(parent,name,mode,rdev);FS.hashAddNode(node);return node}),destroyNode:(function(node){FS.hashRemoveNode(node)}),isRoot:(function(node){return node===node.parent}),isMountpoint:(function(node){return!!node.mounted}),isFile:(function(mode){return(mode&61440)===32768}),isDir:(function(mode){return(mode&61440)===16384}),isLink:(function(mode){return(mode&61440)===40960}),isChrdev:(function(mode){return(mode&61440)===8192}),isBlkdev:(function(mode){return(mode&61440)===24576}),isFIFO:(function(mode){return(mode&61440)===4096}),isSocket:(function(mode){return(mode&49152)===49152}),flagModes:{"r":0,"rs":1052672,"r+":2,"w":577,"wx":705,"xw":705,"w+":578,"wx+":706,"xw+":706,"a":1089,"ax":1217,"xa":1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:(function(str){var flags=FS.flagModes[str];if(typeof flags==="undefined"){throw new Error("Unknown file open mode: "+str)}return flags}),flagsToPermissionString:(function(flag){var perms=["r","w","rw"][flag&3];if(flag&512){perms+="w"}return perms}),nodePermissions:(function(node,perms){if(FS.ignorePermissions){return 0}if(perms.indexOf("r")!==-1&&!(node.mode&292)){return ERRNO_CODES.EACCES}else if(perms.indexOf("w")!==-1&&!(node.mode&146)){return ERRNO_CODES.EACCES}else if(perms.indexOf("x")!==-1&&!(node.mode&73)){return ERRNO_CODES.EACCES}return 0}),mayLookup:(function(dir){var err=FS.nodePermissions(dir,"x");if(err)return err;if(!dir.node_ops.lookup)return ERRNO_CODES.EACCES;return 0}),mayCreate:(function(dir,name){try{var node=FS.lookupNode(dir,name);return ERRNO_CODES.EEXIST}catch(e){}return FS.nodePermissions(dir,"wx")}),mayDelete:(function(dir,name,isdir){var node;try{node=FS.lookupNode(dir,name)}catch(e){return e.errno}var err=FS.nodePermissions(dir,"wx");if(err){return err}if(isdir){if(!FS.isDir(node.mode)){return ERRNO_CODES.ENOTDIR}if(FS.isRoot(node)||FS.getPath(node)===FS.cwd()){return ERRNO_CODES.EBUSY}}else{if(FS.isDir(node.mode)){return ERRNO_CODES.EISDIR}}return 0}),mayOpen:(function(node,flags){if(!node){return ERRNO_CODES.ENOENT}if(FS.isLink(node.mode)){return ERRNO_CODES.ELOOP}else if(FS.isDir(node.mode)){if(FS.flagsToPermissionString(flags)!=="r"||flags&512){return ERRNO_CODES.EISDIR}}return FS.nodePermissions(node,FS.flagsToPermissionString(flags))}),MAX_OPEN_FDS:4096,nextfd:(function(fd_start,fd_end){fd_start=fd_start||0;fd_end=fd_end||FS.MAX_OPEN_FDS;for(var fd=fd_start;fd<=fd_end;fd++){if(!FS.streams[fd]){return fd}}throw new FS.ErrnoError(ERRNO_CODES.EMFILE)}),getStream:(function(fd){return FS.streams[fd]}),createStream:(function(stream,fd_start,fd_end){if(!FS.FSStream){FS.FSStream=(function(){});FS.FSStream.prototype={};Object.defineProperties(FS.FSStream.prototype,{object:{get:(function(){return this.node}),set:(function(val){this.node=val})},isRead:{get:(function(){return(this.flags&2097155)!==1})},isWrite:{get:(function(){return(this.flags&2097155)!==0})},isAppend:{get:(function(){return this.flags&1024})}})}var newStream=new FS.FSStream;for(var p in stream){newStream[p]=stream[p]}stream=newStream;var fd=FS.nextfd(fd_start,fd_end);stream.fd=fd;FS.streams[fd]=stream;return stream}),closeStream:(function(fd){FS.streams[fd]=null}),chrdev_stream_ops:{open:(function(stream){var device=FS.getDevice(stream.node.rdev);stream.stream_ops=device.stream_ops;if(stream.stream_ops.open){stream.stream_ops.open(stream)}}),llseek:(function(){throw new FS.ErrnoError(ERRNO_CODES.ESPIPE)})},major:(function(dev){return dev>>8}),minor:(function(dev){return dev&255}),makedev:(function(ma,mi){return ma<<8|mi}),registerDevice:(function(dev,ops){FS.devices[dev]={stream_ops:ops}}),getDevice:(function(dev){return FS.devices[dev]}),getMounts:(function(mount){var mounts=[];var check=[mount];while(check.length){var m=check.pop();mounts.push(m);check.push.apply(check,m.mounts)}return mounts}),syncfs:(function(populate,callback){if(typeof populate==="function"){callback=populate;populate=false}FS.syncFSRequests++;if(FS.syncFSRequests>1){console.log("warning: "+FS.syncFSRequests+" FS.syncfs operations in flight at once, probably just doing extra work")}var mounts=FS.getMounts(FS.root.mount);var completed=0;function doCallback(err){assert(FS.syncFSRequests>0);FS.syncFSRequests--;return callback(err)}function done(err){if(err){if(!done.errored){done.errored=true;return doCallback(err)}return}if(++completed>=mounts.length){doCallback(null)}}mounts.forEach((function(mount){if(!mount.type.syncfs){return done(null)}mount.type.syncfs(mount,populate,done)}))}),mount:(function(type,opts,mountpoint){var root=mountpoint==="/";var pseudo=!mountpoint;var node;if(root&&FS.root){throw new FS.ErrnoError(ERRNO_CODES.EBUSY)}else if(!root&&!pseudo){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});mountpoint=lookup.path;node=lookup.node;if(FS.isMountpoint(node)){throw new FS.ErrnoError(ERRNO_CODES.EBUSY)}if(!FS.isDir(node.mode)){throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR)}}var mount={type:type,opts:opts,mountpoint:mountpoint,mounts:[]};var mountRoot=type.mount(mount);mountRoot.mount=mount;mount.root=mountRoot;if(root){FS.root=mountRoot}else if(node){node.mounted=mount;if(node.mount){node.mount.mounts.push(mount)}}return mountRoot}),unmount:(function(mountpoint){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});if(!FS.isMountpoint(lookup.node)){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}var node=lookup.node;var mount=node.mounted;var mounts=FS.getMounts(mount);Object.keys(FS.nameTable).forEach((function(hash){var current=FS.nameTable[hash];while(current){var next=current.name_next;if(mounts.indexOf(current.mount)!==-1){FS.destroyNode(current)}current=next}}));node.mounted=null;var idx=node.mount.mounts.indexOf(mount);assert(idx!==-1);node.mount.mounts.splice(idx,1)}),lookup:(function(parent,name){return parent.node_ops.lookup(parent,name)}),mknod:(function(path,mode,dev){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);if(!name||name==="."||name===".."){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}var err=FS.mayCreate(parent,name);if(err){throw new FS.ErrnoError(err)}if(!parent.node_ops.mknod){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}return parent.node_ops.mknod(parent,name,mode,dev)}),create:(function(path,mode){mode=mode!==undefined?mode:438;mode&=4095;mode|=32768;return FS.mknod(path,mode,0)}),mkdir:(function(path,mode){mode=mode!==undefined?mode:511;mode&=511|512;mode|=16384;return FS.mknod(path,mode,0)}),mkdirTree:(function(path,mode){var dirs=path.split("/");var d="";for(var i=0;ithis.length-1||idx<0){return undefined}var chunkOffset=idx%this.chunkSize;var chunkNum=idx/this.chunkSize|0;return this.getter(chunkNum)[chunkOffset]};LazyUint8Array.prototype.setDataGetter=function LazyUint8Array_setDataGetter(getter){this.getter=getter};LazyUint8Array.prototype.cacheLength=function LazyUint8Array_cacheLength(){var xhr=new XMLHttpRequest;xhr.open("HEAD",url,false);xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error("Couldn't load "+url+". Status: "+xhr.status);var datalength=Number(xhr.getResponseHeader("Content-length"));var header;var hasByteServing=(header=xhr.getResponseHeader("Accept-Ranges"))&&header==="bytes";var usesGzip=(header=xhr.getResponseHeader("Content-Encoding"))&&header==="gzip";var chunkSize=1024*1024;if(!hasByteServing)chunkSize=datalength;var doXHR=(function(from,to){if(from>to)throw new Error("invalid range ("+from+", "+to+") or no bytes requested!");if(to>datalength-1)throw new Error("only "+datalength+" bytes available! programmer error!");var xhr=new XMLHttpRequest;xhr.open("GET",url,false);if(datalength!==chunkSize)xhr.setRequestHeader("Range","bytes="+from+"-"+to);if(typeof Uint8Array!="undefined")xhr.responseType="arraybuffer";if(xhr.overrideMimeType){xhr.overrideMimeType("text/plain; charset=x-user-defined")}xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error("Couldn't load "+url+". Status: "+xhr.status);if(xhr.response!==undefined){return new Uint8Array(xhr.response||[])}else{return intArrayFromString(xhr.responseText||"",true)}});var lazyArray=this;lazyArray.setDataGetter((function(chunkNum){var start=chunkNum*chunkSize;var end=(chunkNum+1)*chunkSize-1;end=Math.min(end,datalength-1);if(typeof lazyArray.chunks[chunkNum]==="undefined"){lazyArray.chunks[chunkNum]=doXHR(start,end)}if(typeof lazyArray.chunks[chunkNum]==="undefined")throw new Error("doXHR failed!");return lazyArray.chunks[chunkNum]}));if(usesGzip||!datalength){chunkSize=datalength=1;datalength=this.getter(0).length;chunkSize=datalength;console.log("LazyFiles on gzip forces download of the whole file when length is accessed")}this._length=datalength;this._chunkSize=chunkSize;this.lengthKnown=true};if(typeof XMLHttpRequest!=="undefined"){if(!ENVIRONMENT_IS_WORKER)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var lazyArray=new LazyUint8Array;Object.defineProperties(lazyArray,{length:{get:(function(){if(!this.lengthKnown){this.cacheLength()}return this._length})},chunkSize:{get:(function(){if(!this.lengthKnown){this.cacheLength()}return this._chunkSize})}});var properties={isDevice:false,contents:lazyArray}}else{var properties={isDevice:false,url:url}}var node=FS.createFile(parent,name,properties,canRead,canWrite);if(properties.contents){node.contents=properties.contents}else if(properties.url){node.contents=null;node.url=properties.url}Object.defineProperties(node,{usedBytes:{get:(function(){return this.contents.length})}});var stream_ops={};var keys=Object.keys(node.stream_ops);keys.forEach((function(key){var fn=node.stream_ops[key];stream_ops[key]=function forceLoadLazyFile(){if(!FS.forceLoadFile(node)){throw new FS.ErrnoError(ERRNO_CODES.EIO)}return fn.apply(null,arguments)}}));stream_ops.read=function stream_ops_read(stream,buffer,offset,length,position){if(!FS.forceLoadFile(node)){throw new FS.ErrnoError(ERRNO_CODES.EIO)}var contents=stream.node.contents;if(position>=contents.length)return 0;var size=Math.min(contents.length-position,length);assert(size>=0);if(contents.slice){for(var i=0;i>2]=stat.dev;HEAP32[buf+4>>2]=0;HEAP32[buf+8>>2]=stat.ino;HEAP32[buf+12>>2]=stat.mode;HEAP32[buf+16>>2]=stat.nlink;HEAP32[buf+20>>2]=stat.uid;HEAP32[buf+24>>2]=stat.gid;HEAP32[buf+28>>2]=stat.rdev;HEAP32[buf+32>>2]=0;HEAP32[buf+36>>2]=stat.size;HEAP32[buf+40>>2]=4096;HEAP32[buf+44>>2]=stat.blocks;HEAP32[buf+48>>2]=stat.atime.getTime()/1e3|0;HEAP32[buf+52>>2]=0;HEAP32[buf+56>>2]=stat.mtime.getTime()/1e3|0;HEAP32[buf+60>>2]=0;HEAP32[buf+64>>2]=stat.ctime.getTime()/1e3|0;HEAP32[buf+68>>2]=0;HEAP32[buf+72>>2]=stat.ino;return 0}),doMsync:(function(addr,stream,len,flags){var buffer=new Uint8Array(HEAPU8.subarray(addr,addr+len));FS.msync(stream,buffer,0,len,flags)}),doMkdir:(function(path,mode){path=PATH.normalize(path);if(path[path.length-1]==="/")path=path.substr(0,path.length-1);FS.mkdir(path,mode,0);return 0}),doMknod:(function(path,mode,dev){switch(mode&61440){case 32768:case 8192:case 24576:case 4096:case 49152:break;default:return-ERRNO_CODES.EINVAL}FS.mknod(path,mode,dev);return 0}),doReadlink:(function(path,buf,bufsize){if(bufsize<=0)return-ERRNO_CODES.EINVAL;var ret=FS.readlink(path);var len=Math.min(bufsize,lengthBytesUTF8(ret));var endChar=HEAP8[buf+len];stringToUTF8(ret,buf,bufsize+1);HEAP8[buf+len]=endChar;return len}),doAccess:(function(path,amode){if(amode&~7){return-ERRNO_CODES.EINVAL}var node;var lookup=FS.lookupPath(path,{follow:true});node=lookup.node;var perms="";if(amode&4)perms+="r";if(amode&2)perms+="w";if(amode&1)perms+="x";if(perms&&FS.nodePermissions(node,perms)){return-ERRNO_CODES.EACCES}return 0}),doDup:(function(path,flags,suggestFD){var suggest=FS.getStream(suggestFD);if(suggest)FS.close(suggest);return FS.open(path,flags,0,suggestFD,suggestFD).fd}),doReadv:(function(stream,iov,iovcnt,offset){var ret=0;for(var i=0;i>2];var len=HEAP32[iov+(i*8+4)>>2];var curr=FS.read(stream,HEAP8,ptr,len,offset);if(curr<0)return-1;ret+=curr;if(curr>2];var len=HEAP32[iov+(i*8+4)>>2];var curr=FS.write(stream,HEAP8,ptr,len,offset);if(curr<0)return-1;ret+=curr}return ret}),varargs:0,get:(function(varargs){SYSCALLS.varargs+=4;var ret=HEAP32[SYSCALLS.varargs-4>>2];return ret}),getStr:(function(){var ret=Pointer_stringify(SYSCALLS.get());return ret}),getStreamFromFD:(function(){var stream=FS.getStream(SYSCALLS.get());if(!stream)throw new FS.ErrnoError(ERRNO_CODES.EBADF);return stream}),getSocketFromFD:(function(){var socket=SOCKFS.getSocket(SYSCALLS.get());if(!socket)throw new FS.ErrnoError(ERRNO_CODES.EBADF);return socket}),getSocketAddress:(function(allowNull){var addrp=SYSCALLS.get(),addrlen=SYSCALLS.get();if(allowNull&&addrp===0)return null;var info=__read_sockaddr(addrp,addrlen);if(info.errno)throw new FS.ErrnoError(info.errno);info.addr=DNS.lookup_addr(info.addr)||info.addr;return info}),get64:(function(){var low=SYSCALLS.get(),high=SYSCALLS.get();if(low>=0)assert(high===0);else assert(high===-1);return low}),getZero:(function(){assert(SYSCALLS.get()===0)})};function ___syscall10(which,varargs){SYSCALLS.varargs=varargs;try{var path=SYSCALLS.getStr();FS.unlink(path);return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___syscall140(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(),offset_high=SYSCALLS.get(),offset_low=SYSCALLS.get(),result=SYSCALLS.get(),whence=SYSCALLS.get();var offset=offset_low;FS.llseek(stream,offset,whence);HEAP32[result>>2]=stream.position;if(stream.getdents&&offset===0&&whence===0)stream.getdents=null;return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___syscall145(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(),iov=SYSCALLS.get(),iovcnt=SYSCALLS.get();return SYSCALLS.doReadv(stream,iov,iovcnt)}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___syscall146(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(),iov=SYSCALLS.get(),iovcnt=SYSCALLS.get();return SYSCALLS.doWritev(stream,iov,iovcnt)}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___syscall192(which,varargs){SYSCALLS.varargs=varargs;try{var addr=SYSCALLS.get(),len=SYSCALLS.get(),prot=SYSCALLS.get(),flags=SYSCALLS.get(),fd=SYSCALLS.get(),off=SYSCALLS.get();off<<=12;var ptr;var allocated=false;if(fd===-1){ptr=_memalign(PAGE_SIZE,len);if(!ptr)return-ERRNO_CODES.ENOMEM;_memset(ptr,0,len);allocated=true}else{var info=FS.getStream(fd);if(!info)return-ERRNO_CODES.EBADF;var res=FS.mmap(info,HEAPU8,addr,len,off,prot,flags);ptr=res.ptr;allocated=res.allocated}SYSCALLS.mappings[ptr]={malloc:ptr,len:len,allocated:allocated,fd:fd,flags:flags};return ptr}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___syscall195(which,varargs){SYSCALLS.varargs=varargs;try{var path=SYSCALLS.getStr(),buf=SYSCALLS.get();return SYSCALLS.doStat(FS.stat,path,buf)}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___syscall197(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(),buf=SYSCALLS.get();return SYSCALLS.doStat(FS.stat,stream.path,buf)}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___syscall221(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(),cmd=SYSCALLS.get();switch(cmd){case 0:{var arg=SYSCALLS.get();if(arg<0){return-ERRNO_CODES.EINVAL}var newStream;newStream=FS.open(stream.path,stream.flags,0,arg);return newStream.fd};case 1:case 2:return 0;case 3:return stream.flags;case 4:{var arg=SYSCALLS.get();stream.flags|=arg;return 0};case 12:case 12:{var arg=SYSCALLS.get();var offset=0;HEAP16[arg+offset>>1]=2;return 0};case 13:case 14:case 13:case 14:return 0;case 16:case 8:return-ERRNO_CODES.EINVAL;case 9:___setErrNo(ERRNO_CODES.EINVAL);return-1;default:{return-ERRNO_CODES.EINVAL}}}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___syscall33(which,varargs){SYSCALLS.varargs=varargs;try{var path=SYSCALLS.getStr(),amode=SYSCALLS.get();return SYSCALLS.doAccess(path,amode)}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___syscall5(which,varargs){SYSCALLS.varargs=varargs;try{var pathname=SYSCALLS.getStr(),flags=SYSCALLS.get(),mode=SYSCALLS.get();var stream=FS.open(pathname,flags,mode);return stream.fd}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___syscall54(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(),op=SYSCALLS.get();switch(op){case 21509:case 21505:{if(!stream.tty)return-ERRNO_CODES.ENOTTY;return 0};case 21510:case 21511:case 21512:case 21506:case 21507:case 21508:{if(!stream.tty)return-ERRNO_CODES.ENOTTY;return 0};case 21519:{if(!stream.tty)return-ERRNO_CODES.ENOTTY;var argp=SYSCALLS.get();HEAP32[argp>>2]=0;return 0};case 21520:{if(!stream.tty)return-ERRNO_CODES.ENOTTY;return-ERRNO_CODES.EINVAL};case 21531:{var argp=SYSCALLS.get();return FS.ioctl(stream,op,argp)};case 21523:{if(!stream.tty)return-ERRNO_CODES.ENOTTY;return 0};default:abort("bad ioctl syscall "+op)}}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___syscall6(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD();FS.close(stream);return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___syscall91(which,varargs){SYSCALLS.varargs=varargs;try{var addr=SYSCALLS.get(),len=SYSCALLS.get();var info=SYSCALLS.mappings[addr];if(!info)return 0;if(len===info.len){var stream=FS.getStream(info.fd);SYSCALLS.doMsync(addr,stream,len,info.flags);FS.munmap(stream);SYSCALLS.mappings[addr]=null;if(info.allocated){_free(info.malloc)}}return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}var cttz_i8=allocate([8,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0],"i8",ALLOC_STATIC);function ___unlock(){}function __exit(status){Module["exit"](status)}function _exit(status){__exit(status)}var _environ=STATICTOP;STATICTOP+=16;function ___buildEnvironment(env){var MAX_ENV_VALUES=64;var TOTAL_ENV_SIZE=1024;var poolPtr;var envPtr;if(!___buildEnvironment.called){___buildEnvironment.called=true;ENV["USER"]=ENV["LOGNAME"]="web_user";ENV["PATH"]="/";ENV["PWD"]="/";ENV["HOME"]="/home/web_user";ENV["LANG"]="C.UTF-8";ENV["_"]=Module["thisProgram"];poolPtr=staticAlloc(TOTAL_ENV_SIZE);envPtr=staticAlloc(MAX_ENV_VALUES*4);HEAP32[envPtr>>2]=poolPtr;HEAP32[_environ>>2]=envPtr}else{envPtr=HEAP32[_environ>>2];poolPtr=HEAP32[envPtr>>2]}var strings=[];var totalSize=0;for(var key in env){if(typeof env[key]==="string"){var line=key+"="+env[key];strings.push(line);totalSize+=line.length}}if(totalSize>TOTAL_ENV_SIZE){throw new Error("Environment size exceeded TOTAL_ENV_SIZE!")}var ptrSize=4;for(var i=0;i>2]=poolPtr;poolPtr+=line.length+1}HEAP32[envPtr+strings.length*ptrSize>>2]=0}var ENV={};function _getenv(name){if(name===0)return 0;name=Pointer_stringify(name);if(!ENV.hasOwnProperty(name))return 0;if(_getenv.ret)_free(_getenv.ret);_getenv.ret=allocateUTF8(ENV[name]);return _getenv.ret}var _llvm_ceil_f64=Math_ceil;var _llvm_fabs_f64=Math_abs;var _llvm_floor_f64=Math_floor;var _llvm_pow_f64=Math_pow;var _llvm_sqrt_f64=Math_sqrt;function _llvm_trap(){abort("trap!")}function _longjmp(env,value){Module["setThrew"](env,value||1);throw"longjmp"}function _emscripten_memcpy_big(dest,src,num){HEAPU8.set(HEAPU8.subarray(src,src+num),dest);return dest}function _setenv(envname,envval,overwrite){if(envname===0){___setErrNo(ERRNO_CODES.EINVAL);return-1}var name=Pointer_stringify(envname);var val=Pointer_stringify(envval);if(name===""||name.indexOf("=")!==-1){___setErrNo(ERRNO_CODES.EINVAL);return-1}if(ENV.hasOwnProperty(name)&&!overwrite)return 0;ENV[name]=val;___buildEnvironment(ENV);return 0}function _times(buffer){if(buffer!==0){_memset(buffer,0,16)}return 0}if(ENVIRONMENT_IS_NODE){_emscripten_get_now=function _emscripten_get_now_actual(){var t=process["hrtime"]();return t[0]*1e3+t[1]/1e6}}else if(typeof dateNow!=="undefined"){_emscripten_get_now=dateNow}else if(typeof self==="object"&&self["performance"]&&typeof self["performance"]["now"]==="function"){_emscripten_get_now=(function(){return self["performance"]["now"]()})}else if(typeof performance==="object"&&typeof performance["now"]==="function"){_emscripten_get_now=(function(){return performance["now"]()})}else{_emscripten_get_now=Date.now}FS.staticInit();__ATINIT__.unshift((function(){if(!Module["noFSInit"]&&!FS.init.initialized)FS.init()}));__ATMAIN__.push((function(){FS.ignorePermissions=false}));__ATEXIT__.push((function(){FS.quit()}));__ATINIT__.unshift((function(){TTY.init()}));__ATEXIT__.push((function(){TTY.shutdown()}));if(ENVIRONMENT_IS_NODE){var fs=require("fs");var NODEJS_PATH=require("path");NODEFS.staticInit()}___buildEnvironment(ENV);DYNAMICTOP_PTR=staticAlloc(4);STACK_BASE=STACKTOP=alignMemory(STATICTOP);STACK_MAX=STACK_BASE+TOTAL_STACK;DYNAMIC_BASE=alignMemory(STACK_MAX);HEAP32[DYNAMICTOP_PTR>>2]=DYNAMIC_BASE;staticSealed=true;var ASSERTIONS=false;function intArrayFromString(stringy,dontAddNull,length){var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}function intArrayToString(array){var ret=[];for(var i=0;i255){if(ASSERTIONS){assert(false,"Character code "+chr+" ("+String.fromCharCode(chr)+") at offset "+i+" not in 0x00-0xFF.")}chr&=255}ret.push(String.fromCharCode(chr))}return ret.join("")}var decodeBase64=typeof atob==="function"?atob:(function(input){var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{enc1=keyStr.indexOf(input.charAt(i++));enc2=keyStr.indexOf(input.charAt(i++));enc3=keyStr.indexOf(input.charAt(i++));enc4=keyStr.indexOf(input.charAt(i++));chr1=enc1<<2|enc2>>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;output=output+String.fromCharCode(chr1);if(enc3!==64){output=output+String.fromCharCode(chr2)}if(enc4!==64){output=output+String.fromCharCode(chr3)}}while(i>2]=0;h=ks()|0;ps(h,10904);ps(h,17148);Zl(1)|0;Yl(16)|0;ep(1);while(1){a=Sn(a)|0;e=c[f>>2]|0;if(!a)break;if(!e){ls(h,a,d)|0;os(h,a,b,f,g)|0;hr(h,a)|0}ln(a)|0;a=174181}l=i;return e|0}function zb(a){a=a|0;var d=0,e=0,f=0,g=0;g=l;l=l+16|0;d=g+4|0;e=g;f=c[(c[a+16>>2]|0)+8>>2]|0;a=a+64|0;switch(c[a>>2]|0){case 0:{vx(f);break}case 1:{if(b[(c[f+16>>2]|0)+136>>1]&1)nB(f);break}case 4:case 5:case 6:{sx(f,e,d);Cb(f,c[e>>2]|0,c[d>>2]|0,c[a>>2]|0);break}default:{}}l=g;return}function Ab(a){a=a|0;var b=0,d=0,e=0,f=0;d=c[(c[a+16>>2]|0)+8>>2]|0;if(!(c[41841]|0)){c[41841]=c[4442];c[41842]=9;c[41843]=17}e=d+64|0;f=(c[e>>2]|0)+8|0;b=c[f>>2]|0;c[f>>2]=167364;switch(c[a+64>>2]|0){case 2:{ix(a,d,a,0);break}case 3:{ix(a,d,a,1);break}case 1:case 0:{if(!(c[a+152>>2]&134217728))_p(d,a)|0;break}case 6:case 5:case 4:{Bb(d);if(!(c[a+152>>2]&134217728))_p(d,a)|0;break}default:{}}c[(c[e>>2]|0)+8>>2]=b;return}function Bb(b){b=b|0;var d=0,e=0;d=c[41845]|0;if((d|0)!=(c[41844]|0)){e=c[c[41876]>>2]|0;if(!e){e=tB(b,0,84827,174181)|0;c[c[41876]>>2]=e;d=c[41845]|0}if(d>>>0>=(c[41846]|0)>>>0){dm(167376,1)|0;d=c[41845]|0}a[d>>0]=0;d=c[41844]|0;c[41845]=d;Cm(b,e,d)|0}if(c[(c[b+16>>2]|0)+12>>2]|0){e=c[(c[41876]|0)+4>>2]|0;d=c[41861]|0;if(d>>>0>=(c[41862]|0)>>>0){dm(167440,1)|0;d=c[41861]|0}a[d>>0]=0;d=c[41860]|0;c[41861]=d;Cm(b,e,d)|0}Lm(b,59577,c[(c[41876]|0)+8236>>2]|0,174181)|0;d=0;while(1){if((d|0)==8)break;gm(167376+(d<<4)|0);d=d+1|0}_I(c[41876]|0);h[1]=1.0;h[5]=1.0;c[41877]=0;c[41881]=0;return}function Cb(d,e,f,g){d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0;i=ZI(8240)|0;c[41876]=i;a:do switch(g|0){case 6:{b[i+8232>>1]=14;g=59593;break}case 5:{b[i+8232>>1]=12;g=59597;break}default:{g=Im(d,59577)|0;if((g|0?a[g>>0]|0:0)?(h=Db(g)|0,(h&65535)>10):0){i=c[41876]|0;b[i+8232>>1]=h;break a}g=Db(59589)|0;i=c[41876]|0;b[i+8232>>1]=g;g=59589}}while(0);c[i+8236>>2]=g;j=d+16|0;g=c[j>>2]|0;if(!(c[g+180>>2]|0))h=0;else{h=tB(d,0,84827,174181)|0;i=c[41876]|0;g=c[j>>2]|0}c[i>>2]=h;if(!(a[g+113>>0]&8))g=0;else g=tB(d,0,59601,174181)|0;c[(c[41876]|0)+4>>2]=g;i=tB(d,1,84827,174181)|0;c[(c[41876]|0)+8>>2]=i;i=tB(d,1,59601,174181)|0;c[(c[41876]|0)+12>>2]=i;i=tB(d,2,84827,174181)|0;g=c[41876]|0;c[g+16>>2]=i;if(!f)h=0;else{h=tB(d,2,59609,174181)|0;g=c[41876]|0}c[g+20>>2]=h;if(!e)h=0;else{h=tB(d,2,59617,174181)|0;g=c[41876]|0}c[g+24>>2]=h;h=a[(c[j>>2]|0)+113>>0]|0;if(!(h&33))i=0;else{i=tB(d,2,59601,174181)|0;g=c[41876]|0;h=a[(c[j>>2]|0)+113>>0]|0}c[g+28>>2]=i;if(!(h&2))i=0;else{i=tB(d,2,59625,174181)|0;g=c[41876]|0;h=a[(c[j>>2]|0)+113>>0]|0}c[g+32>>2]=i;if(!(h&4))h=0;else{h=tB(d,2,59634,174181)|0;g=c[41876]|0}c[g+36>>2]=h;g=0;while(1){if((g|0)==8)break;cm(167376+(g<<4)|0,1024,(c[41876]|0)+40+(g<<10)|0);g=g+1|0}return}function Db(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0;j=l;l=l+1040|0;h=j;g=j+8|0;f=0;d=b;a:while(1){do{e=d;d=d+1|0;e=a[e>>0]|0;if(!(e<<24>>24))break a}while(((e<<24>>24)+-48|0)>>>0>=10);if((f|0)>=1023){i=7;break}a[g+f>>0]=e;f=f+1|0}if((i|0)==7){c[h>>2]=b;_l(0,59643,h)|0}a[g+f>>0]=0;i=(rM(g)|0)&65535;l=j;return i|0}function Eb(b){b=b|0;var d=0,e=0;e=c[(c[b+16>>2]|0)+8>>2]|0;d=c[c[41876]>>2]|0;b=c[41849]|0;if(b>>>0>=(c[41850]|0)>>>0){dm(167392,1)|0;b=c[41849]|0}a[b>>0]=0;b=c[41848]|0;c[41849]=b;Cm(e,d,b)|0;if(c[(c[e+16>>2]|0)+12>>2]|0){d=c[(c[41876]|0)+4>>2]|0;b=c[41865]|0;if(b>>>0>=(c[41866]|0)>>>0){dm(167456,1)|0;b=c[41865]|0}a[b>>0]=0;b=c[41864]|0;c[41865]=b;Cm(e,d,b)|0}h[2]=1.0;h[6]=1.0;c[41878]=0;c[41882]=0;return}function Fb(b){b=b|0;var d=0,e=0;e=c[(c[b+16>>2]|0)+8>>2]|0;b=c[41849]|0;if((c[41848]|0)!=(b|0)){d=c[(c[41876]|0)+8>>2]|0;if(b>>>0>=(c[41850]|0)>>>0){dm(167392,1)|0;b=c[41849]|0}a[b>>0]=0;b=c[41848]|0;c[41849]=b;Cm(e,d,b)|0}b=c[41865]|0;if((c[41864]|0)!=(b|0)){d=c[(c[41876]|0)+12>>2]|0;if(b>>>0>=(c[41866]|0)>>>0){dm(167456,1)|0;b=c[41865]|0}a[b>>0]=0;b=c[41864]|0;c[41865]=b;Cm(e,d,b)|0}h[9]=1.0;h[11]=1.0;c[41885]=0;c[41887]=0;return}function Gb(b){b=b|0;var d=0,e=0;e=c[(c[b+16>>2]|0)+8>>2]|0;b=c[41849]|0;if((c[41848]|0)!=(b|0)){d=c[(c[41876]|0)+16>>2]|0;if(b>>>0>=(c[41850]|0)>>>0){dm(167392,1)|0;b=c[41849]|0}a[b>>0]=0;b=c[41848]|0;c[41849]=b;Cm(e,d,b)|0}b=c[41853]|0;if((c[41852]|0)!=(b|0)){d=c[(c[41876]|0)+24>>2]|0;if(b>>>0>=(c[41854]|0)>>>0){dm(167408,1)|0;b=c[41853]|0}a[b>>0]=0;b=c[41852]|0;c[41853]=b;Cm(e,d,b)|0}b=c[41857]|0;if((c[41856]|0)!=(b|0)){d=c[(c[41876]|0)+20>>2]|0;if(b>>>0>=(c[41858]|0)>>>0){dm(167424,1)|0;b=c[41857]|0}a[b>>0]=0;b=c[41856]|0;c[41857]=b;Cm(e,d,b)|0}b=c[41865]|0;if((c[41864]|0)!=(b|0)){d=c[(c[41876]|0)+28>>2]|0;if(b>>>0>=(c[41866]|0)>>>0){dm(167456,1)|0;b=c[41865]|0}a[b>>0]=0;b=c[41864]|0;c[41865]=b;Cm(e,d,b)|0}b=c[41869]|0;if((c[41868]|0)!=(b|0)){d=c[(c[41876]|0)+36>>2]|0;if(b>>>0>=(c[41870]|0)>>>0){dm(167472,1)|0;b=c[41869]|0}a[b>>0]=0;b=c[41868]|0;c[41869]=b;Cm(e,d,b)|0}b=c[41873]|0;if((c[41872]|0)!=(b|0)){d=c[(c[41876]|0)+32>>2]|0;if(b>>>0>=(c[41874]|0)>>>0){dm(167488,1)|0;b=c[41873]|0}a[b>>0]=0;b=c[41872]|0;c[41873]=b;Cm(e,d,b)|0}h[10]=1.0;h[12]=1.0;h[3]=1.0;h[4]=1.0;h[7]=1.0;h[8]=1.0;c[41886]=0;c[41888]=0;c[41879]=0;c[41880]=0;c[41883]=0;c[41884]=0;return}function Hb(d,e,f){d=d|0;e=e|0;f=f|0;var g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;t=l;l=l+1056|0;j=t+16|0;s=t+8|0;r=t;k=t+32|0;o=c[(c[d+16>>2]|0)+12>>2]|0;p=c[11344+(o<<2)>>2]|0;fm(p,59746)|0;g=f+4|0;Qb(k,+h[(c[g>>2]|0)+16>>3]);fm(p,k)|0;Tb(d,174181,c[c[g>>2]>>2]|0);Nb(d);q=a[f+48>>0]|0;q=q<<24>>24==108?-1:q<<24>>24==114&1;g=c[g>>2]|0;if(!g)g=0;else g=c[g+24>>2]&127;i=b[(c[41876]|0)+8232>>1]|0;if((i&65535)>14?(m=c[11392+((i&65535)+-15<<2)>>2]&g,n=167508+(o<<2)|0,(c[n>>2]|0)!=(m|0)):0){c[r>>2]=m;pL(k,59749,r)|0;fm(p,k)|0;c[n>>2]=m}r=e+8|0;h[r>>3]=+h[r>>3]+ +h[f+24>>3];fm(p,59755)|0;c[j>>2]=c[e>>2];c[j+4>>2]=c[e+4>>2];c[j+8>>2]=c[e+8>>2];c[j+12>>2]=c[e+12>>2];Pb(p,j);c[s>>2]=q;pL(k,87254,s)|0;fm(p,k)|0;Qb(k,+h[f+32>>3]);fm(p,k)|0;Tb(d,174181,c[f>>2]|0);l=t;return}function Ib(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,i=0;i=l;l=l+1040|0;f=i;g=i+16|0;e=c[(c[a+16>>2]|0)+12>>2]|0;Mb(a);Nb(a);if(!d){a=c[11344+(e<<2)>>2]|0;fm(a,59743)|0}else{if((d|1|0)==3)Vb(a,d,b,2);else Wb(a);a=c[11344+(e<<2)>>2]|0;fm(a,59740)|0};c[f>>2]=c[b>>2];c[f+4>>2]=c[b+4>>2];c[f+8>>2]=c[b+8>>2];c[f+12>>2]=c[b+12>>2];Pb(a,f);Qb(g,+h[b+16>>3]-+h[b>>3]);fm(a,g)|0;Qb(g,+h[b+24>>3]-+h[b+8>>3]);fm(a,g)|0;l=i;return}function Jb(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Mb(a);Nb(a);if(!d)Ob(a,112,b,c);else{if((d|1|0)==3)Vb(a,d,b,c);else Wb(a);Ob(a,80,b,c)}return}function Kb(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;Mb(a);Nb(a);if(!f)Ob(a,66,b,c);else{if((f|1|0)==3)Vb(a,f,b,c);else Wb(a);Ob(a,98,b,c)}return}function Lb(a,b,c){a=a|0;b=b|0;c=c|0;Mb(a);Nb(a);Ob(a,76,b,c);return}function Mb(b){b=b|0;var d=0,e=0,f=0,g=0.0,i=0,j=0,k=0,m=0,n=0;n=l;l=l+1184|0;i=n;f=n+24|0;m=n+8|0;cm(m,1024,n+152|0);j=b+16|0;d=c[j>>2]|0;g=+h[d+152>>3];e=8+(c[d+12>>2]<<3)|0;if(g!=+h[e>>3]){h[e>>3]=g;fm(m,59706)|0;h[i>>3]=+h[(c[j>>2]|0)+152>>3];pL(f,59720,i)|0;Rb(f,0);fm(m,f)|0;f=m+4|0;d=c[f>>2]|0;e=m+8|0;if(d>>>0>=(c[e>>2]|0)>>>0){dm(m,1)|0;d=c[f>>2]|0}c[f>>2]=d+1;a[d>>0]=41;d=c[f>>2]|0;if(d>>>0>=(c[e>>2]|0)>>>0){dm(m,1)|0;d=c[f>>2]|0}a[d>>0]=0;d=c[m>>2]|0;c[f>>2]=d;Tb(b,59725,d);d=c[j>>2]|0}d=c[d+160>>2]|0;if(d|0){j=m+4|0;k=m+8|0;a:while(1){i=d+4|0;d=c[d>>2]|0;if(!d)break;switch(a[d>>0]|0){case 102:{if(!(xJ(d,95923)|0)){d=i;continue a}break}case 98:{if(!(xJ(d,95905)|0)){d=i;continue a}break}case 115:{if(!(xJ(d,95910)|0)){d=i;continue a}break}default:{}}fm(m,d)|0;do{f=d;d=d+1|0}while((a[f>>0]|0)!=0);if(a[d>>0]|0){e=c[j>>2]|0;if(e>>>0>=(c[k>>2]|0)>>>0){dm(m,1)|0;e=c[j>>2]|0}c[j>>2]=e+1;a[e>>0]=40;f=0;while(1){if(!(a[d>>0]|0))break;if(f|0){e=c[j>>2]|0;if(e>>>0>=(c[k>>2]|0)>>>0){dm(m,1)|0;e=c[j>>2]|0}c[j>>2]=e+1;a[e>>0]=44}fm(m,d)|0;do{e=d;d=d+1|0}while((a[e>>0]|0)!=0);f=f+1|0}d=c[j>>2]|0;if(d>>>0>=(c[k>>2]|0)>>>0){dm(m,1)|0;d=c[j>>2]|0}c[j>>2]=d+1;a[d>>0]=41}d=c[j>>2]|0;if(d>>>0>=(c[k>>2]|0)>>>0){dm(m,1)|0;d=c[j>>2]|0}a[d>>0]=0;d=c[m>>2]|0;c[j>>2]=d;Tb(b,59725,d);d=i}gm(m)}l=n;return}function Nb(a){a=a|0;Sb((c[a+16>>2]|0)+16|0);Tb(a,68667,173882);return}function Ob(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0;k=l;l=l+1040|0;j=k;i=k+16|0;h=c[11344+(c[(c[b+16>>2]|0)+12>>2]<<2)>>2]|0;g=h+4|0;b=c[g>>2]|0;if(b>>>0>=(c[h+8>>2]|0)>>>0){dm(h,1)|0;b=c[g>>2]|0}c[g>>2]=b+1;a[b>>0]=d;c[j>>2]=f;pL(i,59670,j)|0;fm(h,i)|0;b=0;while(1){if((b|0)>=(f|0))break;i=e+(b<<4)|0;c[j>>2]=c[i>>2];c[j+4>>2]=c[i+4>>2];c[j+8>>2]=c[i+8>>2];c[j+12>>2]=c[i+12>>2];Pb(h,j);b=b+1|0}l=k;return}function Pb(a,b){a=a|0;b=b|0;var c=0,d=0;c=l;l=l+1024|0;d=c;Qb(d,+h[b>>3]);fm(a,d)|0;Qb(d,+hx(+h[b+8>>3]));fm(a,d)|0;l=c;return}function Qb(a,b){a=a|0;b=+b;var c=0,d=0;c=l;l=l+16|0;d=c;h[d>>3]=b>-1.0e-08&b<1.0e-08?0.0:b;pL(a,59675,d)|0;Rb(a,1);l=c;return}function Rb(b,c){b=b|0;c=c|0;var d=0,e=0;d=WJ(b,46)|0;if(!d){if(c|0){d=b+(rJ(b)|0)|0;e=10}}else{while(1){b=d+1|0;if(!(a[b>>0]|0))break;else d=b}a:while(1){switch(a[d>>0]|0){case 46:{e=5;break a}case 48:break;default:{e=6;break a}}a[d>>0]=0;d=d+-1|0}if((e|0)==5)a[d>>0]=0;else if((e|0)==6)d=d+1|0;if(c|0)e=10}if((e|0)==10){a[d>>0]=32;a[d+1>>0]=0}return}function Sb(b){b=b|0;var e=0,f=0,g=0,h=0,i=0,j=0;j=l;l=l+32|0;i=j+16|0;h=j;e=a[b+3>>0]|0;f=d[b>>0]|0;g=d[b+1>>0]|0;b=d[b+2>>0]|0;if(e<<24>>24==-1){c[h>>2]=f;c[h+4>>2]=g;c[h+8>>2]=b;pL(173882,68547,h)|0}else{c[i>>2]=f;c[i+4>>2]=g;c[i+8>>2]=b;c[i+12>>2]=e&255;pL(173882,59688,i)|0}l=j;return}function Tb(a,b,d){a=a|0;b=b|0;d=d|0;Ub(c[11344+(c[(c[a+16>>2]|0)+12>>2]<<2)>>2]|0,b,d);return}function Ub(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;f=l;l=l+1040|0;h=f;g=f+8|0;i=rJ(e)|0;c[h>>2]=d;c[h+4>>2]=i;pL(g,59681,h)|0;fm(b,g)|0;fm(b,e)|0;e=b+4|0;d=c[e>>2]|0;if(d>>>0>=(c[b+8>>2]|0)>>>0){dm(b,1)|0;d=c[e>>2]|0}c[e>>2]=d+1;a[d>>0]=32;l=f;return}function Vb(b,d,f,i){b=b|0;d=d|0;f=f|0;i=i|0;var j=0.0,k=0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0.0;x=l;l=l+1120|0;t=x+64|0;w=x+80|0;k=x+32|0;r=x+16|0;s=x;u=c[b+16>>2]|0;j=+(c[u+136>>2]|0)*.017453292519943295;if((e[(c[41876]|0)+8232>>1]|0)<14)Wb(b);else{cm(w,1024,x+96|0);v=(d|0)==2;if(v){JB(f,k,i,j,2);f=w+4|0;d=c[f>>2]|0;if(d>>>0>=(c[w+8>>2]|0)>>>0){dm(w,1)|0;d=c[f>>2]|0}c[f>>2]=d+1;a[d>>0]=91;c[t>>2]=c[k>>2];c[t+4>>2]=c[k+4>>2];c[t+8>>2]=c[k+8>>2];c[t+12>>2]=c[k+12>>2];Pb(w,t);s=k+16|0;c[t>>2]=c[s>>2];c[t+4>>2]=c[s+4>>2];c[t+8>>2]=c[s+8>>2];c[t+12>>2]=c[s+12>>2];Pb(w,t)}else{JB(f,k,i,0.0,3);q=+h[k+24>>3];o=+h[k>>3];if(j==0.0){n=+h[k+8>>3];p=q*.25;j=n;m=o}else{p=q*.25;y=p;m=+E(+j)*y+o;n=+h[k+8>>3];j=+F(+j)*y+n}h[r>>3]=m;h[r+8>>3]=j;h[s>>3]=o;h[s+8>>3]=n;f=w+4|0;d=c[f>>2]|0;if(d>>>0>=(c[w+8>>2]|0)>>>0){dm(w,1)|0;d=c[f>>2]|0}c[f>>2]=d+1;a[d>>0]=40;c[t>>2]=c[r>>2];c[t+4>>2]=c[r+4>>2];c[t+8>>2]=c[r+8>>2];c[t+12>>2]=c[r+12>>2];Pb(w,t);Xb(w,p);c[t>>2]=c[s>>2];c[t+4>>2]=c[s+4>>2];c[t+8>>2]=c[s+8>>2];c[t+12>>2]=c[s+12>>2];Pb(w,t);Xb(w,q)}fm(w,59731)|0;d=u+140|0;j=+g[d>>2];f=u+56|0;if(j>0.0){Yb(w,j,f);Yb(w,+g[d>>2],u+96|0)}else{Yb(w,0.0,f);Yb(w,1.0,u+96|0)}hm(w)|0;k=w+4|0;d=c[k>>2]|0;i=w+8|0;f=d>>>0>=(c[i>>2]|0)>>>0;if(v){if(f){dm(w,1)|0;d=c[k>>2]|0}c[k>>2]=d+1;a[d>>0]=93}else{if(f){dm(w,1)|0;d=c[k>>2]|0}c[k>>2]=d+1;a[d>>0]=41}d=c[k>>2]|0;if(d>>>0>=(c[i>>2]|0)>>>0){dm(w,1)|0;d=c[k>>2]|0}a[d>>0]=0;v=c[w>>2]|0;c[k>>2]=v;Tb(b,59728,v);gm(w)}l=x;return}function Wb(a){a=a|0;Sb((c[a+16>>2]|0)+56|0);Tb(a,59728,173882);return}function Xb(a,b){a=a|0;b=+b;var c=0,d=0;c=l;l=l+1024|0;d=c;Qb(d,b);fm(a,d)|0;l=c;return}function Yb(a,b,c){a=a|0;b=+b;c=c|0;var d=0,e=0,f=0;d=l;l=l+1040|0;f=d;e=d+8|0;h[f>>3]=b;pL(e,59734,f)|0;Rb(e,1);Sb(c);Ub(a,e,173882);l=d;return}function Zb(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0;e=l;l=l+1040|0;i=e;f=e+16|0;g=c[11344+(c[(c[a+16>>2]|0)+12>>2]<<2)>>2]|0;fm(g,59843)|0;c[i>>2]=c[d>>2];c[i+4>>2]=c[d+4>>2];c[i+8>>2]=c[d+8>>2];c[i+12>>2]=c[d+12>>2];Pb(g,i);Qb(f,+h[d+16>>3]-+h[d>>3]);fm(g,f)|0;Qb(f,+h[d+24>>3]-+h[d+8>>3]);fm(g,f)|0;Tb(a,174181,c[b+8>>2]|0);l=e;return}function _b(a){a=a|0;var b=0;switch(c[a+64>>2]|0){case 0:{b=yr(c[a>>2]|0)|0;ms(b,c[(c[a+16>>2]|0)+8>>2]|0,60630,0)|0;zr(b);break}case 1:{vx(c[(c[a>>2]|0)+168>>2]|0);break}default:{}}return}function $b(b){b=b|0;var d=0,e=0,f=0,g=0;f=l;l=l+16|0;d=f;e=c[(c[b+16>>2]|0)+8>>2]|0;if(!(c[41889]|0)){c[41889]=c[4442];c[41890]=9;c[41891]=17}c[(c[e+64>>2]|0)+8>>2]=167556;ac(e,1);c[d>>2]=0;a[d+4>>0]=(a[(c[e+16>>2]|0)+115>>0]|0)==1&1;g=c[b+64>>2]|0;a[d+5>>0]=((g|0)==0|(g|0)==3)&1;a[d+6>>0]=0;bc(e,b,1,d);l=f;return}function ac(a,b){a=a|0;b=b|0;var d=0;c[a>>2]=c[a>>2]&-9;d=Jp(a)|0;while(1){if(!d)break;ac(d,0);d=Kp(d)|0}a:do if(b|0){b=co(a)|0;while(1){if(!b)break a;c[b>>2]=c[b>>2]&-9;d=Pm(a,b)|0;while(1){if(!d)break;c[d>>2]=c[d>>2]&-9;d=Rm(a,d)|0}b=eo(a,b)|0}}while(0);return}function bc(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0;q=l;l=l+16|0;p=q+8|0;o=q;n=(d|0)!=0;if(n){m=Ql(11764,c[4345]|0)|0;So(a,1,86799,12,0);So(a,2,86799,12,0);So(a,0,86799,-12,0);f=cc(a,0,m)|0;j=co(a)|0;i=0;g=0;while(1){if(!j)break;if(!(VJ(Dn(j)|0,93039,7)|0)){k=g;g=dc(m,Dn(j)|0)|0}else{k=g+1|0;g=g+f|0}c[(Lo(j,86799,0)|0)+8>>2]=g;h=Pm(a,j)|0;g=i;while(1){if(!h)break;c[(Lo(h,86799,0)|0)+8>>2]=g;h=Rm(a,h)|0;g=g+1|0}j=eo(a,j)|0;i=g;g=k}Kl(m)|0}else f=0;m=c[e>>2]|0;c[e>>2]=m+1;ec(b,m);mr(b,82337)|0;fc(a,b,d,e);gc(a,b,e);mr(b,82308)|0;ec(b,c[e>>2]|0);if(n){c[o>>2]=f;sr(b,59846,o)}else{c[p>>2]=c[(Lo(a,86799,0)|0)+8>>2];sr(b,59866,p)}ic(a,b,d,hc(a,b,d,e)|0,e);jc(a,b,d,e);mr(b,134901)|0;p=(c[e>>2]|0)+-1|0;c[e>>2]=p;ec(b,p);if(n)mr(b,95830)|0;else mr(b,68190)|0;l=q;return}function cc(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;if((so(a)|0)!=(a|0)){e=b+1|0;c[(Lo(a,86799,0)|0)+8>>2]=b;if(!(VJ(Dn(a)|0,93039,7)|0)){b=Dn(a)|0;vc(d,b,c[(Lo(a,86799,0)|0)+8>>2]|0);b=e}else b=e}e=Jp(a)|0;while(1){if(!e)break;a=cc(e,b,d)|0;e=Kp(e)|0;b=a}return b|0}function dc(a,b){a=a|0;b=b|0;a=bb[c[a>>2]&31](a,b,512)|0;if(!a)a=-1;else a=c[a+12>>2]|0;return a|0}function ec(a,b){a=a|0;b=b|0;while(1){if((b|0)<=0)break;mr(a,60598)|0;b=b+-1|0}return}function fc(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;h=l;l=l+32|0;g=h+16|0;f=h+8|0;i=h;j=Dn(a)|0;ec(b,c[e>>2]|0);c[i>>2]=mc(j,e)|0;sr(b,59954,i);if(d|0){mr(b,82308)|0;ec(b,c[e>>2]|0);j=(qn(a)|0)!=0;c[f>>2]=j?92685:122100;sr(b,60568,f);ec(b,c[e>>2]|0);j=(sn(a)|0)!=0;c[g>>2]=j?92685:122100;sr(b,60585,g)}l=h;return}function gc(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0;o=l;l=l+16|0;n=o+8|0;m=o;i=so(b)|0;j=c[b>>2]&3;f=Dm(i,j,0)|0;a:do if(f|0){k=e+5|0;while(1){if(!f)break a;g=Jm(b,f)|0;do if(g|0){h=f+8|0;if(!(a[g>>0]|0)){g=c[h>>2]|0;if((a[g>>0]|0)!=108)break;if(xJ(g,86240)|0)break}mr(d,82308)|0;ec(d,c[e>>2]|0);c[m>>2]=mc(c[h>>2]|0,e)|0;sr(d,60004,m);if(a[k>>0]|0?oc(c[h>>2]|0)|0:0){pc(Jm(b,f)|0,d,e);break}c[n>>2]=mc(Jm(b,f)|0,e)|0;sr(d,60011,n)}while(0);f=Dm(i,j,f)|0}}while(0);l=o;return}function hc(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;i=l;l=l+16|0;h=i;f=Jp(a)|0;if(f){mr(b,82308)|0;g=c[e>>2]|0;c[e>>2]=g+1;ec(b,g);g=(d|0)!=0;if(g){mr(b,59928)|0;a=0;d=f}else{mr(b,59988)|0;ec(b,c[e>>2]|0);a=0;d=f}while(1){if(!d)break;if(!a)a=1;else mr(b,82308)|0;if(g)nc(d,b,e);else{c[h>>2]=c[(Lo(d,86799,0)|0)+8>>2];sr(b,122187,h)}d=Kp(d)|0}if(g)a=1;else{c[e>>2]=(c[e>>2]|0)+-1;mr(b,134901)|0;ec(b,c[e>>2]|0);mr(b,82303)|0;a=1}}else a=0;l=i;return a|0}function ic(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0;g=co(a)|0;if(!g){if((d|0)!=0&(e|0)!=0){c[f>>2]=(c[f>>2]|0)+-1;mr(b,134901)|0;ec(b,c[f>>2]|0);mr(b,82303)|0}}else{mr(b,82308)|0;h=(d|0)!=0;if(h)if(!e){e=c[f>>2]|0;c[f>>2]=e+1;ec(b,e);mr(b,59928)|0;e=0}else e=0;else{e=c[f>>2]|0;c[f>>2]=e+1;ec(b,e);mr(b,59942)|0;ec(b,c[f>>2]|0);e=0}while(1){if(!g)break;if(VJ(Dn(g)|0,93039,7)|0){do if(e)if(h){mr(b,82308)|0;break}else{mr(b,86030)|0;break}else e=1;while(0);lc(g,b,d,f)}g=eo(a,g)|0}c[f>>2]=(c[f>>2]|0)+-1;mr(b,134901)|0;ec(b,c[f>>2]|0);mr(b,82303)|0}return}function jc(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;f=co(a)|0;a:do if(f|0){while(1){if(!f)break a;if(Pm(a,f)|0)break;f=eo(a,f)|0}mr(b,82308)|0;i=c[e>>2]|0;c[e>>2]=i+1;ec(b,i);mr(b,59878)|0;i=(d|0)!=0;if(i)g=0;else{ec(b,c[e>>2]|0);g=0}while(1){if(!f)break;h=Pm(a,f)|0;while(1){if(!h)break;do if(g)if(i){mr(b,82308)|0;break}else{mr(b,86030)|0;break}else g=1;while(0);kc(h,b,d,e);h=Rm(a,h)|0}f=eo(a,f)|0}c[e>>2]=(c[e>>2]|0)+-1;mr(b,134901)|0;ec(b,c[e>>2]|0);mr(b,82303)|0}while(0);return}function kc(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;j=l;l=l+32|0;i=j+24|0;h=j+16|0;g=j+8|0;f=j;if(!d){c[i>>2]=c[(Lo(a,86799,0)|0)+8>>2];sr(b,122187,i)}else{i=c[e>>2]|0;c[e>>2]=i+1;ec(b,i);mr(b,82337)|0;ec(b,c[e>>2]|0);c[f>>2]=c[(Lo(a,86799,0)|0)+8>>2];sr(b,59890,f);ec(b,c[e>>2]|0);c[g>>2]=c[(Lo(c[((c[a>>2]&3|0)==3?a:a+48|0)+40>>2]|0,86799,0)|0)+8>>2];sr(b,59904,g);ec(b,c[e>>2]|0);c[h>>2]=c[(Lo(c[((c[a>>2]&3|0)==2?a:a+-48|0)+40>>2]|0,86799,0)|0)+8>>2];sr(b,59917,h);gc(a,b,e);mr(b,134901)|0;i=(c[e>>2]|0)+-1|0;c[e>>2]=i;ec(b,i);mr(b,68190)|0}l=j;return}function lc(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;i=l;l=l+32|0;h=i+16|0;g=i+8|0;f=i;if(!d){c[h>>2]=c[(Lo(a,86799,0)|0)+8>>2];sr(b,122187,h)}else{h=c[e>>2]|0;c[e>>2]=h+1;ec(b,h);mr(b,82337)|0;ec(b,c[e>>2]|0);c[f>>2]=c[(Lo(a,86799,0)|0)+8>>2];sr(b,59890,f);ec(b,c[e>>2]|0);c[g>>2]=mc(Dn(a)|0,e)|0;sr(b,59954,g);gc(a,b,e);mr(b,134901)|0;h=(c[e>>2]|0)+-1|0;c[e>>2]=h;ec(b,h);mr(b,68190)|0}l=i;return}function mc(b,d){b=b|0;d=d|0;var e=0,f=0,g=0;g=d+4|0;if(a[g>>0]|0)b=yB(b)|0;if(!(c[41892]|0)){cm(167568,1024,0);e=b}else e=b;a:while(1){f=a[e>>0]|0;switch(f<<24>>24){case 0:break a;case 34:{fm(167568,59967)|0;break}case 92:{fm(167568,81579)|0;break}case 47:{fm(167568,59970)|0;break}case 8:{fm(167568,59973)|0;break}case 12:{fm(167568,59976)|0;break}case 10:{fm(167568,59979)|0;break}case 13:{fm(167568,59982)|0;break}case 9:{fm(167568,59985)|0;break}default:{d=c[41893]|0;if(d>>>0>=(c[41894]|0)>>>0){dm(167568,1)|0;d=c[41893]|0}c[41893]=d+1;a[d>>0]=f}}e=e+1|0}d=c[41893]|0;if(d>>>0>=(c[41894]|0)>>>0){dm(167568,1)|0;d=c[41893]|0}a[d>>0]=0;d=c[41892]|0;c[41893]=d;if(a[g>>0]|0)_I(b);return d|0}function nc(a,b,c){a=a|0;b=b|0;c=c|0;bc(a,b,0,c);a=Jp(a)|0;while(1){if(!a)break;mr(b,82308)|0;nc(a,b,c);a=Kp(a)|0}return}function oc(b){b=b|0;var c=0;c=b+1|0;a:do if((a[b>>0]|0)==95){b=(a[c>>0]|0)+-100<<24>>24;switch(((b&255)>>>2|b<<6&255)<<24>>24){case 0:{if(!(xJ(c,60525)|0)){b=1;break a}break}case 2:{if(!(xJ(c,60531)|0)){b=1;break a}break}case 1:{if(!(xJ(c,60538)|0)){b=1;break a}return (xJ(c,60552)|0)==0|0}case 4:{if(!(xJ(c,60545)|0)){b=1;break a}b=(xJ(c,60560)|0)==0&1;break a}default:{b=0;break a}}b=0}else b=0;while(0);return b|0}function pc(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;i=l;l=l+16|0;f=i;do if(b|0?a[b>>0]|0:0){h=wt(b)|0;if(!h){c[f>>2]=b;_l(0,60016,f)|0;break}mr(d,134901)|0;g=c[e>>2]|0;c[e>>2]=g+1;ec(d,g);mr(d,60043)|0;g=h+8|0;b=0;f=0;while(1){if((f|0)>=(c[h>>2]|0))break;if(!b)b=1;else mr(d,82308)|0;qc((c[g>>2]|0)+(f*80|0)|0,d,e);f=f+1|0}c[e>>2]=(c[e>>2]|0)+-1;mr(d,134901)|0;ec(d,c[e>>2]|0);mr(d,82303)|0;xt(h)}while(0);l=i;return}function qc(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0.0,C=0.0,D=0.0;A=l;l=l+240|0;y=A+224|0;x=A+216|0;w=A+208|0;v=A+200|0;u=A+192|0;t=A+184|0;s=A+176|0;r=A+152|0;q=A+136|0;p=A+128|0;o=A+112|0;n=A+104|0;m=A+96|0;k=A+88|0;j=A+72|0;i=A+48|0;z=A+40|0;g=A+8|0;f=A;e=c[d>>2]|0;c[d>>2]=e+1;ec(b,e);mr(b,82337)|0;ec(b,c[d>>2]|0);e=c[a>>2]|0;a:do switch(e|0){case 1:case 0:{c[f>>2]=(e|0)==0?69:101;sr(b,60046,f);ec(b,c[d>>2]|0);D=+h[a+16>>3];C=+h[a+24>>3];B=+h[a+32>>3];h[g>>3]=+h[a+8>>3];h[g+8>>3]=D;h[g+16>>3]=C;h[g+24>>3]=B;sr(b,60059,g);break}case 3:case 2:{c[z>>2]=(e|0)==2?80:112;sr(b,60046,z);ec(b,c[d>>2]|0);rc(b,a+8|0);break}case 5:case 4:{c[i>>2]=(e|0)==4?66:98;sr(b,60046,i);ec(b,c[d>>2]|0);rc(b,a+8|0);break}case 6:{sr(b,60094,A+56|0);ec(b,c[d>>2]|0);rc(b,a+8|0);break}case 7:{sr(b,60106,A+64|0);ec(b,c[d>>2]|0);D=+h[a+16>>3];h[j>>3]=+h[a+8>>3];h[j+8>>3]=D;sr(b,60118,j);ec(b,c[d>>2]|0);z=c[a+24>>2]|0;c[k>>2]=(z|0)==0?108:(z|0)==1?99:114;sr(b,60140,k);ec(b,c[d>>2]|0);h[m>>3]=+h[a+32>>3];sr(b,60156,m);ec(b,c[d>>2]|0);c[n>>2]=mc(c[a+40>>2]|0,d)|0;sr(b,60173,n);break}case 9:case 8:{c[o>>2]=(e|0)==8?67:99;sr(b,60046,o);ec(b,c[d>>2]|0);sr(b,60187,A+120|0);ec(b,c[d>>2]|0);c[p>>2]=mc(c[a+8>>2]|0,d)|0;sr(b,60204,p);break}case 13:case 14:{c[q>>2]=(e|0)==13?67:99;sr(b,60046,q);ec(b,c[d>>2]|0);switch(c[a+8>>2]|0){case 0:{sr(b,60187,A+144|0);ec(b,c[d>>2]|0);c[r>>2]=mc(c[a+16>>2]|0,d)|0;sr(b,60204,r);break a}case 1:{sr(b,60219,A+160|0);ec(b,c[d>>2]|0);sc(b,a+16|0,d);break a}default:{sr(b,60238,A+168|0);ec(b,c[d>>2]|0);tc(b,a+16|0,d);break a}}}case 10:{sr(b,60257,s);ec(b,c[d>>2]|0);h[t>>3]=+h[a+8>>3];sr(b,60269,t);ec(b,c[d>>2]|0);c[u>>2]=mc(c[a+16>>2]|0,d)|0;sr(b,60285,u);break}case 11:{sr(b,60299,v);ec(b,c[d>>2]|0);c[w>>2]=mc(c[a+8>>2]|0,d)|0;sr(b,60311,w);break}case 15:{sr(b,60326,x);ec(b,c[d>>2]|0);c[y>>2]=c[a+8>>2];sr(b,60338,y);break}default:{}}while(0);z=(c[d>>2]|0)+-1|0;c[d>>2]=z;ec(b,z);mr(b,68190)|0;l=A;return}function rc(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0,k=0.0;j=l;l=l+48|0;i=j+32|0;g=j+16|0;f=j+8|0;e=c[b>>2]|0;d=c[b+4>>2]|0;sr(a,60499,j);b=0;while(1){if((b|0)>=(e|0))break;if((b|0)>0)sr(a,86030,f);k=+h[d+(b*24|0)+8>>3];h[g>>3]=+h[d+(b*24|0)>>3];h[g+8>>3]=k;sr(a,60511,g);b=b+1|0}sr(a,60452,i);l=j;return}function sc(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0.0,i=0;e=l;l=l+32|0;f=e+16|0;i=e;ec(a,c[d>>2]|0);g=+h[b+8>>3];h[i>>3]=+h[b>>3];h[i+8>>3]=g;sr(a,60455,i);ec(a,c[d>>2]|0);g=+h[b+24>>3];h[f>>3]=+h[b+16>>3];h[f+8>>3]=g;sr(a,60477,f);ec(a,c[d>>2]|0);uc(a,c[b+32>>2]|0,c[b+36>>2]|0,d);l=e;return}function tc(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0.0,i=0.0,j=0;e=l;l=l+48|0;f=e+24|0;j=e;ec(a,c[d>>2]|0);g=+h[b+8>>3];i=+h[b+16>>3];h[j>>3]=+h[b>>3];h[j+8>>3]=g;h[j+16>>3]=i;sr(a,60354,j);ec(a,c[d>>2]|0);i=+h[b+32>>3];g=+h[b+40>>3];h[f>>3]=+h[b+24>>3];h[f+8>>3]=i;h[f+16>>3]=g;sr(a,60382,f);ec(a,c[d>>2]|0);uc(a,c[b+48>>2]|0,c[b+52>>2]|0,d);l=e;return}function uc(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,i=0,j=0,k=0,m=0,n=0,o=0.0;m=l;l=l+48|0;k=m+32|0;j=m+16|0;i=m+8|0;sr(a,60410,m);f=0;while(1){if((f|0)>=(b|0))break;if((f|0)>0)sr(a,86030,i);o=+g[d+(f<<3)>>2];n=mc(c[d+(f<<3)+4>>2]|0,e)|0;h[j>>3]=o;c[j+8>>2]=n;sr(a,60421,j);f=f+1|0}sr(a,60452,k);l=m;return}function vc(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;g=l;l=l+16|0;f=g;e=bb[c[a>>2]&31](a,b,512)|0;if(e){if((c[e+12>>2]|0)!=(d|0)){c[f>>2]=b;_l(0,60601,f)|0}}else{f=$I(1,16)|0;c[f+8>>2]=GL(b)|0;c[f+12>>2]=d;bb[c[a>>2]&31](a,f,1)|0}l=g;return}function wc(a,b,d){a=a|0;b=b|0;d=d|0;_I(c[b+8>>2]|0);_I(b);return}function xc(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;b=l;l=l+32|0;d=b+24|0;e=b+16|0;g=b;f=c[a+16>>2]|0;mr(a,61456)|0;j=c[c[a+12>>2]>>2]|0;i=c[j+4>>2]|0;h=c[j+8>>2]|0;c[g>>2]=c[j>>2];c[g+4>>2]=i;c[g+8>>2]=h;sr(a,61466,g);c[e>>2]=Dn(c[f+8>>2]|0)|0;sr(a,61501,e);c[d>>2]=O(c[a+168>>2]|0,c[a+164>>2]|0)|0;sr(a,61514,d);mr(a,61527)|0;mr(a,61537)|0;mr(a,61545)|0;mr(a,61553)|0;mr(a,61561)|0;mr(a,61569)|0;mr(a,61577)|0;mr(a,61581)|0;mr(a,61586)|0;l=b;return}function yc(a){a=a|0;mr(a,61437)|0;return}function zc(a){a=a|0;c[41896]=2;return}function Ac(a){a=a|0;c[41896]=1;return}function Bc(a){a=a|0;c[41896]=2;return}function Cc(a){a=a|0;c[41896]=0;return}function Dc(a){a=a|0;c[41896]=2;return}function Ec(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0.0,i=0.0,j=0,k=0.0,m=0,n=0,o=0,p=0,q=0.0,r=0.0,s=0;p=l;l=l+80|0;o=p;m=c[(c[b+16>>2]|0)+16>>2]|0;n=c[41896]|0;f=c[e+4>>2]|0;g=+h[b+352>>3]*+h[f+16>>3];i=c[b+360>>2]|0?1.5707963267948966:0.0;j=c[e>>2]|0;k=g*.3333333333333333*+((rJ(j)|0)>>>0);f=c[f+8>>2]|0;if(!f)f=-1;else f=c[f+20>>2]|0;s=a[e+48>>0]|0;r=+h[d>>3];q=+h[d+8>>3];e=Oc(j)|0;c[o>>2]=4;c[o+4>>2]=s<<24>>24==108?0:s<<24>>24==114?2:1;c[o+8>>2]=m;c[o+12>>2]=n;c[o+16>>2]=0;c[o+20>>2]=f;h[o+24>>3]=g;h[o+32>>3]=i;c[o+40>>2]=6;h[o+48>>3]=g;h[o+56>>3]=k;c[o+64>>2]=~~(r+(r>=0.0?.5:-.5));c[o+68>>2]=~~(q+(q+-72.0>=0.0?-71.5:-72.5));c[o+72>>2]=e;sr(b,61382,o);l=p;return}function Fc(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0;n=l;l=l+32|0;j=n;i=n+20|0;m=e+32|0;a:do switch(c[m>>2]|0){case 5:{f=0;while(1){g=c[12652+(f<<2)>>2]|0;if((f|0)==8)break a;h=c[e>>2]|0;if((a[g>>0]|0)==(a[h>>0]|0)?(xJ(g,h)|0)==0:0){k=10;break a}f=f+1|0}}case 1:{g=e+1|0;h=e+2|0;f=(Nc(i,d[e>>0]|0,d[g>>0]|0,d[h>>0]|0)|0)+32|0;if(!(c[i>>2]|0))k=10;else{o=d[e>>0]|0;i=d[g>>0]|0;k=d[h>>0]|0;c[j>>2]=0;c[j+4>>2]=f;c[j+8>>2]=o;c[j+12>>2]=i;c[j+16>>2]=k;sr(b,61325,j);k=10}break}default:ma(123205,60722,163,60753)}while(0);if((k|0)==10)c[e>>2]=f;c[m>>2]=6;l=n;return}function Gc(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0.0,i=0.0,j=0,k=0,m=0.0,n=0.0,o=0.0,p=0,q=0,r=0,s=0,t=0,u=0;e=l;l=l+112|0;f=e+8|0;u=e+104|0;t=e;k=c[a+16>>2]|0;s=~~+h[k+152>>3];r=c[k+16>>2]|0;q=c[k+56>>2]|0;p=c[41896]|0;Lc(k,u,t);n=+h[b>>3];k=~~(n+(n>=0.0?.5:-.5));m=+h[b+8>>3];j=~~(m+(m>=0.0?.5:-.5));i=+h[b+16>>3];n=i-n;g=+h[b+24>>3];m=g-m;b=c[u>>2]|0;o=+h[t>>3];c[f>>2]=1;c[f+4>>2]=1;c[f+8>>2]=b;c[f+12>>2]=s;c[f+16>>2]=r;c[f+20>>2]=q;c[f+24>>2]=p;c[f+28>>2]=0;c[f+32>>2]=d|0?20:-1;h[f+40>>3]=o;c[f+48>>2]=0;h[f+56>>3]=0.0;c[f+64>>2]=k;c[f+68>>2]=j;c[f+72>>2]=~~(n+(n>=0.0?.5:-.5));c[f+76>>2]=~~(m+(m>=0.0?.5:-.5));c[f+80>>2]=k;c[f+84>>2]=j;c[f+88>>2]=~~(i+(i>=0.0?.5:-.5));c[f+92>>2]=~~(g+(g>=0.0?.5:-.5));sr(a,61260,f);l=e;return}function Hc(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0.0,j=0,k=0,m=0,n=0,o=0,p=0,q=0;f=l;l=l+96|0;g=f+8|0;o=f+80|0;p=f;q=c[a+16>>2]|0;n=~~+h[q+152>>3];m=c[q+16>>2]|0;k=c[q+56>>2]|0;j=c[41896]|0;Lc(q,o,p);o=c[o>>2]|0;i=+h[p>>3];c[g>>2]=2;c[g+4>>2]=3;c[g+8>>2]=o;c[g+12>>2]=n;c[g+16>>2]=m;c[g+20>>2]=k;c[g+24>>2]=j;c[g+28>>2]=0;c[g+32>>2]=e|0?20:-1;h[g+40>>3]=i;c[g+48>>2]=0;c[g+52>>2]=0;c[g+56>>2]=0;c[g+60>>2]=0;c[g+64>>2]=0;c[g+68>>2]=d+1;sr(a,61164,g);Mc(a,b,d,1);l=f;return}function Ic(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0.0,E=0.0,F=0;C=l;l=l+192|0;B=C+176|0;z=C+168|0;A=C+104|0;y=C+96|0;i=C+88|0;u=C+180|0;v=C+80|0;w=C+16|0;x=C;f=a+16|0;e=c[f>>2]|0;q=~~+h[e+152>>3];r=c[e+16>>2]|0;s=c[41896]|0;if((d|0)<=3)ma(60715,60722,360,60742);t=ZI((d*140|0)+140|0)|0;Lc(e,u,v);if(!g){o=4;j=0;k=-1}else{o=5;j=c[(c[f>>2]|0)+56>>2]|0;k=20}E=+h[b>>3];n=w+48|0;h[n>>3]=E;D=+h[b+8>>3];h[w+56>>3]=D;c[i>>2]=~~(E+(E>=0.0?.5:-.5));c[i+4>>2]=~~(D+(D>=0.0?.5:-.5));m=x+8|0;e=t+(pL(t,73932,i)|0)|0;p=1;g=0;while(1){i=g+3|0;if((i|0)>=(d|0))break;c[w>>2]=c[n>>2];c[w+4>>2]=c[n+4>>2];c[w+8>>2]=c[n+8>>2];c[w+12>>2]=c[n+12>>2];f=1;while(1){if((f|0)==4){f=1;break}F=f+g|0;h[w+(f<<4)>>3]=+h[b+(F<<4)>>3];h[w+(f<<4)+8>>3]=+h[b+(F<<4)+8>>3];f=f+1|0}while(1){if((f|0)==7)break;PA(x,w,3,+(f|0)*.16666666666666666,0,0);D=+h[x>>3];E=+h[m>>3];c[y>>2]=~~(D+(D>=0.0?.5:-.5));c[y+4>>2]=~~(E+(E>=0.0?.5:-.5));f=f+1|0;e=e+(pL(e,73932,y)|0)|0}p=p+6|0;g=i}f=c[u>>2]|0;E=+h[v>>3];c[A>>2]=3;c[A+4>>2]=o;c[A+8>>2]=f;c[A+12>>2]=q;c[A+16>>2]=r;c[A+20>>2]=j;c[A+24>>2]=s;c[A+28>>2]=0;c[A+32>>2]=k;h[A+40>>3]=E;c[A+48>>2]=0;c[A+52>>2]=0;c[A+56>>2]=0;c[A+60>>2]=p;sr(a,61215,A);c[z>>2]=t;sr(a,73939,z);_I(t);f=p+-1|0;e=0;while(1){if((e|0)>=(p|0))break;c[B>>2]=((e|0)%(f|0)|0|0)!=0&1;sr(a,73944,B);e=e+1|0}mr(a,134901)|0;l=C;return}function Jc(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0.0,i=0,j=0,k=0,m=0,n=0,o=0;e=l;l=l+96|0;f=e+8|0;m=e+80|0;n=e;o=c[a+16>>2]|0;k=~~+h[o+152>>3];j=c[o+16>>2]|0;i=c[41896]|0;Lc(o,m,n);m=c[m>>2]|0;g=+h[n>>3];c[f>>2]=2;c[f+4>>2]=1;c[f+8>>2]=m;c[f+12>>2]=k;c[f+16>>2]=j;c[f+20>>2]=0;c[f+24>>2]=i;c[f+28>>2]=0;c[f+32>>2]=0;h[f+40>>3]=g;c[f+48>>2]=0;c[f+52>>2]=0;c[f+56>>2]=0;c[f+60>>2]=0;c[f+64>>2]=0;c[f+68>>2]=d;sr(a,61164,f);Mc(a,b,d,0);l=e;return}function Kc(a,b){a=a|0;b=b|0;var d=0,e=0;d=l;l=l+16|0;e=d;c[e>>2]=b;sr(a,61158,e);l=d;return}function Lc(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0;switch(c[a+144>>2]|0){case 1:{e=10.0;a=1;break}case 2:{e=10.0;a=2;break}default:{e=0.0;a=0}}c[b>>2]=a;h[d>>3]=e;return}function Mc(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0.0,m=0.0;j=l;l=l+16|0;i=j+8|0;g=j;f=0;while(1){if((f|0)>=(d|0))break;m=+h[b+(f<<4)>>3];k=+h[b+(f<<4)+8>>3];c[g>>2]=~~(m+(m>=0.0?.5:-.5));c[g+4>>2]=~~(k+(k>=0.0?.5:-.5));sr(a,73932,g);f=f+1|0}if(e|0){k=+h[b>>3];m=+h[b+8>>3];c[i>>2]=~~(k+(k>=0.0?.5:-.5));c[i+4>>2]=~~(m+(m>=0.0?.5:-.5));sr(a,73932,i)}mr(a,134901)|0;l=j;return}function Nc(a,d,e,f){a=a|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c[a>>2]=0;k=c[41897]|0;h=195075;g=0;i=-1;while(1){if((g|0)>=(k|0)){l=6;break}m=(b[170804+(g<<1)>>1]|0)-d|0;n=(b[171316+(g<<1)>>1]|0)-e|0;j=(b[171828+(g<<1)>>1]|0)-f|0;j=(O(n,n)|0)+(O(m,m)|0)+(O(j,j)|0)|0;if((j|0)<(h|0))if(!j)break;else{h=j;i=g}g=g+1|0}if((l|0)==6){c[41897]=k+1;if((k|0)==256)g=i;else{b[170804+(g<<1)>>1]=d;b[171316+(g<<1)>>1]=e;b[171828+(g<<1)>>1]=f;c[a>>2]=1}}return g|0}function Oc(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;i=l;l=l+16|0;h=i;d=c[41898]|0;if(!d){c[41899]=64;d=ZI(64)|0;c[41898]=d;e=0}else e=0;while(1){g=b+1|0;f=a[b>>0]|0;if(!(f<<24>>24))break;b=c[41899]|0;if((e|0)>(b+-8|0)){d=b<<1;c[41899]=d;d=aJ(c[41898]|0,d)|0;c[41898]=d;d=d+e|0}if(f<<24>>24<=-1){a[d>>0]=92;c[h>>2]=f&255;pL(d+1|0,74057,h)|0;b=g;d=d+4|0;e=e+4|0;continue}if(f<<24>>24==92){a[d>>0]=92;e=e+1|0;d=d+1|0}a[d>>0]=f;b=g;d=d+1|0;e=e+1|0}a[d>>0]=0;l=i;return c[41898]|0}function Pc(b){b=b|0;var d=0,e=0,f=0;e=c[b+16>>2]|0;switch(c[b+64>>2]|0){case 0:{mr(b,61053)|0;d=e+208|0;e=c[d>>2]|0;if(e|0?a[e>>0]|0:0){mr(b,61067)|0;mr(b,rw(c[d>>2]|0)|0)|0;mr(b,134901)|0}break}case 1:{d=e+208|0;f=c[d>>2]|0;if(f|0?a[f>>0]|0:0){mr(b,61067)|0;mr(b,rw(c[d>>2]|0)|0)|0;mr(b,87638)|0;mr(b,rw(Dn(c[e+8>>2]|0)|0)|0)|0;mr(b,134901)|0}break}case 3:{f=rw(Dn(c[e+8>>2]|0)|0)|0;mr(b,61076)|0;mr(b,f)|0;mr(b,61086)|0;mr(b,f)|0;mr(b,61041)|0;break}default:{}}return}function Qc(a){a=a|0;var b=0;b=c[a+16>>2]|0;switch(c[a+64>>2]|0){case 2:{Sc(a,c[b+264>>2]|0,c[b+272>>2]|0,c[b+268>>2]|0,c[b+208>>2]|0,c[b+228>>2]|0,c[b+244>>2]|0,c[b+212>>2]|0);break}case 3:{Sc(a,c[b+264>>2]|0,c[b+272>>2]|0,c[b+268>>2]|0,c[b+208>>2]|0,c[b+228>>2]|0,c[b+244>>2]|0,c[b+212>>2]|0);mr(a,61045)|0;break}default:{}}return}function Rc(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0;g=c[a+16>>2]|0;Sc(a,c[g+264>>2]|0,c[g+272>>2]|0,c[g+268>>2]|0,b,d,e,f);return}function Sc(b,d,e,f,g,i,j,k){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;i=i|0;j=j|0;k=k|0;var m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0.0;y=l;l=l+128|0;x=y+120|0;u=y+112|0;t=y+96|0;s=y+80|0;r=y+56|0;w=y+48|0;q=y+40|0;v=y+24|0;p=y;a:do if((e|0)!=0&(f|0)!=0){m=f+10|0;if((c[41900]|0)<(f|0)){c[41900]=m;o=aJ(c[41901]|0,m<<3)|0;c[41901]=o}else o=c[41901]|0;m=0;while(1){if((m|0)>=(f|0))break;z=+h[e+(m<<4)>>3];c[o+(m<<3)>>2]=~~(z+(z>=0.0?.5:-.5));z=+h[e+(m<<4)+8>>3];c[o+(m<<3)+4>>2]=~~(z+(z>=0.0?.5:-.5));m=m+1|0}n=b+64|0;m=c[n>>2]|0;e=(g|0)!=0;if(e&(m|0)==0){if(!(a[g>>0]|0))break;switch(d|0){case 0:{v=c[o>>2]|0;w=c[o+12>>2]|0;x=c[o+8>>2]|0;f=c[o+4>>2]|0;c[p>>2]=g;c[p+4>>2]=v;c[p+8>>2]=w;c[p+12>>2]=x;c[p+16>>2]=f;sr(b,60787,p);break a}case 1:{w=c[o>>2]|0;x=c[o+4>>2]|0;f=(c[o+8>>2]|0)-w|0;c[v>>2]=g;c[v+4>>2]=w;c[v+8>>2]=x;c[v+12>>2]=f;sr(b,60808,v);break a}case 2:{c[q>>2]=g;sr(b,60828,q);m=0;while(1){if((m|0)>=(f|0))break;v=c[41901]|0;x=c[v+(m<<3)+4>>2]|0;c[w>>2]=c[v+(m<<3)>>2];c[w+4>>2]=x;sr(b,60836,w);m=m+1|0}mr(b,134901)|0;break a}default:ma(123205,60843,63,60863)}}if(e&(m|0)==1){if(!(a[g>>0]|0))break;if(!d){w=c[o+12>>2]|0;x=c[o+8>>2]|0;f=c[o+4>>2]|0;c[r>>2]=c[o>>2];c[r+4>>2]=w;c[r+8>>2]=x;c[r+12>>2]=f;c[r+16>>2]=g;c[r+20>>2]=i;sr(b,60880,r);break}else ma(123205,60843,75,60863)}if((m&-2|0)==2){switch(d|0){case 1:{mr(b,60913)|0;break}case 0:{mr(b,60934)|0;break}case 2:{mr(b,60953)|0;break}default:ma(123205,60843,91,60863)}if(k|0?a[k>>0]|0:0){mr(b,66433)|0;mr(b,uw(k)|0)|0;mr(b,83714)|0}if(e?a[g>>0]|0:0){mr(b,60972)|0;mr(b,uw(g)|0)|0;mr(b,83714)|0}if(j|0?a[j>>0]|0:0){mr(b,67392)|0;mr(b,rw(j)|0)|0;mr(b,83714)|0}if(i|0?a[i>>0]|0:0){mr(b,60980)|0;mr(b,rw(i)|0)|0;mr(b,83714)|0}mr(b,60989)|0;mr(b,60997)|0;b:do switch(d|0){case 1:{f=c[41901]|0;w=c[f>>2]|0;x=c[f+4>>2]|0;f=(c[f+8>>2]|0)-w|0;c[s>>2]=w;c[s+4>>2]=x;c[s+8>>2]=f;sr(b,61007,s);break}case 0:{v=c[41901]|0;w=c[v+12>>2]|0;x=c[v+8>>2]|0;f=c[v+4>>2]|0;c[t>>2]=c[v>>2];c[t+4>>2]=w;c[t+8>>2]=x;c[t+12>>2]=f;sr(b,61016,t);break}case 2:{w=c[41901]|0;m=c[w+4>>2]|0;c[u>>2]=c[w>>2];c[u+4>>2]=m;sr(b,61028,u);m=1;while(1){if((m|0)>=(f|0))break b;v=c[41901]|0;w=c[v+(m<<3)+4>>2]|0;c[x>>2]=c[v+(m<<3)>>2];c[x+4>>2]=w;sr(b,61034,x);m=m+1|0}}default:{}}while(0);if((c[n>>2]|0)==3){mr(b,66257)|0;break}else{mr(b,61041)|0;break}}}while(0);l=y;return}function Tc(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;b=l;l=l+32|0;d=b+24|0;e=b+16|0;g=b;f=c[a+16>>2]|0;mr(a,61456)|0;j=c[c[a+12>>2]>>2]|0;i=c[j+4>>2]|0;h=c[j+8>>2]|0;c[g>>2]=c[j>>2];c[g+4>>2]=i;c[g+8>>2]=h;sr(a,61466,g);c[e>>2]=Dn(c[f+8>>2]|0)|0;sr(a,61501,e);c[d>>2]=O(c[a+168>>2]|0,c[a+164>>2]|0)|0;sr(a,61514,d);mr(a,61527)|0;mr(a,61537)|0;mr(a,61545)|0;mr(a,61553)|0;mr(a,61561)|0;mr(a,61569)|0;mr(a,61577)|0;mr(a,61581)|0;mr(a,61586)|0;l=b;return}function Uc(a){a=a|0;mr(a,61437)|0;return}function Vc(a){a=a|0;c[41902]=2;return}function Wc(a){a=a|0;c[41902]=1;return}function Xc(a){a=a|0;c[41902]=2;return}function Yc(a){a=a|0;c[41902]=0;return}function Zc(a){a=a|0;c[41902]=2;return}function _c(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0.0,i=0.0,j=0,k=0,m=0,n=0,o=0.0,p=0.0,q=0;n=l;l=l+80|0;m=n;j=c[(c[b+16>>2]|0)+16>>2]|0;k=c[41902]|0;f=c[e+4>>2]|0;g=+h[b+352>>3]*+h[f+16>>3];i=c[b+360>>2]|0?1.5707963267948966:0.0;f=c[f+8>>2]|0;if(!f)f=-1;else f=c[f+20>>2]|0;q=a[e+48>>0]|0;p=+h[d>>3];o=+h[d+8>>3];e=id(c[e>>2]|0)|0;c[m>>2]=4;c[m+4>>2]=q<<24>>24==108?0:q<<24>>24==114?2:1;c[m+8>>2]=j;c[m+12>>2]=k;c[m+16>>2]=0;c[m+20>>2]=f;h[m+24>>3]=g;h[m+32>>3]=i;c[m+40>>2]=4;h[m+48>>3]=0.0;h[m+56>>3]=0.0;c[m+64>>2]=~~(p+(p>=0.0?.5:-.5));c[m+68>>2]=~~(o+(o>=0.0?.5:-.5));c[m+72>>2]=e;sr(b,61382,m);l=n;return}function $c(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0;n=l;l=l+32|0;j=n;i=n+20|0;m=e+32|0;a:do switch(c[m>>2]|0){case 5:{f=0;while(1){g=c[12652+(f<<2)>>2]|0;if((f|0)==8)break a;h=c[e>>2]|0;if((a[g>>0]|0)==(a[h>>0]|0)?(xJ(g,h)|0)==0:0){k=10;break a}f=f+1|0}}case 1:{g=e+1|0;h=e+2|0;f=(hd(i,d[e>>0]|0,d[g>>0]|0,d[h>>0]|0)|0)+32|0;if(!(c[i>>2]|0))k=10;else{o=d[e>>0]|0;i=d[g>>0]|0;k=d[h>>0]|0;c[j>>2]=0;c[j+4>>2]=f;c[j+8>>2]=o;c[j+12>>2]=i;c[j+16>>2]=k;sr(b,61325,j);k=10}break}case 0:{f=0;k=10;break}default:ma(123205,61346,168,61365)}while(0);if((k|0)==10)c[e>>2]=f;c[m>>2]=6;l=n;return}function ad(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0.0,i=0.0,j=0,k=0,m=0.0,n=0.0,o=0.0,p=0,q=0,r=0,s=0,t=0,u=0;e=l;l=l+112|0;f=e+8|0;u=e+104|0;t=e;k=c[a+16>>2]|0;s=~~+h[k+152>>3];r=c[k+16>>2]|0;q=c[k+56>>2]|0;p=c[41902]|0;fd(k,u,t);n=+h[b>>3];k=~~(n+(n>=0.0?.5:-.5));m=+h[b+8>>3];j=~~(m+(m>=0.0?.5:-.5));i=+h[b+16>>3];n=i-n;g=+h[b+24>>3];m=g-m;b=c[u>>2]|0;o=+h[t>>3];c[f>>2]=1;c[f+4>>2]=1;c[f+8>>2]=b;c[f+12>>2]=s;c[f+16>>2]=r;c[f+20>>2]=q;c[f+24>>2]=p;c[f+28>>2]=0;c[f+32>>2]=d|0?20:-1;h[f+40>>3]=o;c[f+48>>2]=0;h[f+56>>3]=0.0;c[f+64>>2]=k;c[f+68>>2]=j;c[f+72>>2]=~~(n+(n>=0.0?.5:-.5));c[f+76>>2]=~~(m+(m>=0.0?.5:-.5));c[f+80>>2]=k;c[f+84>>2]=j;c[f+88>>2]=~~(i+(i>=0.0?.5:-.5));c[f+92>>2]=~~(g+(g>=0.0?.5:-.5));sr(a,61260,f);l=e;return}function bd(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0.0,j=0,k=0,m=0,n=0,o=0,p=0,q=0;f=l;l=l+96|0;g=f+8|0;o=f+80|0;p=f;q=c[a+16>>2]|0;n=~~+h[q+152>>3];m=c[q+16>>2]|0;k=c[q+56>>2]|0;j=c[41902]|0;fd(q,o,p);o=c[o>>2]|0;i=+h[p>>3];c[g>>2]=2;c[g+4>>2]=3;c[g+8>>2]=o;c[g+12>>2]=n;c[g+16>>2]=m;c[g+20>>2]=k;c[g+24>>2]=j;c[g+28>>2]=0;c[g+32>>2]=e|0?20:-1;h[g+40>>3]=i;c[g+48>>2]=0;c[g+52>>2]=0;c[g+56>>2]=0;c[g+60>>2]=0;c[g+64>>2]=0;c[g+68>>2]=d+1;sr(a,61164,g);gd(a,b,d,1);l=f;return}function cd(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0.0,E=0.0,F=0;C=l;l=l+192|0;B=C+176|0;z=C+168|0;A=C+104|0;y=C+96|0;f=C+88|0;u=C+180|0;v=C+80|0;w=C+16|0;x=C;e=a+16|0;p=c[e>>2]|0;q=~~+h[p+152>>3];r=c[p+16>>2]|0;s=c[41902]|0;t=ZI((d*140|0)+140|0)|0;fd(p,u,v);if(!g){o=4;j=0;k=-1}else{o=5;j=c[(c[e>>2]|0)+56>>2]|0;k=20}E=+h[b>>3];n=w+48|0;h[n>>3]=E;D=+h[b+8>>3];h[w+56>>3]=D;c[f>>2]=~~(E+(E>=0.0?.5:-.5));c[f+4>>2]=~~(D+(D>=0.0?.5:-.5));m=x+8|0;e=t+(pL(t,73932,f)|0)|0;p=1;g=0;while(1){i=g+3|0;if((i|0)>=(d|0))break;c[w>>2]=c[n>>2];c[w+4>>2]=c[n+4>>2];c[w+8>>2]=c[n+8>>2];c[w+12>>2]=c[n+12>>2];f=1;while(1){if((f|0)==4){f=1;break}F=f+g|0;h[w+(f<<4)>>3]=+h[b+(F<<4)>>3];h[w+(f<<4)+8>>3]=+h[b+(F<<4)+8>>3];f=f+1|0}while(1){if((f|0)==7)break;PA(x,w,3,+(f|0)*.16666666666666666,0,0);D=+h[x>>3];E=+h[m>>3];c[y>>2]=~~(D+(D>=0.0?.5:-.5));c[y+4>>2]=~~(E+(E>=0.0?.5:-.5));f=f+1|0;e=e+(pL(e,73932,y)|0)|0}p=p+6|0;g=i}f=c[u>>2]|0;E=+h[v>>3];c[A>>2]=3;c[A+4>>2]=o;c[A+8>>2]=f;c[A+12>>2]=q;c[A+16>>2]=r;c[A+20>>2]=j;c[A+24>>2]=s;c[A+28>>2]=0;c[A+32>>2]=k;h[A+40>>3]=E;c[A+48>>2]=0;c[A+52>>2]=0;c[A+56>>2]=0;c[A+60>>2]=p;sr(a,61215,A);c[z>>2]=t;sr(a,73939,z);_I(t);f=p+-1|0;e=0;while(1){if((e|0)>=(p|0))break;c[B>>2]=((e|0)%(f|0)|0|0)!=0&1;sr(a,73944,B);e=e+1|0}mr(a,134901)|0;l=C;return}function dd(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0.0,i=0,j=0,k=0,m=0,n=0,o=0;e=l;l=l+96|0;f=e+8|0;m=e+80|0;n=e;o=c[a+16>>2]|0;k=~~+h[o+152>>3];j=c[o+16>>2]|0;i=c[41902]|0;fd(o,m,n);m=c[m>>2]|0;g=+h[n>>3];c[f>>2]=2;c[f+4>>2]=1;c[f+8>>2]=m;c[f+12>>2]=k;c[f+16>>2]=j;c[f+20>>2]=0;c[f+24>>2]=i;c[f+28>>2]=0;c[f+32>>2]=0;h[f+40>>3]=g;c[f+48>>2]=0;c[f+52>>2]=0;c[f+56>>2]=0;c[f+60>>2]=0;c[f+64>>2]=0;c[f+68>>2]=d;sr(a,61164,f);gd(a,b,d,0);l=e;return}function ed(a,b){a=a|0;b=b|0;var d=0,e=0;d=l;l=l+16|0;e=d;c[e>>2]=b;sr(a,61158,e);l=d;return}function fd(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0;switch(c[a+144>>2]|0){case 1:{e=10.0;a=1;break}case 2:{e=10.0;a=2;break}default:{e=0.0;a=0}}c[b>>2]=a;h[d>>3]=e;return}function gd(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0.0,m=0.0;j=l;l=l+16|0;i=j+8|0;g=j;f=0;while(1){if((f|0)>=(d|0))break;m=+h[b+(f<<4)>>3];k=+h[b+(f<<4)+8>>3];c[g>>2]=~~(m+(m>=0.0?.5:-.5));c[g+4>>2]=~~(k+(k>=0.0?.5:-.5));sr(a,73932,g);f=f+1|0}if(e|0){k=+h[b>>3];m=+h[b+8>>3];c[i>>2]=~~(k+(k>=0.0?.5:-.5));c[i+4>>2]=~~(m+(m>=0.0?.5:-.5));sr(a,73932,i)}mr(a,134901)|0;l=j;return}function hd(a,d,e,f){a=a|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c[a>>2]=0;k=c[41903]|0;h=195075;g=0;i=-1;while(1){if((g|0)>=(k|0)){l=6;break}m=(b[172340+(g<<1)>>1]|0)-d|0;n=(b[172852+(g<<1)>>1]|0)-e|0;j=(b[173364+(g<<1)>>1]|0)-f|0;j=(O(n,n)|0)+(O(m,m)|0)+(O(j,j)|0)|0;if((j|0)<(h|0))if(!j)break;else{h=j;i=g}g=g+1|0}if((l|0)==6){c[41903]=k+1;if((k|0)==256)g=i;else{b[172340+(g<<1)>>1]=d;b[172852+(g<<1)>>1]=e;b[173364+(g<<1)>>1]=f;c[a>>2]=1}}return g|0}function id(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;i=l;l=l+16|0;h=i;d=c[41904]|0;if(!d){c[41905]=64;d=ZI(64)|0;c[41904]=d;e=0}else e=0;while(1){g=b+1|0;f=a[b>>0]|0;if(!(f<<24>>24))break;b=c[41905]|0;if((e|0)>(b+-8|0)){d=b<<1;c[41905]=d;d=aJ(c[41904]|0,d)|0;c[41904]=d;d=d+e|0}if(f<<24>>24<=-1){a[d>>0]=92;c[h>>2]=f&255;pL(d+1|0,74057,h)|0;b=g;d=d+4|0;e=e+4|0;continue}if(f<<24>>24==92){a[d>>0]=92;e=e+1|0;d=d+1|0}a[d>>0]=f;b=g;d=d+1|0;e=e+1|0}a[d>>0]=0;l=i;return c[41904]|0}function jd(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;d=l;l=l+16|0;b=d;mr(a,66165)|0;if((c[a+64>>2]|0)==2)mr(a,66180)|0;else mr(a,134901)|0;g=c[c[a+12>>2]>>2]|0;f=c[g+4>>2]|0;e=c[g+8>>2]|0;c[b>>2]=c[g>>2];c[b+4>>2]=f;c[b+8>>2]=e;sr(a,66191,b);l=d;return}function kd(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;g=l;l=l+32|0;f=g+8|0;e=g;mr(a,66119)|0;d=a+64|0;b=a+12|0;if((c[d>>2]|0)!=2){c[e>>2]=c[(c[b>>2]|0)+28>>2];sr(a,66130,e)}if((c[(c[b>>2]|0)+20>>2]|0)==0?(c[d>>2]|0)!=2:0){b=c[a+476>>2]|0;d=c[a+480>>2]|0;e=c[a+484>>2]|0;c[f>>2]=c[a+472>>2];c[f+4>>2]=b;c[f+8>>2]=d;c[f+12>>2]=e;sr(a,62499,f)}mr(a,66145)|0;mr(a,66158)|0;l=g;return}function ld(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0;k=l;l=l+32|0;j=k+24|0;f=k+8|0;i=k;g=c[b+16>>2]|0;a[173892]=0;e=b+12|0;h=g+8|0;if(!(c[(c[e>>2]|0)+28>>2]|0)){c[i>>2]=Dn(c[h>>2]|0)|0;sr(b,62430,i);d=b+64|0;if((c[d>>2]|0)==2)mr(b,62463)|0;else mr(b,62445)|0;do if(!(c[(c[e>>2]|0)+20>>2]|0))if((c[d>>2]|0)==2){n=c[b+460>>2]|0;m=c[b+464>>2]|0;d=c[b+468>>2]|0;c[f>>2]=c[b+456>>2];c[f+4>>2]=n;c[f+8>>2]=m;c[f+12>>2]=d;sr(b,62499,f);break}else{mr(b,62475)|0;break}while(0);mr(b,62529)|0;ey(b,c[(c[e>>2]|0)+24>>2]|0,12928);gy(b);d=c[(c[e>>2]|0)+20>>2]|0;if(d|0){c[i>>2]=c[d>>2];c[i+4>>2]=0;ey(b,0,i)}}c[41906]=(a[(c[(c[h>>2]|0)+16>>2]|0)+115>>0]|0)==1?1:-1;if(!(a[173892]|0)){mr(b,62549)|0;a[173892]=1}d=c[g+208>>2]|0;if(d|0){c[j>>2]=hy(d,c[41906]|0)|0;sr(b,62562,j)}l=k;return}function md(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;b=l;l=l+16|0;f=b;c[f>>2]=d;c[f+4>>2]=e;sr(a,62414,f);l=b;return}function nd(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0.0,v=0.0,w=0.0;s=l;l=l+144|0;r=s+128|0;q=s+112|0;p=s+72|0;o=s+56|0;n=s+40|0;m=s+32|0;e=s+24|0;b=s+8|0;d=s;f=c[a+456>>2]|0;j=c[a+460>>2]|0;g=c[a+464>>2]|0;i=c[a+468>>2]|0;k=a+12|0;t=(c[(c[k>>2]|0)+28>>2]|0)+1|0;c[d>>2]=t;c[d+4>>2]=t;sr(a,62041,d);if(!(c[(c[k>>2]|0)+20>>2]|0)){c[b>>2]=f;c[b+4>>2]=j;c[b+8>>2]=g;c[b+12>>2]=i;sr(a,62058,b)}d=a+360|0;c[e>>2]=c[d>>2]|0?62092:62102;sr(a,62111,e);b=a+64|0;if((c[b>>2]|0)==1){c[m>>2]=g;c[m+4>>2]=i;sr(a,62136,m)}m=c[a+200>>2]|0;t=c[a+204>>2]|0;c[n>>2]=c[a+196>>2];c[n+4>>2]=m;c[n+8>>2]=t;sr(a,62175,n);if(!(c[(c[k>>2]|0)+20>>2]|0)){c[o>>2]=f;c[o+4>>2]=j;c[o+8>>2]=g-f;c[o+12>>2]=i-j;sr(a,62195,o)}w=+h[a+496>>3];t=c[d>>2]|0;v=+h[a+504>>3];u=+h[a+512>>3];h[p>>3]=+h[a+488>>3];h[p+8>>3]=w;c[p+16>>2]=t;h[p+24>>3]=v;h[p+32>>3]=u;sr(a,62235,p);if((c[b>>2]|0)==1){if((g|0)>14399|(i|0)>14399){t=c[(c[k>>2]|0)+16>>2]|0;c[q>>2]=g;c[q+4>>2]=i;c[q+8>>2]=14400;hb[t&31](62278,q)}c[r>>2]=f;c[r+4>>2]=j;c[r+8>>2]=g;c[r+12>>2]=i;sr(a,62373,r)}l=s;return}function od(a){a=a|0;var b=0,d=0,e=0;e=l;l=l+16|0;d=e;b=a+12|0;if(c[(c[b>>2]|0)+20>>2]|0){mr(a,61965)|0;ey(a,0,(c[(c[b>>2]|0)+20>>2]|0)+4|0)}mr(a,61982)|0;mr(a,62009)|0;c[d>>2]=c[(c[b>>2]|0)+28>>2];sr(a,62024,d);l=e;return}function pd(a){a=a|0;var b=0,d=0;b=l;l=l+16|0;d=b;c[d>>2]=Dn(c[(c[a+16>>2]|0)+8>>2]|0)|0;sr(a,61958,d);mr(a,61951)|0;l=b;return}function qd(a){a=a|0;mr(a,77394)|0;return}function rd(a){a=a|0;mr(a,61951)|0;return}function sd(a){a=a|0;mr(a,77394)|0;return}function td(a){a=a|0;mr(a,61951)|0;return}function ud(a){a=a|0;mr(a,77394)|0;return}function vd(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0;e=l;l=l+16|0;d=e;if(b|0?(g=(c[a+16>>2]|0)+272|0,c[g>>2]|0):0){mr(a,61847)|0;wr(a,c[g>>2]|0,2);mr(a,61858)|0;c[d>>2]=hy(b,c[41906]|0)|0;sr(a,61862,d)}l=e;return}function wd(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0.0,i=0,j=0,k=0,m=0,n=0;m=l;l=l+32|0;j=m+8|0;k=m;f=c[b+16>>2]|0;if(!(+h[f+40>>3]<.5)){Dd(b,f+16|0);i=e+4|0;tr(b,+h[(c[i>>2]|0)+16>>3]);c[j>>2]=c[c[i>>2]>>2];sr(b,61806,j);i=hy(c[e>>2]|0,c[41906]|0)|0;switch(a[e+48>>0]|0){case 114:{n=e+32|0;f=n;g=+h[n>>3];break}case 108:{f=e+32|0;g=0.0;break}default:{n=e+32|0;f=n;g=+h[n>>3]*.5}}h[d>>3]=+h[d>>3]-g;n=d+8|0;h[n>>3]=+h[n>>3]+ +h[e+24>>3];c[j>>2]=c[d>>2];c[j+4>>2]=c[d+4>>2];c[j+8>>2]=c[d+8>>2];c[j+12>>2]=c[d+12>>2];vr(b,j);mr(b,61821)|0;tr(b,+h[f>>3]);c[k>>2]=i;sr(b,61830,k)}l=m;return}function xd(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;g=l;l=l+32|0;f=g;c[f>>2]=c[b>>2];c[f+4>>2]=c[b+4>>2];c[f+8>>2]=c[b+8>>2];c[f+12>>2]=c[b+12>>2];h[f+16>>3]=+h[b+16>>3]-+h[b>>3];h[f+24>>3]=+h[b+24>>3]-+h[b+8>>3];b=a+16|0;if(d|0?(e=c[b>>2]|0,+h[e+80>>3]>.5):0){Dd(a,e+56|0);wr(a,f,2);mr(a,61764)|0}if(+h[(c[b>>2]|0)+40>>3]>.5){Ed(a);Dd(a,(c[b>>2]|0)+16|0);wr(a,f,2);mr(a,61784)|0}l=g;return}function yd(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0;j=l;l=l+16|0;i=j;g=a+16|0;if(e|0?(f=c[g>>2]|0,+h[f+80>>3]>.5):0){Dd(a,f+56|0);mr(a,61685)|0;c[i>>2]=c[b>>2];c[i+4>>2]=c[b+4>>2];c[i+8>>2]=c[b+8>>2];c[i+12>>2]=c[b+12>>2];vr(a,i);mr(a,61694)|0;e=1;while(1){if((e|0)>=(d|0))break;f=b+(e<<4)|0;c[i>>2]=c[f>>2];c[i+4>>2]=c[f+4>>2];c[i+8>>2]=c[f+8>>2];c[i+12>>2]=c[f+12>>2];vr(a,i);mr(a,61703)|0;e=e+1|0}mr(a,61730)|0}if(+h[(c[g>>2]|0)+40>>3]>.5){Ed(a);Dd(a,(c[g>>2]|0)+16|0);mr(a,61685)|0;c[i>>2]=c[b>>2];c[i+4>>2]=c[b+4>>2];c[i+8>>2]=c[b+8>>2];c[i+12>>2]=c[b+12>>2];vr(a,i);mr(a,61694)|0;e=1;while(1){if((e|0)>=(d|0))break;g=b+(e<<4)|0;c[i>>2]=c[g>>2];c[i+4>>2]=c[g+4>>2];c[i+8>>2]=c[g+8>>2];c[i+12>>2]=c[g+12>>2];vr(a,i);mr(a,61703)|0;e=e+1|0}mr(a,61746)|0}l=j;return}function zd(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var i=0,j=0,k=0;k=l;l=l+16|0;f=k;i=a+16|0;if(g|0?(j=c[i>>2]|0,+h[j+80>>3]>.5):0){Dd(a,j+56|0);mr(a,61685)|0;c[f>>2]=c[b>>2];c[f+4>>2]=c[b+4>>2];c[f+8>>2]=c[b+8>>2];c[f+12>>2]=c[b+12>>2];vr(a,f);mr(a,61694)|0;e=1;while(1){if((e|0)>=(d|0))break;wr(a,b+(e<<4)|0,3);mr(a,61720)|0;e=e+3|0}mr(a,61730)|0}if(+h[(c[i>>2]|0)+40>>3]>.5){Ed(a);Dd(a,(c[i>>2]|0)+16|0);mr(a,61685)|0;c[f>>2]=c[b>>2];c[f+4>>2]=c[b+4>>2];c[f+8>>2]=c[b+8>>2];c[f+12>>2]=c[b+12>>2];vr(a,f);mr(a,61694)|0;e=1;while(1){if((e|0)>=(d|0))break;wr(a,b+(e<<4)|0,3);mr(a,61720)|0;e=e+3|0}mr(a,61712)|0}l=k;return}function Ad(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,i=0;g=l;l=l+16|0;f=g;e=a+16|0;if(+h[(c[e>>2]|0)+40>>3]>.5){Ed(a);Dd(a,(c[e>>2]|0)+16|0);mr(a,61685)|0;c[f>>2]=c[b>>2];c[f+4>>2]=c[b+4>>2];c[f+8>>2]=c[b+8>>2];c[f+12>>2]=c[b+12>>2];vr(a,f);mr(a,61694)|0;e=1;while(1){if((e|0)>=(d|0))break;i=b+(e<<4)|0;c[f>>2]=c[i>>2];c[f+4>>2]=c[i+4>>2];c[f+8>>2]=c[i+8>>2];c[f+12>>2]=c[i+12>>2];vr(a,f);mr(a,61703)|0;e=e+1|0}mr(a,61712)|0}l=g;return}function Bd(a,b){a=a|0;b=b|0;mr(a,61682)|0;mr(a,b)|0;mr(a,134901)|0;return}function Cd(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,i=0,j=0,k=0,m=0,n=0;n=l;l=l+32|0;g=n+16|0;m=n+8|0;k=n;i=a+16|0;if(f|0?(j=c[i>>2]|0,+h[j+80>>3]>.5):0){Dd(a,j+56|0);mr(a,77289)|0;wr(a,d,e);mr(a,87638)|0;c[g>>2]=c[d>>2];c[g+4>>2]=c[d+4>>2];c[g+8>>2]=c[d+8>>2];c[g+12>>2]=c[d+12>>2];vr(a,g);c[k>>2]=e;c[k+4>>2]=b;sr(a,61599,k)}if(+h[(c[i>>2]|0)+40>>3]>.5){Ed(a);Dd(a,(c[i>>2]|0)+16|0);mr(a,77289)|0;wr(a,d,e);mr(a,87638)|0;c[g>>2]=c[d>>2];c[g+4>>2]=c[d+4>>2];c[g+8>>2]=c[d+8>>2];c[g+12>>2]=c[d+12>>2];vr(a,g);c[m>>2]=e;c[m+4>>2]=b;sr(a,61615,m)}l=n;return}function Dd(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0.0,i=0.0;f=l;l=l+32|0;e=f;if(b|0){switch(c[(c[a+16>>2]|0)+4>>2]|0){case 1:case 0:{d=96286;break}case 2:{d=96273;break}case 3:{d=96237;break}default:d=61651}i=+h[b+8>>3];g=+h[b+16>>3];h[e>>3]=+h[b>>3];h[e+8>>3]=i;h[e+16>>3]=g;c[e+24>>2]=d;sr(a,61658,e)}l=f;return}function Ed(b){b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0,k=0,m=0;m=l;l=l+16|0;k=m+8|0;j=m;g=b+16|0;i=c[g>>2]|0;d=c[i+160>>2]|0;tr(b,+h[i+152>>3]);mr(b,61632)|0;while(1){if(!d)break;i=d+4|0;f=c[d>>2]|0;if(!f)break;if(!(xJ(f,95910)|0)){d=i;continue}else e=f;while(1){d=e+1|0;if(!(a[e>>0]|0))break;else e=d}a:while(1){if(!(a[d>>0]|0))break;c[j>>2]=d;sr(b,61647,j);while(1){e=d+1|0;if(!(a[d>>0]|0)){d=e;continue a}else d=e}}if(!(xJ(f,119127)|0))h[(c[g>>2]|0)+152>>3]=0.0;c[k>>2]=f;sr(b,81633,k);d=i}l=m;return}function Fd(b){b=b|0;var d=0;mr(b,67671)|0;d=Im(c[(c[b>>2]|0)+168>>2]|0,67727)|0;if(d|0?a[d>>0]|0:0){mr(b,67738)|0;mr(b,d)|0;mr(b,67762)|0}mr(b,67783)|0;mr(b,67831)|0;mr(b,67885)|0;d=b+12|0;mr(b,rw(c[c[c[d>>2]>>2]>>2]|0)|0)|0;mr(b,71014)|0;mr(b,rw(c[(c[c[d>>2]>>2]|0)+4>>2]|0)|0)|0;mr(b,71024)|0;mr(b,rw(c[(c[c[d>>2]>>2]|0)+8>>2]|0)|0)|0;mr(b,68267)|0;mr(b,68291)|0;return}function Gd(b){b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0.0,k=0.0,m=0.0;i=l;l=l+48|0;g=i+16|0;f=i+8|0;e=i;d=c[b+16>>2]|0;mr(b,67506)|0;d=d+8|0;if(a[(Dn(c[d>>2]|0)|0)>>0]|0){mr(b,68230)|0;mr(b,rw(Dn(c[d>>2]|0)|0)|0)|0}c[e>>2]=O(c[b+168>>2]|0,c[b+164>>2]|0)|0;sr(b,67511,e);e=c[b+452>>2]|0;c[f>>2]=c[b+448>>2];c[f+4>>2]=e;sr(b,67527,f);m=+h[b+392>>3];k=+h[b+400>>3];j=+h[b+408>>3];h[g>>3]=+h[b+384>>3];h[g+8>>3]=m;h[g+16>>3]=k;h[g+24>>3]=j;sr(b,67560,g);mr(b,67591)|0;mr(b,67627)|0;mr(b,69221)|0;l=i;return}function Hd(a){a=a|0;mr(a,67498)|0;return}function Id(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;de(a,b,0,86583,c[(c[a+16>>2]|0)+8>>2]|0);mr(a,69221)|0;return}function Jd(a){a=a|0;mr(a,67346)|0;return}function Kd(b){b=b|0;var d=0,e=0,f=0,g=0;e=l;l=l+16|0;f=e;g=c[b+16>>2]|0;d=g+8|0;de(b,c[g+212>>2]|0,0,96286,c[d>>2]|0);mr(b,67450)|0;tr(b,+h[b+488>>3]);mr(b,87638)|0;tr(b,+h[b+496>>3]);c[f>>2]=0-(c[b+360>>2]|0);sr(b,67469,f);tr(b,+h[b+504>>3]);mr(b,87638)|0;tr(b,-+h[b+512>>3]);mr(b,67493)|0;if(a[(Dn(c[d>>2]|0)|0)>>0]|0){mr(b,67402)|0;mr(b,rw(Dn(c[d>>2]|0)|0)|0)|0;mr(b,67410)|0}l=e;return}function Ld(a){a=a|0;mr(a,67346)|0;return}function Md(a){a=a|0;var b=0,d=0;d=c[a+16>>2]|0;b=d+8|0;de(a,c[d+212>>2]|0,0,93039,c[b>>2]|0);mr(a,69221)|0;mr(a,67402)|0;mr(a,rw(Dn(c[b>>2]|0)|0)|0)|0;mr(a,67410)|0;return}function Nd(a){a=a|0;mr(a,67346)|0;return}function Od(a){a=a|0;var b=0,d=0,e=0;d=c[a+16>>2]|0;b=c[a+160>>2]|0;if((b|0)>1)b=c[(c[(c[a>>2]|0)+308>>2]|0)+(b<<2)>>2]|0;else b=0;e=d+8|0;de(a,c[d+212>>2]|0,b,96273,c[e>>2]|0);mr(a,69221)|0;mr(a,67402)|0;mr(a,rw(Dn(c[e>>2]|0)|0)|0)|0;mr(a,67410)|0;return}function Pd(a){a=a|0;mr(a,67346)|0;return}function Qd(a){a=a|0;var b=0,d=0;d=c[a+16>>2]|0;b=d+8|0;de(a,c[d+212>>2]|0,0,96237,c[b>>2]|0);mr(a,69221)|0;mr(a,67402)|0;b=qw(87129,c[b>>2]|0)|0;mr(a,rw(b)|0)|0;_I(b);mr(a,67410)|0;return}function Rd(a){a=a|0;mr(a,67346)|0;return}function Sd(b,c,d,e,f){b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;mr(b,67352)|0;if(f|0){mr(b,67355)|0;mr(b,rw(f)|0)|0;mr(b,83714)|0}mr(b,67245)|0;mr(b,69182)|0;if(c|0?a[c>>0]|0:0){mr(b,67363)|0;mr(b,c)|0;mr(b,83714)|0}if(d|0?a[d>>0]|0:0){mr(b,67377)|0;mr(b,sw(d,1)|0)|0;mr(b,83714)|0}if(e|0?a[e>>0]|0:0){mr(b,67392)|0;mr(b,rw(e)|0)|0;mr(b,83714)|0}mr(b,69221)|0;return}function Td(a){a=a|0;mr(a,69176)|0;mr(a,67346)|0;return}function Ud(e,f,g){e=e|0;f=f|0;g=g|0;var i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0.0,H=0,I=0,J=0,K=0,L=0,M=0;M=l;l=l+176|0;L=M+160|0;K=M+152|0;F=M+136|0;J=M+128|0;E=M+120|0;D=M+112|0;C=M+104|0;B=M+96|0;A=M+88|0;y=M+80|0;w=M+72|0;v=M+64|0;u=M+56|0;t=M+48|0;i=M+40|0;q=M+32|0;s=M+24|0;r=M+16|0;p=M+8|0;o=M;I=c[e+16>>2]|0;mr(e,66877)|0;switch(a[g+48>>0]|0){case 108:{mr(e,66883)|0;break}case 114:{mr(e,66904)|0;break}default:mr(e,66923)|0}H=f+8|0;G=+h[H>>3]+ +h[g+24>>3];h[H>>3]=G;H=I+260|0;if(!(b[H>>1]&512)){mr(e,66945)|0;tr(e,+h[f>>3]);mr(e,66950)|0;tr(e,-G);mr(e,83714)|0}x=g+4|0;f=c[x>>2]|0;n=c[f+8>>2]|0;if(n){switch(c[(c[(c[(c[e>>2]|0)+168>>2]|0)+16>>2]|0)+244>>2]|0){case 1:{m=n;f=n+16|0;i=n+8|0;break}case 2:{m=n+24|0;f=n+32|0;i=n+28|0;break}default:{m=n+4|0;f=n+16|0;i=n+8|0}}j=c[f>>2]|0;f=c[i>>2]|0;k=c[n+12>>2]|0;c[o>>2]=c[m>>2];sr(e,66956,o);i=c[n+24>>2]|0;if(i|0){c[p>>2]=i;sr(e,66973,p)}mr(e,83714)|0;if(f|0){c[r>>2]=f;sr(e,66977,r)}if(k|0){c[s>>2]=k;sr(e,66995,s)}if(!j)j=0;else{c[q>>2]=j;sr(e,67014,q)}}else{c[i>>2]=c[f>>2];sr(e,67031,i);j=0;f=0}i=c[x>>2]|0;if(i|0?(z=c[i+24>>2]|0,z&127|0):0){if(!((f|0)!=0|(z&1|0)==0))sr(e,67049,t);if(!((j|0)!=0|(z&2|0)==0))sr(e,67069,u);if(z&100|0){sr(e,67090,v);if(!(z&4))f=0;else{sr(e,91030,w);f=1}if(z&64){c[y>>2]=f|0?86030:174181;sr(e,67109,y);f=1}if(z&32|0){c[A>>2]=f|0?86030:174181;sr(e,67120,A)}sr(e,83714,B)}if(z&8|0)sr(e,67135,C);if(z&16|0)sr(e,67159,D)}h[E>>3]=+h[(c[x>>2]|0)+16>>3];sr(e,67181,E);f=I+16|0;switch(c[I+48>>2]|0){case 5:{f=c[f>>2]|0;if(iK(f,122106)|0){c[J>>2]=f;sr(e,67199,J)}break}case 1:{E=d[f+1>>0]|0;J=d[f+2>>0]|0;c[F>>2]=d[f>>0];c[F+4>>2]=E;c[F+8>>2]=J;sr(e,67210,F);break}default:ma(123205,66391,486,67232)}mr(e,67245)|0;if(b[H>>1]&512){c[K>>2]=rw(c[I+212>>2]|0)|0;sr(e,67247,K);mr(e,67296)|0;tr(e,-G);mr(e,67314)|0}mr(e,sw(c[g>>2]|0,1)|0)|0;if(b[H>>1]&512)sr(e,67317,L);mr(e,67337)|0;l=M;return}function Vd(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;switch(c|0){case 2:{d=ae(a,b,2)|0;break}case 3:{d=be(a)|0;break}default:d=0}mr(a,66841)|0;_d(a,c,d);mr(a,66850)|0;tr(a,+h[b>>3]);mr(a,66856)|0;c=b+8|0;tr(a,-+h[c>>3]);mr(a,66863)|0;tr(a,+h[b+16>>3]-+h[b>>3]);mr(a,66870)|0;tr(a,+h[b+24>>3]-+h[c>>3]);mr(a,66257)|0;return}function Wd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;switch(d|0){case 2:{e=ae(a,b,c)|0;break}case 3:{e=be(a)|0;break}default:e=0}mr(a,66832)|0;_d(a,d,e);mr(a,66247)|0;e=0;while(1){if((e|0)>=(c|0))break;tr(a,+h[b+(e<<4)>>3]);mr(a,86030)|0;tr(a,-+h[b+(e<<4)+8>>3]);mr(a,87638)|0;e=e+1|0}tr(a,+h[b>>3]);mr(a,86030)|0;tr(a,-+h[b+8>>3]);mr(a,66257)|0;return}function Xd(a,d,e,f,g,h){a=a|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;g=c[a+16>>2]|0;switch(h|0){case 2:{f=ae(a,d,e)|0;break}case 3:{f=be(a)|0;break}default:f=0}mr(a,66427)|0;if(b[g+260>>1]&512){mr(a,66433)|0;mr(a,rw(c[g+212>>2]|0)|0)|0;mr(a,66439)|0}_d(a,h,f);mr(a,66444)|0;ce(a,d,e);mr(a,66257)|0;return}function Yd(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;mr(a,66237)|0;_d(a,0,0);mr(a,66247)|0;d=0;while(1){if((d|0)>=(c|0))break;tr(a,+h[b+(d<<4)>>3]);mr(a,86030)|0;tr(a,-+h[b+(d<<4)+8>>3]);mr(a,87638)|0;d=d+1|0}mr(a,66257)|0;return}function Zd(a,b){a=a|0;b=b|0;mr(a,66231)|0;mr(a,rw(b)|0)|0;mr(a,68291)|0;return}function _d(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0;q=l;l=l+96|0;k=q+48|0;p=q+40|0;n=q+32|0;o=q+24|0;j=q+16|0;g=q+8|0;f=q;m=c[b+16>>2]|0;mr(b,66262)|0;a:do switch(d|0){case 2:{c[f>>2]=e;sr(b,66270,f);break}case 3:{c[g>>2]=e;sr(b,66281,g);break}case 0:{mr(b,120501)|0;break}default:{d=m+56|0;f=k;g=d;i=f+40|0;do{c[f>>2]=c[g>>2];f=f+4|0;g=g+4|0}while((f|0)<(i|0));$d(b,k);if((c[m+88>>2]|0)==1){d=a[d+3>>0]|0;switch(d<<24>>24){case -1:case 0:break a;default:{}}h[j>>3]=+(d&255)*.00392156862745098;sr(b,66292,j)}}}while(0);mr(b,66311)|0;e=m+16|0;f=k;g=e;i=f+40|0;do{c[f>>2]=c[g>>2];f=f+4|0;g=g+4|0}while((f|0)<(i|0));$d(b,k);d=m+152|0;if(+h[d>>3]!=1.0){mr(b,66322)|0;tr(b,+h[d>>3])}switch(c[m+144>>2]|0){case 1:{c[o>>2]=66362;sr(b,66339,o);break}case 2:{c[n>>2]=66366;sr(b,66339,n);break}default:{}}b:do if((c[m+48>>2]|0)==1){d=a[e+3>>0]|0;switch(d<<24>>24){case -1:case 0:break b;default:{}}h[p>>3]=+(d&255)*.00392156862745098;sr(b,66370,p)}while(0);mr(b,83714)|0;l=q;return}function $d(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,i=0;g=l;l=l+16|0;f=g;a:do switch(c[e+32>>2]|0){case 5:{mr(b,c[e>>2]|0)|0;break}case 1:if(!(a[e+3>>0]|0)){mr(b,122171)|0;break a}else{i=d[e+1>>0]|0;h=d[e+2>>0]|0;c[f>>2]=d[e>>0];c[f+4>>2]=i;c[f+8>>2]=h;sr(b,68547,f);break a}default:ma(123205,66391,117,66411)}while(0);l=g;return}function ae(b,d,e){b=b|0;d=d|0;e=e|0;var f=0.0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;t=l;l=l+112|0;o=t+64|0;r=t+56|0;n=t+48|0;m=t+40|0;i=t+32|0;k=t;q=c[41908]|0;c[41908]=q+1;p=c[b+16>>2]|0;f=+(c[p+136>>2]|0)*.017453292519943295;c[k>>2]=0;c[k+4>>2]=0;c[k+8>>2]=0;c[k+12>>2]=0;c[k+16>>2]=0;c[k+20>>2]=0;c[k+24>>2]=0;c[k+28>>2]=0;JB(d,k,e,f,0);c[o>>2]=q;sr(b,66664,o);mr(b,66729)|0;tr(b,+h[k>>3]);mr(b,66734)|0;tr(b,+h[k+8>>3]);mr(b,66741)|0;tr(b,+h[k+16>>3]);mr(b,66748)|0;tr(b,+h[k+24>>3]);mr(b,66755)|0;k=p+140|0;f=+g[k>>2];if(f>0.0){h[i>>3]=f+-.001;sr(b,66760,i)}else mr(b,66536)|0;d=p+56|0;e=o;i=d;j=e+40|0;do{c[e>>2]=c[i>>2];e=e+4|0;i=i+4|0}while((e|0)<(j|0));$d(b,o);mr(b,66572)|0;a:do if((c[p+88>>2]|0)==1){d=a[d+3>>0]|0;switch(d<<24>>24){case -1:case 0:{s=7;break a}default:{}}h[m>>3]=+(d&255)*.00392156862745098;sr(b,84631,m)}else s=7;while(0);if((s|0)==7)mr(b,66587)|0;mr(b,66590)|0;f=+g[k>>2];if(f>0.0){h[n>>3]=f;sr(b,66760,n)}else mr(b,66596)|0;d=p+96|0;e=o;i=d;j=e+40|0;do{c[e>>2]=c[i>>2];e=e+4|0;i=i+4|0}while((e|0)<(j|0));$d(b,o);mr(b,66572)|0;b:do if((c[p+128>>2]|0)==1){d=a[d+3>>0]|0;switch(d<<24>>24){case -1:case 0:{s=14;break b}default:{}}h[r>>3]=+(d&255)*.00392156862745098;sr(b,84631,r)}else s=14;while(0);if((s|0)==14)mr(b,66587)|0;mr(b,66800)|0;l=t;return q|0}function be(b){b=b|0;var d=0,e=0.0,f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0.0;q=l;l=l+64|0;k=q+16|0;o=q+8|0;j=q;n=c[41907]|0;c[41907]=n+1;m=c[b+16>>2]|0;r=+(c[m+136>>2]|0)*.017453292519943295;e=r;if(r==0.0){f=50;d=50}else{f=~~((+E(+e)+1.0)*50.0);d=~~((1.0-+F(+e))*50.0)}c[k>>2]=n;c[k+4>>2]=f;c[k+8>>2]=d;sr(b,66452,k);mr(b,66536)|0;d=m+56|0;f=k;g=d;i=f+40|0;do{c[f>>2]=c[g>>2];f=f+4|0;g=g+4|0}while((f|0)<(i|0));$d(b,k);mr(b,66572)|0;a:do if((c[m+88>>2]|0)==1){d=a[d+3>>0]|0;switch(d<<24>>24){case -1:case 0:{p=6;break a}default:{}}h[j>>3]=+(d&255)*.00392156862745098;sr(b,84631,j)}else p=6;while(0);if((p|0)==6)mr(b,66587)|0;mr(b,66590)|0;mr(b,66596)|0;d=m+96|0;f=k;g=d;i=f+40|0;do{c[f>>2]=c[g>>2];f=f+4|0;g=g+4|0}while((f|0)<(i|0));$d(b,k);mr(b,66572)|0;b:do if((c[m+128>>2]|0)==1){d=a[d+3>>0]|0;switch(d<<24>>24){case -1:case 0:{p=10;break b}default:{}}h[o>>3]=+(d&255)*.00392156862745098;sr(b,84631,o)}else p=10;while(0);if((p|0)==10)mr(b,66587)|0;mr(b,66632)|0;l=q;return n|0}function ce(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,i=0;i=l;l=l+16|0;g=i;e=77;f=0;while(1){if((f|0)>=(d|0))break;c[g>>2]=e;sr(a,66449,g);tr(a,+h[b+(f<<4)>>3]);mr(a,86030)|0;tr(a,-+h[b+(f<<4)+8>>3]);e=(f|0)==0?67:32;f=f+1|0}l=i;return}function de(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0;j=l;l=l+16|0;i=j+8|0;h=j;mr(b,67420)|0;mr(b,rw(d)|0)|0;if(e|0){c[h>>2]=rw(e)|0;sr(b,67428,h)}c[i>>2]=f;sr(b,67432,i);d=Im(g,67444)|0;if(d|0?a[d>>0]|0:0){mr(b,87638)|0;mr(b,rw(d)|0)|0}mr(b,83714)|0;l=j;return}function ee(a){a=a|0;var b=0;mr(a,68251)|0;b=a+12|0;mr(a,oe(c[c[c[b>>2]>>2]>>2]|0)|0)|0;mr(a,71014)|0;mr(a,oe(c[(c[c[b>>2]>>2]|0)+4>>2]|0)|0)|0;mr(a,71024)|0;mr(a,oe(c[(c[c[b>>2]>>2]|0)+8>>2]|0)|0)|0;mr(a,68267)|0;return}function fe(b){b=b|0;var d=0,e=0,f=0;f=l;l=l+16|0;e=f;d=c[b+16>>2]|0;mr(b,68228)|0;d=d+8|0;if(a[(Dn(c[d>>2]|0)|0)>>0]|0){mr(b,68230)|0;mr(b,oe(Dn(c[d>>2]|0)|0)|0)|0}c[e>>2]=O(c[b+168>>2]|0,c[b+164>>2]|0)|0;sr(b,68239,e);c[41909]=0;l=f;return}function ge(a){a=a|0;c[41909]=1;return}function he(a){a=a|0;c[41909]=-1;return}function ie(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0,m=0,n=0;n=l;l=l+48|0;i=n+8|0;m=n;f=c[b+16>>2]|0;if(c[f+144>>2]|0?(k=e+4|0,j=~~(+h[b+352>>3]*+h[(c[k>>2]|0)+16>>3]),j|0):0){pe(b);mr(b,68167)|0;g=d+8|0;h[g>>3]=+h[g>>3]-+(j|0)*.55;c[i>>2]=c[d>>2];c[i+4>>2]=c[d+4>>2];c[i+8>>2]=c[d+8>>2];c[i+12>>2]=c[d+12>>2];vr(b,i);mr(b,68181)|0;mr(b,c[e>>2]|0)|0;mr(b,68190)|0;mr(b,67988)|0;g=i;d=f+16|0;f=g+40|0;do{c[g>>2]=c[d>>2];g=g+4|0;d=d+4|0}while((g|0)<(f|0));qe(b,i);mr(b,68192)|0;i=c[k>>2]|0;k=c[i+8>>2]|0;k=c[((k|0)==0?i:k+4|0)>>2]|0;mr(b,83714)|0;mr(b,k)|0;mr(b,83714)|0;c[m>>2]=j;sr(b,68201,m);switch(a[e+48>>0]|0){case 108:{mr(b,68206)|0;break}case 114:{mr(b,68217)|0;break}default:{}}re(b);mr(b,134901)|0}l=n;return}function je(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,i=0,j=0,k=0.0,m=0.0,n=0.0;j=l;l=l+48|0;f=j;g=c[a+16>>2]|0;i=g+144|0;if(c[i>>2]|0){n=+h[b>>3];m=+h[b+24>>3];e=b+8|0;k=+h[e>>3];h[b>>3]=n-+h[b+16>>3]+n;h[e>>3]=k-m+k;pe(a);mr(a,68153)|0;wr(a,b,2);mr(a,67988)|0;do if(!d)if(!(c[41909]|0)){mr(a,82272)|0;break}else{mr(a,121990)|0;break}else{b=f;d=g+56|0;e=b+40|0;do{c[b>>2]=c[d>>2];b=b+4|0;d=d+4|0}while((b|0)<(e|0));qe(a,f)}while(0);if((c[41909]|0)==1)c[41909]=0;mr(a,68099)|0;tr(a,+h[g+152>>3]);mr(a,68142)|0;b=f;d=g+16|0;e=b+40|0;do{c[b>>2]=c[d>>2];b=b+4|0;d=d+4|0}while((b|0)<(e|0));qe(a,f);b=c[i>>2]|0;if((b|0)==1){mr(a,67996)|0;b=c[i>>2]|0}if((b|0)==2)mr(a,68005)|0;re(a);mr(a,134901)|0}l=j;return}function ke(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0;j=l;l=l+48|0;f=j;g=c[a+16>>2]|0;i=g+144|0;if(c[i>>2]|0){pe(a);mr(a,68125)|0;wr(a,b,d);mr(a,67988)|0;do if(!e)if(!(c[41909]|0)){mr(a,82272)|0;break}else{mr(a,121990)|0;break}else{b=f;d=g+56|0;e=b+40|0;do{c[b>>2]=c[d>>2];b=b+4|0;d=d+4|0}while((b|0)<(e|0));qe(a,f)}while(0);if((c[41909]|0)==1)c[41909]=0;mr(a,68099)|0;tr(a,+h[g+152>>3]);mr(a,68142)|0;b=f;d=g+16|0;e=b+40|0;do{c[b>>2]=c[d>>2];b=b+4|0;d=d+4|0}while((b|0)<(e|0));qe(a,f);b=c[i>>2]|0;if((b|0)==1){mr(a,67996)|0;b=c[i>>2]|0}if((b|0)==2)mr(a,68005)|0;re(a);mr(a,134901)|0}l=j;return}function le(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var i=0,j=0,k=0,m=0;m=l;l=l+48|0;i=m;j=c[a+16>>2]|0;k=j+144|0;if(c[k>>2]|0){pe(a);mr(a,67974)|0;wr(a,b,d);mr(a,67988)|0;e=i;f=j+16|0;g=e+40|0;do{c[e>>2]=c[f>>2];e=e+4|0;f=f+4|0}while((e|0)<(g|0));qe(a,i);mr(a,68099)|0;tr(a,+h[j+152>>3]);e=c[k>>2]|0;if((e|0)==1){mr(a,67996)|0;e=c[k>>2]|0}if((e|0)==2)mr(a,68005)|0;mr(a,68108)|0;re(a);mr(a,134901)|0}l=m;return}function me(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;i=l;l=l+48|0;g=i;e=c[a+16>>2]|0;h=e+144|0;if(c[h>>2]|0){pe(a);mr(a,67974)|0;wr(a,b,d);mr(a,67988)|0;f=g;b=e+16|0;d=f+40|0;do{c[f>>2]=c[b>>2];f=f+4|0;b=b+4|0}while((f|0)<(d|0));qe(a,g);b=c[h>>2]|0;if((b|0)==1){mr(a,67996)|0;b=c[h>>2]|0}if((b|0)==2)mr(a,68005)|0;re(a);mr(a,134901)|0}l=i;return}function ne(a,b){a=a|0;b=b|0;mr(a,67971)|0;mr(a,oe(b)|0)|0;mr(a,134901)|0;return}function oe(a){a=a|0;return a|0}function pe(b){b=b|0;if(!(a[b+144>>0]|0))mr(b,68096)|0;else mr(b,c[b+148>>2]|0)|0;return}function qe(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,i=0;g=l;l=l+16|0;f=g;a:do switch(c[e+32>>2]|0){case 5:{mr(b,c[e>>2]|0)|0;break}case 1:if(!(a[e+3>>0]|0)){mr(b,82272)|0;break a}else{i=d[e+1>>0]|0;h=d[e+2>>0]|0;c[f>>2]=d[e>>0];c[f+4>>2]=i;c[f+8>>2]=h;sr(b,68547,f);break a}default:ma(123205,68014,49,68078)}while(0);l=g;return}function re(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0;h=l;l=l+16|0;g=h;f=c[a+16>>2]|0;switch(c[f+12>>2]|0){case 8:{b=1;d=96273;e=f+8|0;break}case 10:{b=0;d=96273;e=f+8|0;break}case 3:case 2:case 9:{b=1;d=96237;e=f+8|0;break}case 7:case 6:case 11:{b=0;d=96237;e=f+8|0;break}case 0:{b=1;d=96286;e=f+8|0;break}case 4:{b=0;d=68050;e=f+8|0;break}case 1:{b=1;d=96286;e=f+8|0;break}case 5:{b=0;d=96286;e=f+8|0;break}default:ma(123205,68014,106,68033)}f=c[(c[e>>2]|0)+8>>2]|0;c[g>>2]=b;c[g+4>>2]=d;c[g+8>>2]=f;sr(a,68062,g);l=h;return}function se(a){a=a|0;var b=0;mr(a,70986)|0;mr(a,70994)|0;b=a+12|0;mr(a,De(c[c[c[b>>2]>>2]>>2]|0)|0)|0;mr(a,71014)|0;mr(a,De(c[(c[c[b>>2]>>2]|0)+4>>2]|0)|0)|0;mr(a,71024)|0;mr(a,De(c[(c[c[b>>2]>>2]|0)+8>>2]|0)|0)|0;mr(a,71027)|0;return}function te(b){b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0;j=l;l=l+32|0;i=j+24|0;g=j+16|0;f=j+8|0;e=j;d=c[b+16>>2]|0;c[41913]=~~(+h[b+232>>3]-+h[b+216>>3]);c[41912]=~~(+h[b+224>>3]-+h[b+208>>3]);mr(b,69673)|0;mr(b,69680)|0;d=Dn(c[d+8>>2]|0)|0;if(a[d>>0]|0){mr(b,69749)|0;mr(b,De(d)|0)|0;mr(b,69757)|0}c[e>>2]=O(c[b+168>>2]|0,c[b+164>>2]|0)|0;sr(b,69766,e);mr(b,69786)|0;mr(b,69821)|0;mr(b,69849)|0;mr(b,69855)|0;mr(b,69898)|0;mr(b,69939)|0;mr(b,69958)|0;mr(b,69975)|0;mr(b,70023)|0;mr(b,70076)|0;mr(b,70152)|0;mr(b,70228)|0;mr(b,70237)|0;mr(b,70260)|0;mr(b,70287)|0;mr(b,70340)|0;mr(b,70362)|0;mr(b,70407)|0;mr(b,70419)|0;mr(b,70429)|0;mr(b,70455)|0;mr(b,70340)|0;mr(b,70507)|0;mr(b,70407)|0;mr(b,70419)|0;mr(b,70551)|0;mr(b,70260)|0;mr(b,70287)|0;mr(b,70340)|0;mr(b,70507)|0;mr(b,70407)|0;mr(b,70419)|0;mr(b,70429)|0;mr(b,70455)|0;mr(b,70340)|0;mr(b,70362)|0;mr(b,70407)|0;mr(b,70419)|0;mr(b,70564)|0;mr(b,70572)|0;mr(b,70578)|0;mr(b,70592)|0;mr(b,70600)|0;mr(b,70633)|0;e=(c[41913]|0)+10|0;c[f>>2]=c[41912];c[f+4>>2]=e;sr(b,70710,f);mr(b,70740)|0;mr(b,70749)|0;mr(b,70807)|0;mr(b,70817)|0;mr(b,70882)|0;f=c[41913]|0;c[g>>2]=c[41912];c[g+4>>2]=f;sr(b,70919,g);g=c[41913]|0;c[i>>2]=c[41912];c[i+4>>2]=g;sr(b,70947,i);l=j;return}function ue(a){a=a|0;mr(a,69224)|0;mr(a,69236)|0;mr(a,69244)|0;mr(a,69307)|0;mr(a,69236)|0;mr(a,69352)|0;mr(a,69401)|0;mr(a,69455)|0;mr(a,69236)|0;mr(a,69555)|0;mr(a,69604)|0;mr(a,69236)|0;mr(a,69656)|0;return}function ve(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0;j=l;l=l+32|0;i=j+16|0;h=j+8|0;g=j;mr(b,69182)|0;if(d|0?a[d>>0]|0:0){c[g>>2]=De(d)|0;sr(b,69185,g)}if(e|0?a[e>>0]|0:0){c[h>>2]=De(e)|0;sr(b,69196,h)}if(f|0?a[f>>0]|0:0){c[i>>2]=De(f)|0;sr(b,69208,i)}mr(b,69221)|0;l=j;return}function we(a){a=a|0;mr(a,69176)|0;return}function xe(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,i=0.0,j=0.0,k=0.0,m=0.0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0.0;A=l;l=l+112|0;y=A+96|0;z=A+88|0;w=A+80|0;q=A+72|0;v=A+64|0;t=A+56|0;s=A+48|0;r=A+40|0;p=A+24|0;o=A+8|0;n=A;x=c[b+16>>2]|0;switch(a[f+48>>0]|0){case 108:{j=+h[e>>3];m=+h[f+32>>3];break}case 114:{m=+h[f+32>>3];j=+h[e>>3]-m;break}default:{m=+h[f+32>>3];j=+h[e>>3]-m*.5}}g=f+40|0;i=+h[g>>3];u=f+4|0;k=+h[(c[u>>2]|0)+16>>3];if(i>3]=i}B=j+-8.0;k=+((c[41913]|0)>>>0)-+h[e+8>>3]-i+k*.2+(k<12.0?1.4:2.0);sr(b,68838,n);h[o>>3]=B;h[o+8>>3]=k;sr(b,68775,o);h[p>>3]=j+8.0+m-B;h[p+8>>3]=i;sr(b,68799,p);mr(b,68873)|0;mr(b,68907)|0;g=c[u>>2]|0;e=c[g+8>>2]|0;if(e){c[r>>2]=c[e+4>>2];sr(b,68997,r);g=c[e+8>>2]|0;if(g|0){c[s>>2]=g;sr(b,69016,s)}g=c[e+12>>2]|0;if(g|0){c[t>>2]=g;sr(b,69033,t)}g=c[e+16>>2]|0;if(g|0){c[v>>2]=g;sr(b,69051,v)}}else{c[q>>2]=c[g>>2];sr(b,68997,q)}h[w>>3]=+h[(c[u>>2]|0)+16>>3];sr(b,69067,w);g=x+16|0;switch(c[x+48>>2]|0){case 5:{g=c[g>>2]|0;if(iK(g,122106)|0){c[z>>2]=g;sr(b,69087,z)}break}case 1:{x=d[g+1>>0]|0;z=d[g+2>>0]|0;c[y>>2]=d[g>>0];c[y+4>>2]=x;c[y+8>>2]=z;sr(b,69097,y);break}default:ma(123205,68561,438,69118)}mr(b,69131)|0;mr(b,De(c[f>>2]|0)|0)|0;mr(b,69142)|0;mr(b,69165)|0;l=A;return}function ye(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0.0,i=0.0,j=0,k=0.0,m=0.0;e=l;l=l+32|0;f=e+16|0;j=e;mr(a,68739)|0;m=+h[b>>3];i=+h[b+16>>3]-m;k=+h[b+24>>3];g=k-+h[b+8>>3];k=+((c[41913]|0)>>>0)-k;h[j>>3]=m-i;h[j+8>>3]=k;sr(a,68775,j);h[f>>3]=i*2.0;h[f+8>>3]=g*2.0;sr(a,68799,f);He(a,d);mr(a,68621)|0;Fe(a);mr(a,68827)|0;l=e;return}function ze(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,g=0,i=0.0,j=0,k=0,m=0,n=0;m=l;l=l+48|0;k=m+24|0;j=m+8|0;g=m;mr(a,68344)|0;n=c[41913]|0;c[g>>2]=c[41912];c[g+4>>2]=n;sr(a,68597,g);He(a,e);mr(a,68621)|0;Fe(a);mr(a,68624)|0;g=d+-1|0;e=0;while(1){if((e|0)>=(d|0))break;i=+h[b+(e<<4)>>3];f=+((c[41913]|0)>>>0)-+h[b+(e<<4)+8>>3];if(!e){mr(a,68651)|0;h[j>>3]=i;h[j+8>>3]=f;sr(a,68717,j);mr(a,68728)|0}else{h[k>>3]=i;h[k+8>>3]=f;sr(a,68717,k)}if((e|0)==(g|0))mr(a,68731)|0;e=e+1|0}mr(a,68460)|0;l=m;return}function Ae(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0;f=l;l=l+16|0;e=f;mr(a,68344)|0;h=c[41913]|0;c[e>>2]=c[41912];c[e+4>>2]=h;sr(a,68597,e);He(a,g);mr(a,68621)|0;Fe(a);mr(a,68624)|0;Ie(a,b,d);mr(a,68637)|0;l=f;return}function Be(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,i=0,j=0,k=0,m=0.0;k=l;l=l+48|0;j=k+24|0;i=k+8|0;f=k;mr(a,68344)|0;g=c[41913]|0;c[f>>2]=c[41912];c[f+4>>2]=g;sr(a,68381,f);mr(a,68421)|0;f=d+-1|0;g=b+8|0;e=0;while(1){if((e|0)>=(d|0))break;if(!e){mr(a,68433)|0;m=+((c[41913]|0)>>>0)-+h[g>>3];h[i>>3]=+h[b>>3];h[i+8>>3]=m;sr(a,68437,i);mr(a,68448)|0}else{m=+((c[41913]|0)>>>0)-+h[b+(e<<4)+8>>3];h[j>>3]=+h[b+(e<<4)>>3];h[j+8>>3]=m;sr(a,68437,j)}if((e|0)==(f|0))mr(a,68452)|0;e=e+1|0}mr(a,68456)|0;Fe(a);mr(a,68460)|0;l=k;return}function Ce(a,b){a=a|0;b=b|0;mr(a,68279)|0;mr(a,De(b)|0)|0;mr(a,68291)|0;return}function De(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;u=l;l=l+16|0;e=u;d=c[41910]|0;if(!d){c[41911]=64;d=ww(64)|0;c[41910]=d}s=e+15|0;r=e+14|0;g=0;q=0;o=0;e=0;f=0;a:while(1){n=(o|0)!=0;k=g;p=b;j=e;b:while(1){if(!p){t=32;break a}e=a[p>>0]|0;if(!(e<<24>>24)){t=32;break a}b=c[41911]|0;if((q|0)>(b+-8|0)){d=b<<1;c[41911]=d;d=yw(c[41910]|0,d)|0;c[41910]=d;d=d+q|0;e=a[p>>0]|0}switch(e<<24>>24){case 60:{e=4;b=87187;t=26;break b}case 62:{e=4;b=87170;t=27;break b}case 38:{t=10;break b}case 45:{e=5;b=87181;i=j;break b}default:{}}if(n&e<<24>>24==32){t=12;break}switch(e<<24>>24){case 34:{e=6;b=87150;t=26;break b}case 39:{e=5;b=87175;t=27;break b}default:{}}if(e<<24>>24<0){i=127;b=0}else{e=1;b=p;t=26;break}while(1){g=i&255;h=e&255;if(g>>>0>=h>>>0)break;e=i&h&255;i=g>>>1;b=b+1|0}if((b|0)<=1){g=ON(j|0,f|0,6)|0;g=HN(g|0,z|0,e&255|0,0)|0;f=z;m=k+-1|0;if((k|0)>1){b=m;e=g}else{t=21;break}}else{b=b+-1|0;e=e&255;f=0}k=b;p=p+1|0;j=e}if((t|0)==10){t=0;b=(Ee(p)|0)==0;e=b?5:1;b=b?87164:p;i=j}else if((t|0)==12){t=0;b=(a[o>>0]|0)==32;e=b?6:1;b=b?87157:p;i=j}else if((t|0)==21){t=0;a[s>>0]=59;e=3;h=r;i=g;j=f;while(1){b=MN(i|0,j|0,10,0)|0;g=h+-1|0;a[h>>0]=b|48;b=i;i=LN(i|0,j|0,10,0)|0;f=j;j=z;o=e;e=e+1|0;if((o|0)>11){t=23;break a}if(!(f>>>0>0|(f|0)==0&b>>>0>9))break;else h=g}b=h+-2|0;a[g>>0]=35;a[b>>0]=38;k=m;f=j}else if((t|0)==26){t=0;i=j}else if((t|0)==27){t=0;i=j}h=d+e|0;g=e;while(1){if(!g)break;a[d>>0]=a[b>>0]|0;g=g+-1|0;b=b+1|0;d=d+1|0}g=k;b=p+1|0;q=e+q|0;o=p;d=h;e=i}if((t|0)==23){XL(68297,46,1,c[13918]|0)|0;Ma(1)}else if((t|0)==32){a[d>>0]=0;l=u;return c[41910]|0}return 0}function Ee(b){b=b|0;var c=0,d=0;d=b+1|0;c=a[d>>0]|0;a:do if(c<<24>>24==35){d=b+2|0;c=a[d>>0]|0;switch(c<<24>>24){case 88:case 120:break;default:{b=d;while(1){d=b+1|0;if((c+-48&255)>=10)break a;b=d;c=a[d>>0]|0}}}d=b+3|0;while(1){c=a[d>>0]|0;if((c+-48&255)>=10)switch(c<<24>>24){case 65:case 66:case 67:case 68:case 69:case 70:case 97:case 98:case 99:case 100:case 101:case 102:break;default:break a}d=d+1|0}}else while(1){b=d+1|0;if(((c&-33)+-65&255)>=26)break a;d=b;c=a[b>>0]|0}while(0);return c<<24>>24==59|0}function Fe(a){a=a|0;var b=0.0,d=0,e=0,f=0,g=0,i=0,j=0,k=0;k=l;l=l+48|0;d=k+8|0;j=k;i=c[a+16>>2]|0;mr(a,68472)|0;e=d;f=i+16|0;g=e+40|0;do{c[e>>2]=c[f>>2];e=e+4|0;f=f+4|0}while((e|0)<(g|0));Ge(a,d);b=+h[i+152>>3];if(b!=1.0){h[j>>3]=b;sr(a,68490,j)}switch(c[i+144>>2]|0){case 1:{mr(a,68507)|0;break}case 2:{mr(a,68525)|0;break}default:{}}mr(a,68542)|0;l=k;return}function Ge(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,i=0;g=l;l=l+16|0;f=g;a:do switch(c[e+32>>2]|0){case 5:{mr(b,c[e>>2]|0)|0;break}case 1:if(!(a[e+3>>0]|0)){mr(b,120501)|0;break a}else{i=d[e+1>>0]|0;h=d[e+2>>0]|0;c[f>>2]=d[e>>0];c[f+4>>2]=i;c[f+8>>2]=h;sr(b,68547,f);break a}default:ma(123205,68561,94,68581)}while(0);l=g;return}function He(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;g=l;l=l+48|0;f=g;if(!b)mr(a,68700)|0;else{d=c[a+16>>2]|0;mr(a,68670)|0;b=f;d=d+56|0;e=b+40|0;do{c[b>>2]=c[d>>2];b=b+4|0;d=d+4|0}while((b|0)<(e|0));Ge(a,f);mr(a,68697)|0}l=g;return}function Ie(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,i=0,j=0.0,k=0.0;i=l;l=l+32|0;g=i;e=68651;f=0;while(1){if((f|0)>=(d|0))break;k=+h[b+(f<<4)>>3];j=+((c[41913]|0)>>>0)-+h[b+(f<<4)+8>>3];c[g>>2]=e;h[g+8>>3]=k;h[g+16>>3]=j;sr(a,68654,g);e=(f|0)==0?68667:174181;f=f+1|0}mr(a,83714)|0;l=i;return}function Je(a){a=a|0;var b=0,d=0,e=0;b=l;l=l+16|0;d=b+8|0;e=b;mr(a,73284)|0;mr(a,73299)|0;mr(a,73338)|0;mr(a,73387)|0;c[e>>2]=122106;c[e+4>>2]=73475;sr(a,73456,e);c[d>>2]=121990;c[d+4>>2]=73481;sr(a,73456,d);l=b;return}function Ke(a){a=a|0;var b=0,d=0,e=0.0,f=0.0,g=0.0,i=0.0,j=0;b=l;l=l+64|0;d=b+8|0;j=b;c[j>>2]=Dn(c[(c[a+16>>2]|0)+8>>2]|0)|0;sr(a,72237,j);i=+h[a+368>>3]*.5*+h[a+488>>3];g=+h[a+376>>3]*.5*+h[a+496>>3];f=+J(+(i*2.0000000949949026e-03))*180.0*.6366197723675814;e=+J(+(g*2.0000000949949026e-03))*180.0*.6366197723675814;h[d>>3]=i;h[d+8>>3]=g;h[d+16>>3]=-500.0;h[d+24>>3]=i;h[d+32>>3]=g;h[d+40>>3]=0.0;h[d+48>>3]=(f>e?f:e)*1.2;sr(a,72259,d);mr(a,72406)|0;mr(a,73236)|0;l=b;return}function Le(a){a=a|0;mr(a,72220)|0;return}function Me(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0;f=l;l=l+16|0;h=f;c[h>>2]=b;c[h+4>>2]=d;c[h+8>>2]=e;sr(a,72190,h);g[41914]=+(O(d,-10)|0);l=f;return}function Ne(a){a=a|0;mr(a,72173)|0;return}function Oe(a){a=a|0;mr(a,72155)|0;return}function Pe(a){a=a|0;mr(a,72139)|0;return}function Qe(a){a=a|0;mr(a,72118)|0;g[41914]=+g[41914]+-2.0;return}function Re(a){a=a|0;mr(a,72099)|0;return}function Se(a){a=a|0;var b=0,d=0;b=l;l=l+16|0;d=b;c[d>>2]=Dn(c[(c[a+16>>2]|0)+8>>2]|0)|0;sr(a,72077,d);l=b;return}function Te(a){a=a|0;mr(a,72061)|0;return}function Ue(a){a=a|0;mr(a,72043)|0;g[41914]=+g[41914]+-5.0;return}function Ve(a){a=a|0;mr(a,72027)|0;g[41914]=+g[41914]+5.0;return}function We(b,d,e){b=b|0;d=d|0;e=e|0;var f=0.0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0.0,t=0.0,u=0.0;r=l;l=l+144|0;o=r+104|0;q=r+56|0;m=r+32|0;j=r+24|0;n=r;p=e+4|0;i=c[p>>2]|0;f=+h[i+16>>3];i=c[i>>2]|0;c[n>>2]=c[e>>2];h[n+8>>3]=f;c[n+16>>2]=i;sr(b,71873,n);g[41915]=+g[41914]+-9.0;switch(a[e+48>>0]|0){case 108:{f=+h[d>>3];break}case 114:{i=d;f=+h[d>>3]-+h[e+32>>3];k=5;break}default:{i=d;f=+h[d>>3]-+h[e+32>>3]*.5;k=5}}if((k|0)==5)h[i>>3]=f;u=+h[b+488>>3];t=(+h[b+504>>3]+f)*u;s=(+h[b+512>>3]+ +h[d+8>>3])*+h[b+496>>3];h[j>>3]=+h[(c[p>>2]|0)+16>>3]*u;n=af(b,71925,j)|0;f=+(c[b+360>>2]|0);h[m>>3]=0.0;h[m+8>>3]=0.0;h[m+16>>3]=f;i=af(b,71142,m)|0;f=+g[41915];h[o>>3]=t;h[o+8>>3]=s;h[o+16>>3]=f;d=af(b,71174,o)|0;j=o;k=(c[b+16>>2]|0)+16|0;m=j+40|0;do{c[j>>2]=c[k>>2];j=j+4|0;k=k+4|0}while((j|0)<(m|0));o=bf(b,o,0.0)|0;e=c[e>>2]|0;c[q>>2]=c[c[p>>2]>>2];h[q+8>>3]=.25;h[q+16>>3]=0.0;c[q+24>>2]=e;c[q+28>>2]=72012;c[q+32>>2]=n;c[q+36>>2]=i;c[q+40>>2]=d;c[q+44>>2]=o;q=af(b,71937,q)|0;mr(b,q)|0;_I(q);_I(i);_I(o);_I(d);_I(n);l=r;return}function Xe(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,i=0.0,j=0.0,k=0.0,m=0,n=0,o=0,p=0.0,q=0.0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0.0;z=l;l=l+240|0;x=z+192|0;y=z+152|0;t=z+128|0;r=z+104|0;o=z+80|0;n=z+48|0;e=z+24|0;m=z;mr(a,71750)|0;g[41915]=+g[41914]+-6.0;i=+h[b>>3];j=+h[a+488>>3];p=(+h[a+504>>3]+i)*j;A=+h[b+8>>3];k=+h[a+496>>3];q=(+h[a+512>>3]+A)*k;j=(+h[b+16>>3]-i)*j;k=(+h[b+24>>3]-A)*k;s=a+16|0;A=k+j;i=+h[(c[s>>2]|0)+152>>3]/A*2.5;h[m>>3]=j;h[m+8>>3]=A*.25;h[m+16>>3]=k;b=af(a,71110,m)|0;m=a+360|0;A=+(c[m>>2]|0);h[e>>3]=90.0;h[e+8>>3]=0.0;h[e+16>>3]=A;e=af(a,71142,e)|0;A=+g[41915];h[x>>3]=p;h[x+8>>3]=q;h[x+16>>3]=A;f=af(a,71174,x)|0;u=x;v=(c[s>>2]|0)+16|0;w=u+40|0;do{c[u>>2]=c[v>>2];u=u+4|0;v=v+4|0}while((u|0)<(w|0));v=bf(a,x,0.0)|0;h[n>>3]=1.0;h[n+8>>3]=i;c[n+16>>2]=b;c[n+20>>2]=e;c[n+24>>2]=f;c[n+28>>2]=v;w=af(a,71765,n)|0;mr(a,w)|0;_I(b);_I(e);_I(f);_I(v);_I(w);if(d|0){h[o>>3]=j;h[o+8>>3]=k;h[o+16>>3]=1.0;f=af(a,71110,o)|0;A=+(c[m>>2]|0);h[r>>3]=0.0;h[r+8>>3]=0.0;h[r+16>>3]=A;e=af(a,71142,r)|0;A=+g[41915];h[t>>3]=p;h[t+8>>3]=q;h[t+16>>3]=A;b=af(a,71174,t)|0;u=x;v=(c[s>>2]|0)+56|0;w=u+40|0;do{c[u>>2]=c[v>>2];u=u+4|0;v=v+4|0}while((u|0)<(w|0));x=bf(a,x,0.0)|0;h[y>>3]=0.0;h[y+8>>3]=0.0;h[y+16>>3]=0.0;c[y+24>>2]=f;c[y+28>>2]=e;c[y+32>>2]=b;c[y+36>>2]=x;y=af(a,71811,y)|0;mr(a,y)|0;_I(f);_I(e);_I(b);_I(x);_I(y)}l=z;return}function Ye(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0.0,M=0,N=0.0;K=l;l=l+336|0;B=K+296|0;J=K+288|0;I=K+272|0;H=K+264|0;G=K+240|0;D=K+232|0;A=K+208|0;z=K+184|0;w=K+160|0;v=K+152|0;u=K+136|0;t=K+128|0;s=K+96|0;r=K+88|0;q=K+56|0;f=K+48|0;m=K+24|0;k=K;mr(a,71615)|0;g[41915]=+g[41914]+-2.0;o=a+488|0;p=a+496|0;L=+h[p>>3];h[k>>3]=+h[o>>3];h[k+8>>3]=L;h[k+16>>3]=1.0;k=af(a,71110,k)|0;y=a+360|0;L=+(c[y>>2]|0);h[m>>3]=0.0;h[m+8>>3]=0.0;h[m+16>>3]=L;m=af(a,71142,m)|0;L=+g[41915]+-2.0;h[B>>3]=0.0;h[B+8>>3]=0.0;h[B+16>>3]=L;n=af(a,71174,B)|0;C=a+16|0;i=B;j=(c[C>>2]|0)+16|0;x=i+40|0;do{c[i>>2]=c[j>>2];i=i+4|0;j=j+4|0}while((i|0)<(x|0));j=bf(a,B,0.0)|0;c[f>>2]=71237;c[f+4>>2]=d+1;E=a+504|0;F=a+512|0;i=0;f=af(a,71206,f)|0;while(1){if((i|0)>=(d|0))break;N=+h[F>>3]+ +h[b+(i<<4)+8>>3];L=+h[(c[C>>2]|0)+152>>3];h[q>>3]=+h[E>>3]+ +h[b+(i<<4)>>3];h[q+8>>3]=N;h[q+16>>3]=0.0;h[q+24>>3]=L;M=af(a,71251,q)|0;c[r>>2]=f;c[r+4>>2]=M;x=af(a,71280,r)|0;_I(M);_I(f);i=i+1|0;f=x}L=+h[F>>3]+ +h[b+8>>3];N=+h[(c[C>>2]|0)+152>>3];h[s>>3]=+h[E>>3]+ +h[b>>3];h[s+8>>3]=L;h[s+16>>3]=0.0;h[s+24>>3]=N;x=af(a,71251,s)|0;c[t>>2]=f;c[t+4>>2]=x;M=af(a,71280,t)|0;_I(x);_I(f);c[u>>2]=k;c[u+4>>2]=m;c[u+8>>2]=n;c[u+12>>2]=j;x=af(a,71630,u)|0;c[v>>2]=M;c[v+4>>2]=x;M=af(a,71335,v)|0;_I(x);mr(a,M)|0;_I(k);_I(m);_I(n);_I(j);_I(M);if(e|0){N=+h[p>>3];h[w>>3]=+h[o>>3];h[w+8>>3]=N;h[w+16>>3]=1.0;n=af(a,71110,w)|0;N=+(c[y>>2]|0);h[z>>3]=0.0;h[z+8>>3]=0.0;h[z+16>>3]=N;m=af(a,71142,z)|0;N=+g[41915]+-2.0;h[A>>3]=0.0;h[A+8>>3]=0.0;h[A+16>>3]=N;k=af(a,71174,A)|0;i=B;j=(c[C>>2]|0)+56|0;x=i+40|0;do{c[i>>2]=c[j>>2];i=i+4|0;j=j+4|0}while((i|0)<(x|0));j=bf(a,B,.25)|0;c[D>>2]=d;i=0;f=af(a,71675,D)|0;while(1){if((i|0)>=(d|0))break;N=+h[F>>3]+ +h[b+(i<<4)+8>>3];h[G>>3]=+h[E>>3]+ +h[b+(i<<4)>>3];h[G+8>>3]=N;h[G+16>>3]=0.0;D=af(a,71690,G)|0;c[H>>2]=f;c[H+4>>2]=D;M=af(a,71712,H)|0;_I(D);_I(f);i=i+1|0;f=M}c[I>>2]=n;c[I+4>>2]=m;c[I+8>>2]=k;c[I+12>>2]=j;I=af(a,71722,I)|0;c[J>>2]=f;c[J+4>>2]=I;M=af(a,71335,J)|0;_I(I);mr(a,M)|0;_I(n);_I(m);_I(k);_I(j);_I(M)}l=K;return}function Ze(a,b,d,e,f,i){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;i=i|0;var j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0.0,D=0.0;B=l;l=l+208|0;e=B+160|0;A=B+152|0;z=B+136|0;y=B+128|0;x=B+96|0;w=B+88|0;v=B+56|0;k=B+48|0;s=B+24|0;r=B;mr(a,71542)|0;g[41915]=+g[41914]+-4.0;C=+h[a+496>>3];h[r>>3]=+h[a+488>>3];h[r+8>>3]=C;h[r+16>>3]=1.0;r=af(a,71110,r)|0;C=+(c[a+360>>2]|0);h[s>>3]=0.0;h[s+8>>3]=0.0;h[s+16>>3]=C;s=af(a,71142,s)|0;C=+g[41915]+-2.0;h[e>>3]=0.0;h[e+8>>3]=0.0;h[e+16>>3]=C;t=af(a,71174,e)|0;u=a+16|0;f=e;i=(c[u>>2]|0)+56|0;j=f+40|0;do{c[f>>2]=c[i>>2];f=f+4|0;i=i+4|0}while((f|0)<(j|0));n=bf(a,e,0.0)|0;c[k>>2]=71556;c[k+4>>2]=d+2;o=a+504|0;p=a+512|0;q=d+-1|0;m=0;e=af(a,71206,k)|0;while(1){if((m|0)>=(d|0))break;f=b+(m<<4)|0;i=b+(m<<4)+8|0;D=+h[p>>3]+ +h[i>>3];C=+h[(c[u>>2]|0)+152>>3];h[v>>3]=+h[o>>3]+ +h[f>>3];h[v+8>>3]=D;h[v+16>>3]=0.0;h[v+24>>3]=C;k=af(a,71251,v)|0;c[w>>2]=e;c[w+4>>2]=k;j=af(a,71280,w)|0;_I(k);_I(e);if((m|0)==0|(m|0)==(q|0)){C=+h[p>>3]+ +h[i>>3];D=+h[(c[u>>2]|0)+152>>3];h[x>>3]=+h[o>>3]+ +h[f>>3];h[x+8>>3]=C;h[x+16>>3]=0.0;h[x+24>>3]=D;k=af(a,71251,x)|0;c[y>>2]=j;c[y+4>>2]=k;e=af(a,71280,y)|0;_I(k);_I(j)}else e=j;m=m+1|0}c[z>>2]=r;c[z+4>>2]=s;c[z+8>>2]=t;c[z+12>>2]=n;b=af(a,71565,z)|0;c[A>>2]=e;c[A+4>>2]=b;d=af(a,71335,A)|0;_I(b);mr(a,d)|0;_I(r);_I(s);_I(t);_I(n);_I(d);l=B;return}function _e(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0.0,x=0,y=0.0;v=l;l=l+160|0;e=v+120|0;u=v+112|0;t=v+96|0;s=v+88|0;r=v+56|0;m=v+48|0;n=v+24|0;q=v;mr(a,71094)|0;g[41915]=+g[41914]+-6.0;w=+h[a+496>>3];h[q>>3]=+h[a+488>>3];h[q+8>>3]=w;h[q+16>>3]=1.0;q=af(a,71110,q)|0;w=+(c[a+360>>2]|0);h[n>>3]=0.0;h[n+8>>3]=0.0;h[n+16>>3]=w;n=af(a,71142,n)|0;w=+g[41915];h[e>>3]=0.0;h[e+8>>3]=0.0;h[e+16>>3]=w;o=af(a,71174,e)|0;p=a+16|0;f=e;i=(c[p>>2]|0)+16|0;j=f+40|0;do{c[f>>2]=c[i>>2];f=f+4|0;i=i+4|0}while((f|0)<(j|0));i=bf(a,e,0.0)|0;c[m>>2]=71237;c[m+4>>2]=d;j=a+504|0;k=a+512|0;f=0;e=af(a,71206,m)|0;while(1){if((f|0)>=(d|0))break;y=+h[k>>3]+ +h[b+(f<<4)+8>>3];w=+h[(c[p>>2]|0)+152>>3];h[r>>3]=+h[j>>3]+ +h[b+(f<<4)>>3];h[r+8>>3]=y;h[r+16>>3]=0.0;h[r+24>>3]=w;x=af(a,71251,r)|0;c[s>>2]=e;c[s+4>>2]=x;m=af(a,71280,s)|0;_I(x);_I(e);f=f+1|0;e=m}c[t>>2]=q;c[t+4>>2]=n;c[t+8>>2]=o;c[t+12>>2]=i;t=af(a,71289,t)|0;c[u>>2]=e;c[u+4>>2]=t;x=af(a,71335,u)|0;_I(t);mr(a,x)|0;_I(q);_I(n);_I(o);_I(i);_I(x);l=v;return}function $e(a,b){a=a|0;b=b|0;var d=0,e=0;d=l;l=l+16|0;e=d;c[e>>2]=b;sr(a,71075,e);l=d;return}function af(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;i=l;l=l+1056|0;h=i;e=i+24|0;f=i+8|0;c[f>>2]=d;g=LK(e,1024,b,f)|0;do if((g|0)>=0)if((g|0)>1023){a=ZI(g+1|0)|0;c[f>>2]=d;qL(a,b,f)|0;break}else{a=GL(e)|0;break}else{a=c[(c[a+12>>2]|0)+16>>2]|0;c[h>>2]=yJ(c[(jJ()|0)>>2]|0)|0;hb[a&31](71520,h);a=GL(174181)|0}while(0);l=i;return a|0}function bf(a,b,e){a=a|0;b=b|0;e=+e;var f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0.0,s=0.0;q=l;l=l+112|0;o=q+104|0;j=q+96|0;i=q+64|0;n=q+48|0;p=q+32|0;m=q+16|0;k=q;g=c[b+32>>2]|0;a:do switch(g|0){case 5:{f=c[b>>2]|0;if(!(xJ(f,121094)|0)){c[k>>2]=71357;h[k+8>>3]=e;f=af(a,71340,k)|0;break a}if(!(xJ(f,118224)|0)){c[m>>2]=71361;h[m+8>>3]=e;f=af(a,71340,m)|0;break a}if(!(xJ(f,116223)|0)){c[p>>2]=71367;h[p+8>>3]=e;f=af(a,71340,p)|0;break a}else{c[n>>2]=f;h[n+8>>3]=e;f=af(a,71340,n)|0;break a}}case 1:{s=+(d[b+1>>0]|0)*.00390625;r=+(d[b+2>>0]|0)*.00390625;h[i>>3]=+(d[b>>0]|0)*.00390625;h[i+8>>3]=s;h[i+16>>3]=r;h[i+24>>3]=e;f=af(a,71372,i)|0;break}default:{p=c[13918]|0;n=c[b>>2]|0;c[j>>2]=g;c[j+4>>2]=n;zL(p,71411,j)|0;ma(123205,71461,436,71481)}}while(0);c[o>>2]=f;p=af(a,71498,o)|0;_I(f);l=q;return p|0}function cf(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;b=l;l=l+32|0;d=b+24|0;e=b+16|0;g=b;f=c[a+16>>2]|0;h=c[c[a+12>>2]>>2]|0;j=c[h>>2]|0;i=c[h+4>>2]|0;h=c[h+8>>2]|0;c[g>>2]=73927;c[g+4>>2]=j;c[g+8>>2]=i;c[g+12>>2]=h;sr(a,76546,g);f=Dn(c[f+8>>2]|0)|0;c[e>>2]=73927;c[e+4>>2]=f;sr(a,76578,e);c[d>>2]=73927;sr(a,76592,d);l=b;return}function df(a){a=a|0;var b=0,d=0;b=l;l=l+16|0;d=b;c[d>>2]=73927;sr(a,76494,d);l=b;return}function ef(a){a=a|0;var b=0.0,d=0.0,e=0.0,f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0;W=l;l=l+304|0;V=W+296|0;U=W+288|0;T=W+272|0;R=W+264|0;Q=W+256|0;P=W+248|0;O=W+240|0;N=W+232|0;M=W+224|0;L=W+216|0;K=W+208|0;J=W+200|0;I=W+192|0;H=W+184|0;G=W+176|0;F=W+168|0;E=W+160|0;C=W+152|0;A=W+144|0;z=W+136|0;y=W+128|0;x=W+120|0;w=W+112|0;v=W+104|0;u=W+96|0;t=W+88|0;s=W+80|0;r=W+72|0;q=W+64|0;p=W+56|0;o=W+48|0;S=W+40|0;B=W+24|0;n=W+16|0;m=W;g=c[a+456>>2]|0;i=c[a+460>>2]|0;j=c[a+464>>2]|0;k=c[a+468>>2]|0;f=a+360|0;a:do if(c[4007]|0){switch(c[f>>2]|0){case 90:case 0:break a;default:{}}rf();c[4007]=0}while(0);e=(+(k|0)-+(i|0))*.013888888888888888;b=(+(j|0)-+(g|0))*.013888888888888888;k=(c[f>>2]|0)==90;d=k?e:b;e=k?b:e;h[m>>3]=d;h[m+8>>3]=e;sr(a,74114,m);c[n>>2]=73927;sr(a,74129,n);if(d>0.0){b=+FJ(d);h[16877]=b;b=b+3.0-+(~~b|0)}else b=3.0;b=+D(10.0,+b);h[16877]=b;h[B>>3]=b;h[B+8>>3]=b;sr(a,74298,B);c[S>>2]=73927;sr(a,74333,S);c[o>>2]=73927;sr(a,74391,o);c[p>>2]=73927;sr(a,74451,p);c[q>>2]=73927;sr(a,74500,q);c[r>>2]=73927;sr(a,74539,r);c[s>>2]=73927;sr(a,74590,s);c[t>>2]=73927;sr(a,74652,t);c[u>>2]=73927;sr(a,74762,u);c[v>>2]=73927;sr(a,74853,v);c[w>>2]=73927;sr(a,74907,w);c[x>>2]=73927;sr(a,74976,x);sr(a,75012,y);c[z>>2]=73927;sr(a,75137,z);c[A>>2]=73927;sr(a,75166,A);sr(a,75206,C);c[E>>2]=73927;sr(a,75299,E);c[F>>2]=73927;sr(a,75358,F);c[G>>2]=73927;sr(a,75439,G);sr(a,75509,H);c[I>>2]=73927;sr(a,75598,I);c[J>>2]=73927;sr(a,75703,J);c[K>>2]=73927;sr(a,75779,K);c[L>>2]=73927;sr(a,75818,L);c[M>>2]=73927;sr(a,75917,M);c[N>>2]=73927;sr(a,75963,N);sr(a,76052,O);c[P>>2]=73927;sr(a,76093,P);c[Q>>2]=73927;sr(a,76176,Q);c[R>>2]=73927;sr(a,76277,R);h[T>>3]=e;h[T+8>>3]=d;sr(a,76341,T);sr(a,76369,U);sr(a,76377,V);l=W;return}function ff(a){a=a|0;var b=0;b=l;l=l+16|0;sr(a,74107,b);l=b;return}function gf(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0.0,i=0.0,j=0.0,k=0,m=0,n=0.0,o=0,p=0,q=0,r=0;r=l;l=l+48|0;q=r+24|0;p=r+8|0;o=r;switch(a[e+48>>0]|0){case 108:{k=d;i=+h[e+32>>3];j=+h[d>>3];break}case 114:{i=+h[e+32>>3];g=i;f=5;break}default:{i=+h[e+32>>3];g=i*.5;f=5}}if((f|0)==5){j=+h[d>>3]-g;h[d>>3]=j;k=d}m=e+4|0;f=c[m>>2]|0;g=+h[f+16>>3];d=d+8|0;n=+h[d>>3]+g*.004629629629629629;h[d>>3]=n;i=j+i*.006944444444444444;h[k>>3]=i;f=c[f>>2]|0;do if(f){d=c[41916]|0;if(d|0?(xJ(d,f)|0)==0:0)break;c[o>>2]=pf(f)|0;sr(b,74006,o);o=c[m>>2]|0;c[41916]=c[o>>2];g=+h[o+16>>3]}while(0);f=~~g;f=(f|0)>1?f:1;if((f|0)!=(c[41917]|0)){j=+h[16877];c[p>>2]=f;h[p+8>>3]=j;sr(b,74014,p);c[41917]=f}c[q>>2]=qf(c[e>>2]|0)|0;h[q+8>>3]=i;h[q+16>>3]=n;sr(b,74035,q);l=r;return}function hf(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0.0,i=0.0,j=0.0,k=0.0;e=l;l=l+48|0;f=e;i=+h[b>>3];k=(+h[b+16>>3]-i)*.027777777777777776;g=+h[b+8>>3];j=(+h[b+24>>3]-g)*.027777777777777776;c[f>>2]=1;c[f+4>>2]=d|0?73948:174181;h[f+8>>3]=k;h[f+16>>3]=j;h[f+24>>3]=i*.013888888888888888;h[f+32>>3]=g*.013888888888888888;sr(a,73954,f);l=e;return}function jf(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;e=l;l=l+16|0;nf(c[a+16>>2]|0,e+8|0,e);of(a,b,d,1);l=e;return}function kf(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0.0,v=0.0,w=0;t=l;l=l+128|0;s=t+112|0;q=t+104|0;p=t+96|0;e=t+88|0;n=t+16|0;o=t;k=c[a+16>>2]|0;j=ZI((d*140|0)+140|0)|0;nf(k,t+116|0,t+80|0);v=+h[b>>3];k=n+48|0;h[k>>3]=v;u=+h[b+8>>3];h[n+56>>3]=u;c[e>>2]=~~(v+(v>=0.0?.5:-.5));c[e+4>>2]=~~(u+(u>=0.0?.5:-.5));i=o+8|0;e=j+(pL(j,73932,e)|0)|0;r=1;g=0;while(1){m=g+3|0;if((m|0)>=(d|0))break;c[n>>2]=c[k>>2];c[n+4>>2]=c[k+4>>2];c[n+8>>2]=c[k+8>>2];c[n+12>>2]=c[k+12>>2];f=1;while(1){if((f|0)==4){f=1;break}w=f+g|0;h[n+(f<<4)>>3]=+h[b+(w<<4)>>3];h[n+(f<<4)+8>>3]=+h[b+(w<<4)+8>>3];f=f+1|0}while(1){if((f|0)==7)break;PA(o,n,3,+(f|0)*.16666666666666666,0,0);u=+h[o>>3];v=+h[i>>3];c[p>>2]=~~(u+(u>=0.0?.5:-.5));c[p+4>>2]=~~(v+(v>=0.0?.5:-.5));f=f+1|0;e=e+(pL(e,73932,p)|0)|0}r=r+6|0;g=m}c[q>>2]=j;sr(a,73939,q);_I(j);f=r+-1|0;e=0;while(1){if((e|0)>=(r|0))break;c[s>>2]=((e|0)%(f|0)|0|0)!=0&1;sr(a,73944,s);e=e+1|0}mr(a,134901)|0;l=t;return}function lf(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=l;l=l+16|0;nf(c[a+16>>2]|0,e+8|0,e);of(a,b,d,0);l=e;return}function mf(a,b){a=a|0;b=b|0;var d=0,e=0;d=l;l=l+16|0;e=d;c[e>>2]=73927;c[e+4>>2]=b;sr(a,73920,e);l=d;return}function nf(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0;switch(c[a+144>>2]|0){case 1:{e=10.0;a=1;break}case 2:{e=10.0;a=2;break}default:{e=0.0;a=0}}c[b>>2]=a;h[d>>3]=e;return}function of(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0.0,m=0.0;j=l;l=l+16|0;i=j+8|0;g=j;f=0;while(1){if((f|0)>=(d|0))break;m=+h[b+(f<<4)>>3];k=+h[b+(f<<4)+8>>3];c[g>>2]=~~(m+(m>=0.0?.5:-.5));c[g+4>>2]=~~(k+(k>=0.0?.5:-.5));sr(a,73932,g);f=f+1|0}if(e|0){k=+h[b>>3];m=+h[b+8>>3];c[i>>2]=~~(k+(k>=0.0?.5:-.5));c[i+4>>2]=~~(m+(m>=0.0?.5:-.5));sr(a,73932,i)}mr(a,134901)|0;l=j;return}function pf(b){b=b|0;var d=0,e=0,f=0,g=0,h=0;h=l;l=l+16|0;f=h;a:while(1){d=15756;while(1){e=c[d+4>>2]|0;if(!e)break;if(!(xJ(e,b)|0)){g=6;break a}d=d+8|0}c[f>>2]=74088;c[f+4>>2]=b;_l(1,74062,f)|0;d=HL(b,45)|0;if(!d){d=74105;break}a[d>>0]=0}l=h;return d|0}function qf(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;i=l;l=l+16|0;h=i;d=c[41918]|0;if(!d){c[41919]=64;d=ZI(64)|0;c[41918]=d;e=0}else e=0;while(1){g=b+1|0;f=a[b>>0]|0;if(!(f<<24>>24))break;b=c[41919]|0;if((e|0)>(b+-8|0)){d=b<<1;c[41919]=d;d=aJ(c[41918]|0,d)|0;c[41918]=d;d=d+e|0}if(f<<24>>24<=-1){a[d>>0]=92;c[h>>2]=f&255;pL(d+1|0,74057,h)|0;b=g;d=d+4|0;e=e+4|0;continue}if(f<<24>>24==92){a[d>>0]=92;e=e+1|0;d=d+1|0}a[d>>0]=f;b=g;d=d+1|0;e=e+1|0}a[d>>0]=0;l=i;return c[41918]|0}function rf(){var a=0,b=0;a=l;l=l+16|0;b=a;c[b>>2]=74088;c[b+4>>2]=76485;_l(0,76467,b)|0;l=a;return}function sf(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0.0,i=0.0,j=0,k=0;e=l;l=l+32|0;f=e+8|0;j=e;b=b+8|0;k=c[b>>2]|0;c[j>>2]=k;c[j+4>>2]=k;sr(a,77065,j);i=(+h[d>>3]+ +h[d+16>>3])*.5;g=(+h[d+8>>3]+ +h[d+24>>3])*.5;c[f>>2]=c[b>>2];h[f+8>>3]=i;h[f+16>>3]=g;sr(a,77107,f);l=e;return}function tf(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0.0,i=0.0,j=0.0,k=0.0;e=l;l=l+48|0;f=e;i=+h[d>>3];k=+h[d+16>>3]-i;g=+h[d+24>>3];j=g-+h[d+8>>3];g=+(~~(+h[a+232>>3]-+h[a+216>>3])>>>0)-g;c[f>>2]=c[b+8>>2];h[f+8>>3]=k;h[f+16>>3]=j;h[f+24>>3]=i;h[f+32>>3]=g;sr(a,77152,f);mr(a,77244)|0;l=e;return}function uf(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return}function vf(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,g=0.0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0.0;t=l;l=l+160|0;s=t+152|0;r=t+136|0;q=t+120|0;k=t+112|0;n=t+104|0;m=t+88|0;j=t+72|0;i=t+64|0;o=t;if(!a)ma(96061,77249,212,77268);if(!b)ma(96091,77249,213,77268);p=b+8|0;if(!(c[p>>2]|0))ma(96094,77249,214,77268);if(c[b+52>>2]|0){c[o>>2]=c[d>>2];c[o+4>>2]=c[d+4>>2];c[o+8>>2]=c[d+8>>2];c[o+12>>2]=c[d+12>>2];b=o+32|0;d=d+16|0;c[b>>2]=c[d>>2];c[b+4>>2]=c[d+4>>2];c[b+8>>2]=c[d+8>>2];c[b+12>>2]=c[d+12>>2];f=+h[o>>3];h[o+16>>3]=f;h[o+24>>3]=+h[o+40>>3];h[o+48>>3]=+h[b>>3];g=+h[o+8>>3];h[o+56>>3]=g;if(e<<24>>24){sr(a,77289,i);b=0;while(1){if((b|0)==4)break;u=+h[o+(b<<4)+8>>3];h[j>>3]=+h[o+(b<<4)>>3];h[j+8>>3]=u;sr(a,77292,j);b=b+1|0}h[m>>3]=f;h[m+8>>3]=g;sr(a,77292,m);m=c[p>>2]|0;c[n>>2]=4;c[n+4>>2]=m;sr(a,77299,n)}sr(a,77289,k);b=0;while(1){if((b|0)==4)break;u=+h[o+(b<<4)+8>>3];h[q>>3]=+h[o+(b<<4)>>3];h[q+8>>3]=u;sr(a,77292,q);b=b+1|0}h[r>>3]=f;h[r+8>>3]=g;sr(a,77292,r);r=c[p>>2]|0;c[s>>2]=4;c[s+4>>2]=r;sr(a,77314,s)}l=t;return}function wf(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0.0;o=l;l=l+112|0;n=o+24|0;m=o+16|0;k=o;i=o+28|0;if(!b)ma(96061,77249,153,77330);if(!d)ma(96091,77249,154,77330);if(!(c[d+8>>2]|0))ma(96094,77249,155,77330);j=d+52|0;if(c[j>>2]|0){f=d+60|0;g=c[f>>2]|0;if((g|0)==84)g=18;else{gb[g&127](d);c[j>>2]=0;c[f>>2]=0;c[d+56>>2]=0;g=10}}else g=10;do if((g|0)==10){if(!((Mr(d)|0)<<24>>24))break;f=zN(c[d+20>>2]|0)|0;if((c[d+24>>2]&-2|0)==6){_L(f,i)|0;i=c[i+36>>2]|0;c[d+56>>2]=i;f=pJ(0,i,1,1,f,0)|0;c[j>>2]=f;a[d+16>>0]=1}else f=c[j>>2]|0;if(f|0)c[d+60>>2]=84;Nr(d);if(c[j>>2]|0)g=18}while(0);if((g|0)==18){p=+h[e+8>>3]-+(c[d+36>>2]|0);h[k>>3]=+h[e>>3]-+(c[d+32>>2]|0);h[k+8>>3]=p;sr(b,77348,k);if(!(a[d+16>>0]|0)){c[m>>2]=c[d+12>>2];sr(b,77379,m)}else fy(b,d);sr(b,77394,n)}l=o;return}function xf(a){a=a|0;nJ(c[a+52>>2]|0,c[a+56>>2]|0)|0;return}function yf(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;g=l;l=l+80|0;f=g+48|0;if(!a)ma(96061,77249,121,77404);e=c[a+16>>2]|0;if(!e)ma(84921,77249,123,77404);if(!b)ma(96091,77249,124,77404);d=b+8|0;if(!(c[d>>2]|0))ma(96094,77249,125,77404);if(!(c[e+8>>2]|0))ma(123690,77249,128,77404);else{sr(a,77424,g);sr(a,77433,g+8|0);sr(a,77460,g+16|0);sr(a,77485,g+24|0);sr(a,77514,g+32|0);sr(a,77542,g+40|0);c[f>>2]=c[d>>2];sr(a,77549,f);sr(a,77588,g+56|0);sr(a,95830,g+64|0);l=g;return}}function zf(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0,m=0.0;i=l;l=l+128|0;g=i+80|0;f=i;if(!a)ma(96061,77249,97,77593);if(!b)ma(96091,77249,98,77593);e=c[b+8>>2]|0;if(!e)ma(96094,77249,99,77593);else{m=+h[d>>3];j=~~(m+(m>=0.0?.5:-.5));m=+h[d+8>>3];b=~~(m+(m>=0.0?.5:-.5));m=+h[d+16>>3];k=~~(m+(m>=0.0?.5:-.5));m=+h[d+24>>3];d=~~(m+(m>=0.0?.5:-.5));c[f>>2]=2;c[f+4>>2]=5;c[f+8>>2]=0;c[f+12>>2]=0;c[f+16>>2]=0;c[f+20>>2]=-1;c[f+24>>2]=1;c[f+28>>2]=-1;c[f+32>>2]=0;h[f+40>>3]=0.0;c[f+48>>2]=0;c[f+52>>2]=0;c[f+56>>2]=0;c[f+60>>2]=0;c[f+64>>2]=0;c[f+68>>2]=5;c[f+72>>2]=0;c[f+76>>2]=e;sr(a,77612,f);c[g>>2]=j;c[g+4>>2]=b;c[g+8>>2]=j;c[g+12>>2]=d;c[g+16>>2]=k;c[g+20>>2]=d;c[g+24>>2]=k;c[g+28>>2]=b;c[g+32>>2]=j;c[g+36>>2]=b;sr(a,77670,g);l=i;return}}function Af(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,g=0.0,i=0.0,j=0.0,k=0,m=0,n=0,o=0;o=l;l=l+96|0;n=o+56|0;m=o+32|0;k=o;i=+h[d>>3];j=+h[d+16>>3]-i;f=+h[d+24>>3];g=f-+h[d+8>>3];if(!a)ma(96061,77249,53,77702);if(!b)ma(96091,77249,54,77702);e=b+8|0;if(!(c[e>>2]|0))ma(96094,77249,55,77702);mr(a,77721)|0;mr(a,c[e>>2]|0)|0;e=a+360|0;f=-f;if(!(c[e>>2]|0)){h[n>>3]=j;h[n+8>>3]=g;h[n+16>>3]=i;h[n+24>>3]=f;sr(a,77850,n)}else{h[k>>3]=g;h[k+8>>3]=j;h[k+16>>3]=i;h[k+24>>3]=f;sr(a,77741,k);c[m>>2]=c[e>>2];h[m+8>>3]=i;h[m+16>>3]=f;sr(a,77820,m)}mr(a,77929)|0;l=o;return}function Bf(a){a=a|0;var b=0,c=0;b=co(a)|0;while(1){if(!b)break;Cf(b);b=eo(a,b)|0}c=co(a)|0;while(1){if(!c)break;b=Pm(a,c)|0;while(1){if(!b)break;Df(b);b=Rm(a,b)|0}c=eo(a,c)|0}return}function Cf(a){a=a|0;var b=0,d=0;No(a,122241,304,1)|0;WA(a);KB(a,c[(c[(ro(a)|0)+16>>2]|0)+116>>2]&1);a=a+16|0;c[(c[a>>2]|0)+176>>2]=0;b=vw(20)|0;d=c[a>>2]|0;c[d+172>>2]=b;c[d+184>>2]=0;d=vw(20)|0;b=c[a>>2]|0;c[b+180>>2]=d;c[b+200>>2]=0;b=vw(12)|0;d=c[a>>2]|0;c[d+196>>2]=b;c[d+192>>2]=0;d=vw(12)|0;b=c[a>>2]|0;c[b+188>>2]=d;c[b+208>>2]=0;b=vw(12)|0;a=c[a>>2]|0;c[a+204>>2]=b;c[a+216>>2]=1;return}function Df(d){d=d|0;var e=0,f=0,g=0,h=0,i=0;No(d,122254,176,1)|0;XA(d)|0;h=DA(d,c[42218]|0,1,0)|0;g=d+16|0;c[(c[g>>2]|0)+156>>2]=h;h=FA(c[((c[d>>2]&3|0)==3?d:d+48|0)+40>>2]|0,c[42212]|0,174181)|0;i=FA(c[((c[d>>2]&3|0)==2?d:d+-48|0)+40>>2]|0,c[42212]|0,174181)|0;e=c[g>>2]|0;f=e+154|0;b[f>>1]=1;b[e+168>>1]=1;if((h|0)==(i|0)&(a[h>>0]|0)!=0){b[f>>1]=1e3;i=e+156|0;c[i>>2]=(c[i>>2]|0)*100}if(zk(d)|0){i=c[g>>2]|0;b[i+154>>1]=0;c[i+156>>2]=0}i=(DA(d,c[42231]|0,0,0)|0)&255;a[(c[g>>2]|0)+152>>0]=i;i=(DA(d,c[42219]|0,1,0)|0)&65535;b[(c[g>>2]|0)+170>>1]=i;return}function Ef(a){a=a|0;var b=0,d=0;Ff(c[(c[a+16>>2]|0)+192>>2]|0);d=co(a)|0;while(1){if(!d)break;b=Pm(a,d)|0;while(1){if(!b)break;rB(b);b=Rm(a,b)|0}Gf(d);d=eo(a,d)|0}Hf(a);return}function Ff(b){b=b|0;var d=0,e=0,f=0,g=0;while(1){if(!b)break;f=b+16|0;g=c[(c[f>>2]|0)+164>>2]|0;If(b);d=c[f>>2]|0;if((a[d+156>>0]|0)!=1){b=g;continue}e=c[d+180>>2]|0;if(e){_I(e);d=c[f>>2]|0}e=c[d+172>>2]|0;if(e){_I(e);d=c[f>>2]|0}_I(d);_I(b);b=g}return}function Gf(a){a=a|0;var b=0,d=0,e=0;e=a+16|0;b=c[e>>2]|0;d=c[b+172>>2]|0;if(d){_I(d);b=c[e>>2]|0}d=c[b+180>>2]|0;if(d){_I(d);b=c[e>>2]|0}d=c[b+188>>2]|0;if(d){_I(d);b=c[e>>2]|0}d=c[b+196>>2]|0;if(d){_I(d);b=c[e>>2]|0}d=c[b+204>>2]|0;if(d){_I(d);b=c[e>>2]|0}ow(c[b+104>>2]|0);ow(c[(c[e>>2]|0)+108>>2]|0);b=c[(c[e>>2]|0)+8>>2]|0;if(b|0)gb[c[(c[b+4>>2]|0)+4>>2]&127](a);Po(a,122241)|0;return}function Hf(a){a=a|0;var d=0,e=0,f=0;d=Jp(a)|0;while(1){if(!d)break;Hf(d);d=Kp(d)|0}if(No(a,122277,0,1)|0){f=a+16|0;d=c[f>>2]|0;e=c[d+184>>2]|0;if(e){_I(e);d=c[f>>2]|0}e=c[d+268>>2]|0;if(e){_I(e);d=c[f>>2]|0}e=c[d+216>>2]|0;if(e){_I(e);d=c[f>>2]|0}do if(c[d+196>>2]|0){e=b[d+236>>1]|0;while(1){if((e|0)>(b[d+238>>1]|0))break;_I(c[(c[d+196>>2]|0)+(e<<6)+12>>2]|0);e=e+1|0;d=c[f>>2]|0}e=c[d+196>>2]|0;if((b[d+236>>1]|0)==-1){_I(e+-64|0);break}else{_I(e);break}}while(0);if((so(a)|0)!=(a|0)){ow(c[(c[f>>2]|0)+12>>2]|0);Po(a,122277)|0}}return}function If(a){a=a|0;var b=0,d=0,e=0;e=a+16|0;d=c[e>>2]|0;b=c[d+176>>2]|0;while(1){a=b+-1|0;if((b|0)<=0)break;b=c[(c[d+172>>2]|0)+(a<<2)>>2]|0;Xg(b);_I(c[b+16>>2]|0);_I(b);b=a;d=c[e>>2]|0}b=c[d+184>>2]|0;while(1){a=b+-1|0;if((b|0)<=0)break;b=c[(c[(c[e>>2]|0)+180>>2]|0)+(a<<2)>>2]|0;Xg(b);_I(c[b+16>>2]|0);_I(b);b=a}return}function Jf(a){a=a|0;if(mn(a)|0)Kf(a);$x(a);return}function Kf(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0;h=l;l=l+48|0;g=h+32|0;f=h;b=et(a,-1,8)|0;d=ft(a,0,f)|0;dt(a,2,8,f)|0;d=(d|0)==0;e=(b|0)<0;if(e&d)Lf(a);else{if(d)c[f+16>>2]=3;else b=e?8:b;c[f+8>>2]=b;c[f+20>>2]=0;e=Bs(a,g,0)|0;b=c[g>>2]|0;do if((b|0)==1){Lf(a);b=0}else{if(c[(c[(c[a+16>>2]|0)+8>>2]|0)+84>>2]|0){Lf(a);b=0;break}c[f+12>>2]=1;d=0;while(1){if((d|0)>=(b|0))break;b=c[e+(d<<2)>>2]|0;Mf(b,a);Lf(b);d=d+1|0;b=c[g>>2]|0}Nf(a);ct(c[g>>2]|0,e,a,f)|0;Of(a);Pf(c[g>>2]|0,e,a);b=0}while(0);while(1){if((b|0)>=(c[g>>2]|0))break;f=e+(b<<2)|0;_I(c[(c[(c[f>>2]|0)+16>>2]|0)+8>>2]|0);Hf(c[f>>2]|0);qo(a,c[f>>2]|0)|0;b=b+1|0}_I(e)}l=h;return}function Lf(a){a=a|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0;m=l;l=l+48|0;k=m+40|0;e=m;i=DA(a,ym(a,0,77944,0)|0,-1,1)|0;IB(a,10);d=yk(a,e)|0;Rf(a,a);Bf(a);f=(i|0)==1;g=e+32|0;h=(i|0)==2;i=(i|0)==3;j=e+28|0;e=e+24|0;while(1){kj(a,d);if(f){d=3;break}if(c[g>>2]|0){_l(0,77950,k)|0;c[e>>2]=0;d=0}uh(a,(d|0)!=0&1);if(h){d=7;break}xi(a,d);if(i){d=9;break}n=(c[j>>2]|0)+-1|0;c[j>>2]=n;if(!((n|0)!=0&(c[e>>2]|0)!=0)){d=11;break}}if((d|0)==3)Sf(a,1);else if((d|0)==7)Sf(a,2);else if((d|0)==9)Sf(a,2);else if((d|0)==11){if(b[(c[a+16>>2]|0)+136>>1]&16)Tf(a);ek(a);Xf(a);if((IA(Im(a,78041)|0)|0)<<24>>24)_k(a)}l=m;return}function Mf(b,d){b=b|0;d=d|0;var e=0,f=0;No(b,122277,280,1)|0;e=vw(96)|0;b=c[b+16>>2]|0;c[b+8>>2]=e;d=c[d+16>>2]|0;f=c[d+8>>2]|0;h[e>>3]=+h[f>>3];h[e+24>>3]=+h[f+24>>3];c[b+144>>2]=c[d+144>>2];a[b+115>>0]=a[d+115>>0]|0;c[b+116>>2]=c[d+116>>2];c[b+248>>2]=c[d+248>>2];c[b+252>>2]=c[d+252>>2];c[b+244>>2]=c[d+244>>2];return}function Nf(a){a=a|0;var b=0,d=0,e=0;b=vw((mn(a)|0)<<4)|0;d=co(a)|0;while(1){if(!d)break;e=c[d+16>>2]|0;c[e+132>>2]=b;h[b>>3]=+h[e+16>>3]*.013888888888888888;h[b+8>>3]=+h[e+24>>3]*.013888888888888888;b=b+16|0;d=eo(a,d)|0}return}function Of(a){a=a|0;var b=0,d=0,e=0,f=0;e=c[(c[(co(a)|0)+16>>2]|0)+132>>2]|0;b=e;d=co(a)|0;while(1){if(!d)break;f=c[d+16>>2]|0;c[f+132>>2]=0;h[f+16>>3]=+h[b>>3]*72.0;h[f+24>>3]=+h[b+8>>3]*72.0;b=b+16|0;d=eo(a,d)|0}_I(e);return}function Pf(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;e=0;f=0;while(1){if((e|0)>=(a|0))break;i=(c[(c[(c[b+(e<<2)>>2]|0)+16>>2]|0)+180>>2]|0)+f|0;e=e+1|0;f=i}i=d+16|0;c[(c[i>>2]|0)+180>>2]=f;g=vw((f<<2)+4|0)|0;c[(c[i>>2]|0)+184>>2]=g;g=0;e=1;while(1){if((g|0)>=(a|0))break;h=(c[b+(g<<2)>>2]|0)+16|0;f=1;while(1){d=c[h>>2]|0;if((f|0)>(c[d+180>>2]|0))break;d=As(c[(c[d+184>>2]|0)+(f<<2)>>2]|0)|0;c[(c[(c[i>>2]|0)+184>>2]|0)+(e<<2)>>2]=d;Qf(c[(c[(c[h>>2]|0)+184>>2]|0)+(f<<2)>>2]|0,d);f=f+1|0;e=e+1|0}g=g+1|0}return}function Qf(b,d){b=b|0;d=d|0;var e=0,f=0,g=0;No(d,122277,280,1)|0;g=d+16|0;d=(c[g>>2]|0)+16|0;f=b+16|0;b=(c[f>>2]|0)+16|0;c[d>>2]=c[b>>2];c[d+4>>2]=c[b+4>>2];c[d+8>>2]=c[b+8>>2];c[d+12>>2]=c[b+12>>2];c[d+16>>2]=c[b+16>>2];c[d+20>>2]=c[b+20>>2];c[d+24>>2]=c[b+24>>2];c[d+28>>2]=c[b+28>>2];b=c[f>>2]|0;d=c[g>>2]|0;a[d+275>>0]=a[b+275>>0]|0;d=d+48|0;b=b+48|0;e=d+64|0;do{c[d>>2]=c[b>>2];d=d+4|0;b=b+4|0}while((d|0)<(e|0));b=c[(c[f>>2]|0)+180>>2]|0;c[(c[g>>2]|0)+180>>2]=b;d=vw((b<<2)+4|0)|0;c[(c[g>>2]|0)+184>>2]=d;d=1;while(1){e=c[f>>2]|0;if((d|0)>(b|0))break;e=As(c[(c[e+184>>2]|0)+(d<<2)>>2]|0)|0;c[(c[(c[g>>2]|0)+184>>2]|0)+(d<<2)>>2]=e;Qf(c[(c[(c[f>>2]|0)+184>>2]|0)+(d<<2)>>2]|0,e);d=d+1|0}f=e+12|0;c[(c[g>>2]|0)+12>>2]=c[f>>2];c[f>>2]=0;return}function Rf(a,b){a=a|0;b=b|0;if((so(a)|0)!=(a|0))No(a,122277,280,1)|0;if((a|0)==(b|0))c[(c[(so(a)|0)+16>>2]|0)+188>>2]=a;a=Jp(a)|0;while(1){if(!a)break;Rf(a,b);a=Kp(a)|0}return}function Sf(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0;m=l;l=l+1040|0;k=m+8|0;j=m;e=m+16|0;f=ym(a,1,80018,174181)|0;g=ym(a,1,78084,174181)|0;h=(b|0)>0;d=(b|0)==1;b=co(a)|0;while(1){if(!b)break;if(h?(i=b+16|0,c[j>>2]=c[(c[i>>2]|0)+232>>2],pL(e,122187,j)|0,Cm(b,f,e)|0,!d):0){c[k>>2]=c[(c[i>>2]|0)+236>>2];pL(e,122187,k)|0;Cm(b,g,e)|0}b=eo(a,b)|0}l=m;return}function Tf(a){a=a|0;var b=0,c=0,d=0;c=Ip(a,79522,0)|0;if(c|0){b=co(c)|0;while(1){if(!b)break;d=eo(c,b)|0;dh(a,b);Uf(a,b);Gf(b);po(a,b)|0;b=d}Mp(a,c)|0}return}function Uf(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0;j=c[(c[b+16>>2]|0)+232>>2]|0;i=a+16|0;a=c[(c[i>>2]|0)+196>>2]|0;d=c[a+(j<<6)>>2]|0;h=a+(j<<6)+4|0;g=0;e=0;while(1){if((e|0)>=(d|0)){f=7;break}f=c[(c[h>>2]|0)+(e<<2)>>2]|0;e=e+1|0;if((f|0)==(b|0)){f=4;break}else g=f}if((f|0)==4){while(1){if((e|0)>=(d|0))break;f=c[a+(j<<6)+4>>2]|0;c[f+(e+-1<<2)>>2]=c[f+(e<<2)>>2];f=c[(c[i>>2]|0)+196>>2]|0;e=e+1|0;d=c[f+(j<<6)>>2]|0;a=f;f=4}c[a+(j<<6)>>2]=d+-1}else if((f|0)==7?(g|0)!=(b|0):0)ma(78050,78057,248,78067);return}function Vf(a){a=a|0;return c[(c[(so(a)|0)+16>>2]|0)+188>>2]|0}function Wf(b,c){b=b|0;c=c|0;var d=0;d=a[b+28>>0]|0;if(a[c+28>>0]|0)if(d<<24>>24){d=~~(+h[b>>3]-+h[c>>3]);if(!d)d=~~(+h[b+8>>3]-+h[c+8>>3])}else d=-1;else d=d<<24>>24!=0&1;return d|0}function Xf(a){a=a|0;Yf(a,1);return}function Yf(d,e){d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0.0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0.0;Z=l;l=l+656|0;O=Z+592|0;N=Z+552|0;f=Z+544|0;T=Z+96|0;U=Z;Y=Z+632|0;V=d+16|0;X=b[(c[V>>2]|0)+136>>1]&14;P=X&65535;Q=T+16|0;c[Q>>2]=Z+368;R=U+16|0;c[R>>2]=Z+192;do if(X<<16>>16){S=X<<16>>16==4;do if(S){Zf(d);if(!(a[(c[(c[d+60>>2]|0)+16>>2]|0)+113>>0]&1))A=9;else{_l(0,78090,f)|0;A=9}}else if(X<<16>>16==8){Zf(d);if(!(a[(c[(c[d+60>>2]|0)+16>>2]|0)+113>>0]&1)){LB(d,0);n=0;m=0;k=0;break}else{_f(d);LB(d,1);n=0;m=0;k=0;break}}else A=9;while(0);if((A|0)==9){Yk(d);if(ly()|0)break;W=vw(96)|0;K=c[(c[V>>2]|0)+248>>2]|0;c[Y+8>>2]=(K|0)/4|0;c[Y+12>>2]=K;k=vw(512)|0;F=Y+4|0;c[F>>2]=0;c[Y>>2]=0;j=c[V>>2]|0;C=b[j+236>>1]|0;D=0;L=0;M=k;E=k;m=k;n=k;o=k;H=0;I=0;a:while(1){if((C|0)>(b[j+238>>1]|0))break;p=c[j+196>>2]|0;i=c[p+(C<<6)>>2]|0;G=i+D|0;g=c[p+(C<<6)+4>>2]|0;f=c[g>>2]|0;if(!f)f=H;else{_=+(H|0);f=c[f+16>>2]|0;y=+h[f+16>>3]-+h[f+88>>3];f=~~(y>_?_:y)}if((i|0)!=0?(J=c[g+(i+-1<<2)>>2]|0,(J|0)!=0):0){y=+(I|0);g=c[J+16>>2]|0;_=+h[g+96>>3]+ +h[g+16>>3];g=~~(_=(i|0))break;k=c[(c[f+(C<<6)+4>>2]|0)+(x<<2)>>2]|0;w=k+16|0;f=c[w>>2]|0;i=c[f+112>>2]|0;if(i){i=i+16|0;j=c[(c[i>>2]|0)+96>>2]|0;if(!j){A=21;break a}s=j+56|0;f=f+16|0;c[s>>2]=c[f>>2];c[s+4>>2]=c[f+4>>2];c[s+8>>2]=c[f+8>>2];c[s+12>>2]=c[f+12>>2];a[(c[(c[i>>2]|0)+96>>2]|0)+81>>0]=1;f=c[w>>2]|0}if((a[f+156>>0]|0)!=0?($a[c[17228>>2]&31](k)|0)<<24>>24==0:0){q=t;f=r;j=u;k=v;i=o}else{s=0;q=t;j=u;k=v;A=25}b:do if((A|0)==25){while(1){A=0;p=c[w>>2]|0;i=c[(c[p+180>>2]|0)+(s<<2)>>2]|0;if(!i)break;switch(a[(c[i+16>>2]|0)+112>>0]|0){case 6:case 4:{f=q;i=r;break}default:{$f(i,1,16,64);f=q+1|0;c[r+(q<<2)>>2]=i;if(!(f&127)){g=yw(g,(q<<2)+516|0)|0;i=g;j=g;k=g;n=g;o=g}else i=r}}s=s+1|0;q=f;r=i;A=25}f=c[p+188>>2]|0;c:do if(!f)i=o;else{s=0;i=o;while(1){f=c[f+(s<<2)>>2]|0;if(!f)break c;$f(f,2,0,128);o=q+1|0;c[r+(q<<2)>>2]=f;if(!(o&127)){g=yw(i,(q<<2)+516|0)|0;f=g;j=g;k=g;n=g;i=g}else f=r;p=c[w>>2]|0;s=s+1|0;q=o;r=f;f=c[p+188>>2]|0}}while(0);f=c[p+204>>2]|0;if(!f)f=r;else{if(!(a[p+156>>0]|0)){v=p+96|0;_=+h[v>>3];s=p+240|0;h[v>>3]=+h[s>>3];h[s>>3]=_;s=0;p=r}else{s=0;p=r}while(1){f=c[f+(s<<2)>>2]|0;if(!f){f=p;break b}$f(f,0,0,128);o=q+1|0;c[p+(q<<2)>>2]=f;if(!(o&127)){g=yw(n,(q<<2)+516|0)|0;f=g;j=g;k=g;n=g;i=g}else f=p;s=s+1|0;q=o;p=f;f=c[(c[w>>2]|0)+204>>2]|0}}}while(0);u=c[V>>2]|0;w=c[u+196>>2]|0;x=x+1|0;t=q;r=f;q=u;u=j;v=k;o=i;i=c[w+(C<<6)>>2]|0;f=w}C=C+1|0;D=G;L=t;M=r;E=u;j=q;m=v;k=g;H=B;I=z}if((A|0)==21)ma(78158,78171,313,78184);c[Y>>2]=H;c[F>>2]=I;rL(E,L,4,10);c[W+84>>2]=vw((D<<5)+11520|0)|0;c[Y+16>>2]=vw(C<<5)|0;d:do if(X<<16>>16==2){f=(c[V>>2]|0)+192|0;while(1){g=c[f>>2]|0;if(!g)break d;i=g+16|0;f=c[i>>2]|0;if((a[f+156>>0]|0)==1?(c[f+104>>2]|0)!=0:0){bg(g);f=c[i>>2]|0}f=f+164|0}}while(0);z=U+48|0;A=U+-48|0;B=T+48|0;C=T+-48|0;y=+(K|0);x=0;e:while(1){if((x|0)>=(L|0))break;v=M+(x<<2)|0;r=c[v>>2]|0;s=cg(r)|0;t=r+16|0;g=c[t>>2]|0;if(!(a[g+44>>0]|0)){g=(a[g+84>>0]|0)==0?s:r;f=g;g=c[g+16>>2]|0}else f=r;i=f+16|0;if(c[g+164>>2]&32){g=c[Q>>2]|0;TN(g|0,c[i>>2]|0,176)|0;n=T;o=f;p=n+48|0;do{c[n>>2]=c[o>>2];n=n+4|0;o=o+4|0}while((n|0)<(p|0));c[Q>>2]=g;o=c[f>>2]&3;n=c[T>>2]&3;c[((n|0)==3?T:B)+40>>2]=c[((o|0)==2?f:f+-48|0)+40>>2];c[((n|0)==2?T:C)+40>>2]=c[((o|0)==3?f:f+48|0)+40>>2];n=g+16|0;o=(c[i>>2]|0)+56|0;p=n+40|0;do{c[n>>2]=c[o>>2];n=n+4|0;o=o+4|0}while((n|0)<(p|0));n=g+56|0;o=(c[i>>2]|0)+16|0;p=n+40|0;do{c[n>>2]=c[o>>2];n=n+4|0;o=o+4|0}while((n|0)<(p|0));a[g+112>>0]=1;c[g+116>>2]=f;f=T}q=f+16|0;w=1;f=x;while(1){u=f+1|0;if((u|0)>=(L|0))break;j=M+(u<<2)|0;f=c[j>>2]|0;if((s|0)!=(cg(f)|0))break;if(!(a[(c[t>>2]|0)+113>>0]|0)){k=f+16|0;g=c[k>>2]|0;if(!(a[g+44>>0]|0)){g=(a[g+84>>0]|0)==0?s:f;f=g;g=c[g+16>>2]|0}i=f+16|0;if(c[g+164>>2]&32){g=c[R>>2]|0;TN(g|0,c[i>>2]|0,176)|0;n=U;o=f;p=n+48|0;do{c[n>>2]=c[o>>2];n=n+4|0;o=o+4|0}while((n|0)<(p|0));c[R>>2]=g;o=c[f>>2]&3;n=c[U>>2]&3;c[((n|0)==3?U:z)+40>>2]=c[((o|0)==2?f:f+-48|0)+40>>2];c[((n|0)==2?U:A)+40>>2]=c[((o|0)==3?f:f+48|0)+40>>2];n=g+16|0;o=(c[i>>2]|0)+56|0;p=n+40|0;do{c[n>>2]=c[o>>2];n=n+4|0;o=o+4|0}while((n|0)<(p|0));n=g+56|0;o=(c[i>>2]|0)+16|0;p=n+40|0;do{c[n>>2]=c[o>>2];n=n+4|0;o=o+4|0}while((n|0)<(p|0));a[g+112>>0]=1;c[g+116>>2]=f}i=c[q>>2]|0;f=g+16|0;n=N;o=i+16|0;p=n+40|0;do{c[n>>2]=c[o>>2];n=n+4|0;o=o+4|0}while((n|0)<(p|0));n=O;o=f;p=n+40|0;do{c[n>>2]=c[o>>2];n=n+4|0;o=o+4|0}while((n|0)<(p|0));if(Wf(N,O)|0)break;f=g+56|0;n=N;o=i+56|0;p=n+40|0;do{c[n>>2]=c[o>>2];n=n+4|0;o=o+4|0}while((n|0)<(p|0));n=O;o=f;p=n+40|0;do{c[n>>2]=c[o>>2];n=n+4|0;o=o+4|0}while((n|0)<(p|0));if(Wf(N,O)|0)break;K=c[t>>2]|0;if((c[K+164>>2]&15|0)==2?(c[K+96>>2]|0)!=(c[(c[k>>2]|0)+96>>2]|0):0)break;if(c[(c[(c[j>>2]|0)+16>>2]|0)+164>>2]&64|0)break}w=w+1|0;f=u}if(S){if((w|0)==1)f=O;else f=vw(w<<2)|0;c[f>>2]=cg(c[v>>2]|0)|0;g=1;while(1){if((g|0)>=(w|0))break;c[f+(g<<2)>>2]=c[v+(g<<2)>>2];g=g+1|0}uy(d,f,w,P,17224);if((w|0)>1)_I(f);x=u;continue}f=c[r>>2]&3;K=c[((f|0)==3?r:r+48|0)+40>>2]|0;f=c[((f|0)==2?r:r+-48|0)+40>>2]|0;g=c[K+16>>2]|0;i=c[g+232>>2]|0;if((K|0)!=(f|0))if((i|0)==(c[(c[f+16>>2]|0)+232>>2]|0)){dg(d,Y,W,M,x,w,P);x=u;continue}else{eg(d,Y,W,M,x,w,P);x=u;continue}f=c[V>>2]|0;do if((i|0)==(b[f+238>>1]|0))if((i|0)>0){f=~~(+h[(c[(c[c[(c[f+196>>2]|0)+(i+-1<<6)+4>>2]>>2]|0)+16>>2]|0)+24>>3]-+h[g+24>>3]);break}else{f=~~+h[g+80>>3];break}else if((i|0)==(b[f+236>>1]|0)){f=~~(+h[g+24>>3]-+h[(c[(c[c[(c[f+196>>2]|0)+(i+1<<6)+4>>2]>>2]|0)+16>>2]|0)+24>>3]);break}else{f=c[f+196>>2]|0;_=+h[g+24>>3];K=~~(+h[(c[(c[c[f+(i+-1<<6)+4>>2]>>2]|0)+16>>2]|0)+24>>3]-_);f=~~(_-+h[(c[(c[c[f+(i+1<<6)+4>>2]>>2]|0)+16>>2]|0)+24>>3]);f=(K|0)<(f|0)?K:f;break}while(0);Rz(W,M,x,w,y,+((f|0)/2|0|0),17224);f=0;while(1){if((f|0)>=(w|0)){x=u;continue e}g=c[(c[(c[M+(f+x<<2)>>2]|0)+16>>2]|0)+96>>2]|0;if(g|0)bB(d,g);f=f+1|0}}f=(c[V>>2]|0)+192|0;while(1){g=c[f>>2]|0;if(!g)break;i=g+16|0;f=c[i>>2]|0;if((a[f+156>>0]|0)==1?(c[f+104>>2]|0)!=0:0){bg(g);bB(d,c[(c[i>>2]|0)+104>>2]|0);f=c[i>>2]|0}f=f+164|0}if(!e){n=W;k=W}else{fg(d);n=W;k=W}}f:do if((c[42241]|0)!=0|(c[42242]|0)!=0?(c[42247]|0)!=0|(c[42246]|0)!=0:0){j=co(d)|0;while(1){if(!j)break f;g:do if(c[42241]|0){f=Sm(d,j)|0;while(1){if(!f)break g;g=f+-48|0;i=(c[f>>2]&3|0)==2?f:g;if(c[(c[i+16>>2]|0)+100>>2]|0){Zz(i,1)|0;bB(d,c[(c[((c[f>>2]&3|0)==2?f:g)+16>>2]|0)+100>>2]|0)}f=Tm(d,f)|0}}while(0);h:do if(c[42242]|0){f=Pm(d,j)|0;while(1){if(!f)break h;g=f+16|0;if(c[(c[g>>2]|0)+104>>2]|0?Zz(f,0)|0:0)bB(d,c[(c[g>>2]|0)+104>>2]|0);f=Rm(d,f)|0}}while(0);j=eo(d,j)|0}}while(0);switch(X&15){case 4:case 8:break;default:{_I(m);_I(c[n+84>>2]|0);_I(k);_I(c[Y+16>>2]|0);my()}}c[42181]=1;c[42182]=1}while(0);l=Z;return}function Zf(a){a=a|0;var b=0,d=0,e=0.0,f=0;b=co(a)|0;while(1){if(!b)break;d=c[b+16>>2]|0;if(c[d+204>>2]|0){f=d+96|0;e=+h[f>>3];d=d+240|0;h[f>>3]=+h[d>>3];h[d>>3]=e}b=eo(a,b)|0}return}function _f(b){b=b|0;var d=0,e=0,f=0,g=0;d=(c[b+16>>2]|0)+192|0;a:while(1){f=c[d>>2]|0;if(!f){d=12;break}g=f+16|0;d=c[g>>2]|0;do if((a[d+156>>0]|0)==1){e=c[d+112>>2]|0;if(!e){e=c[d+104>>2]|0;if(!e)break;bg(f);d=e}else{e=c[(c[e+16>>2]|0)+96>>2]|0;if(!e){d=6;break a}f=e+56|0;d=d+16|0;c[f>>2]=c[d>>2];c[f+4>>2]=c[d+4>>2];c[f+8>>2]=c[d+8>>2];c[f+12>>2]=c[d+12>>2];a[e+81>>0]=1;d=e}bB(b,d);d=c[g>>2]|0}while(0);d=d+164|0}if((d|0)==6)ma(78358,78171,234,78377);else if((d|0)==12)return}function $f(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0;do if(!d){g=c[b>>2]&3;d=c[((g|0)==3?b:b+48|0)+40>>2]|0;g=c[((g|0)==2?b:b+-48|0)+40>>2]|0;if((d|0)!=(g|0)){d=(c[(c[d+16>>2]|0)+232>>2]|0)==(c[(c[g+16>>2]|0)+232>>2]|0)?2:1;break}d=c[b+16>>2]|0;if(!(a[d+44>>0]|0))d=(a[d+84>>0]|0)==0?8:4;else d=4}while(0);a:do if(!e)switch(d|0){case 1:{e=c[b>>2]&3;e=(c[(c[(c[((e|0)==3?b:b+48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)<(c[(c[(c[((e|0)==2?b:b+-48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)?16:32;break a}case 2:{e=c[b>>2]&3;e=(c[(c[(c[((e|0)==3?b:b+48|0)+40>>2]|0)+16>>2]|0)+236>>2]|0)<(c[(c[(c[((e|0)==2?b:b+-48|0)+40>>2]|0)+16>>2]|0)+236>>2]|0)?16:32;break a}default:{e=16;break a}}while(0);c[(c[b+16>>2]|0)+164>>2]=d|f|e;return}function ag(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;D=l;l=l+624|0;z=D+584|0;y=D+544|0;s=D+368|0;e=D+192|0;t=D+96|0;v=D;u=t+16|0;c[u>>2]=s;w=v+16|0;c[w>>2]=e;C=c[b>>2]|0;B=c[d>>2]|0;x=C+16|0;q=c[x>>2]|0;d=c[q+164>>2]|0;f=d&15;A=B+16|0;b=c[A>>2]|0;g=c[b+164>>2]&15;do if((g|0)==(f|0)){p=cg(C)|0;r=cg(B)|0;n=c[p>>2]|0;g=n&3;f=c[(c[((g|0)==3?p:p+48|0)+40>>2]|0)+16>>2]|0;g=c[(c[((g|0)==2?p:p+-48|0)+40>>2]|0)+16>>2]|0;i=(c[f+232>>2]|0)-(c[g+232>>2]|0)|0;o=c[r>>2]|0;m=o&3;k=c[(c[((m|0)==3?r:r+48|0)+40>>2]|0)+16>>2]|0;m=c[(c[((m|0)==2?r:r+-48|0)+40>>2]|0)+16>>2]|0;j=(c[k+232>>2]|0)-(c[m+232>>2]|0)|0;i=(i|0)>-1?i:0-i|0;j=(j|0)>-1?j:0-j|0;if((i|0)!=(j|0)){b=i-j|0;break}g=~~(+h[f+16>>3]-+h[g+16>>3]);g=(g|0)>-1?g:0-g|0;f=~~(+h[k+16>>3]-+h[m+16>>3]);f=(f|0)>-1?f:0-f|0;if((g|0)!=(f|0)){b=g-f|0;break}g=n>>>4;f=o>>>4;if((g|0)!=(f|0)){b=g-f|0;break}if(!(a[q+44>>0]|0)){d=(a[q+84>>0]|0)==0?p:C;g=d;d=c[(c[d+16>>2]|0)+164>>2]|0}else g=C;f=g+16|0;if(d&32){TN(s|0,c[f>>2]|0,176)|0;i=t;j=g;k=i+48|0;do{c[i>>2]=c[j>>2];i=i+4|0;j=j+4|0}while((i|0)<(k|0));c[u>>2]=s;j=c[g>>2]&3;i=c[t>>2]&3;c[((i|0)==3?t:t+48|0)+40>>2]=c[((j|0)==2?g:g+-48|0)+40>>2];c[((i|0)==2?t:t+-48|0)+40>>2]=c[((j|0)==3?g:g+48|0)+40>>2];i=s+16|0;j=(c[f>>2]|0)+56|0;k=i+40|0;do{c[i>>2]=c[j>>2];i=i+4|0;j=j+4|0}while((i|0)<(k|0));i=s+56|0;j=(c[f>>2]|0)+16|0;k=i+40|0;do{c[i>>2]=c[j>>2];i=i+4|0;j=j+4|0}while((i|0)<(k|0));a[s+112>>0]=1;c[s+116>>2]=g;g=t;b=c[A>>2]|0}if(!(a[b+44>>0]|0)){b=(a[b+84>>0]|0)==0?r:B;f=b;b=c[b+16>>2]|0}else f=B;d=f+16|0;if(!(c[b+164>>2]&32))e=b;else{TN(e|0,c[d>>2]|0,176)|0;i=v;j=f;k=i+48|0;do{c[i>>2]=c[j>>2];i=i+4|0;j=j+4|0}while((i|0)<(k|0));c[w>>2]=e;j=c[f>>2]&3;i=c[v>>2]&3;c[((i|0)==3?v:v+48|0)+40>>2]=c[((j|0)==2?f:f+-48|0)+40>>2];c[((i|0)==2?v:v+-48|0)+40>>2]=c[((j|0)==3?f:f+48|0)+40>>2];i=e+16|0;j=(c[d>>2]|0)+56|0;k=i+40|0;do{c[i>>2]=c[j>>2];i=i+4|0;j=j+4|0}while((i|0)<(k|0));i=e+56|0;j=(c[d>>2]|0)+16|0;k=i+40|0;do{c[i>>2]=c[j>>2];i=i+4|0;j=j+4|0}while((i|0)<(k|0));a[e+112>>0]=1;c[e+116>>2]=f}d=c[g+16>>2]|0;b=e+16|0;i=y;j=d+16|0;k=i+40|0;do{c[i>>2]=c[j>>2];i=i+4|0;j=j+4|0}while((i|0)<(k|0));i=z;j=b;k=i+40|0;do{c[i>>2]=c[j>>2];i=i+4|0;j=j+4|0}while((i|0)<(k|0));b=Wf(y,z)|0;if(!b){b=e+56|0;i=y;j=d+56|0;k=i+40|0;do{c[i>>2]=c[j>>2];i=i+4|0;j=j+4|0}while((i|0)<(k|0));i=z;j=b;k=i+40|0;do{c[i>>2]=c[j>>2];i=i+4|0;j=j+4|0}while((i|0)<(k|0));b=Wf(y,z)|0;if(!b){d=c[(c[x>>2]|0)+164>>2]&192;b=c[(c[A>>2]|0)+164>>2]&192;if((d|0)==(b|0)){b=((c[C>>2]|0)>>>4)-((c[B>>2]|0)>>>4)|0;break}else{b=d-b|0;break}}}}else b=g-f|0;while(0);l=D;return b|0}function bg(b){b=b|0;var d=0,e=0,f=0,g=0.0,i=0.0;f=b+16|0;d=c[f>>2]|0;if(c[d+176>>2]|0){d=c[d+180>>2]|0;while(1){d=(c[d>>2]|0)+16|0;e=c[d>>2]|0;if(!(a[e+112>>0]|0))break;else d=e+116|0}e=c[e+96>>2]|0;g=+h[e+24>>3];i=+h[e+32>>3];e=(c[(c[(ro(b)|0)+16>>2]|0)+116>>2]&1|0)!=0;b=c[f>>2]|0;f=c[(c[d>>2]|0)+96>>2]|0;h[f+56>>3]=(e?i:g)*.5+ +h[b+16>>3];h[f+64>>3]=+h[b+24>>3];a[f+81>>0]=1}return}function cg(a){a=a|0;var b=0,d=0;while(1){b=c[a+16>>2]|0;d=c[b+172>>2]|0;if(!d)break;else a=d}while(1){b=c[b+116>>2]|0;if(!b)break;a=b;b=c[b+16>>2]|0}return a|0}function dg(b,d,e,f,g,i,j){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;i=i|0;j=j|0;var k=0,m=0.0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0;B=l;l=l+1712|0;x=B+1664|0;s=B+1488|0;t=B+1392|0;A=B+1696|0;y=B+696|0;z=B;p=t+16|0;c[p>>2]=s;q=c[f+(g<<2)>>2]|0;r=q+16|0;k=c[r>>2]|0;u=a[k+113>>0]|0;if(c[k+164>>2]&32){TN(s|0,k|0,176)|0;k=t;n=q;o=k+48|0;do{c[k>>2]=c[n>>2];k=k+4|0;n=n+4|0}while((k|0)<(o|0));c[p>>2]=s;k=c[t>>2]&3;c[((k|0)==3?t:t+48|0)+40>>2]=c[((c[q>>2]&3|0)==2?q:q+-48|0)+40>>2];c[((k|0)==2?t:t+-48|0)+40>>2]=c[((c[q>>2]&3|0)==3?q:q+48|0)+40>>2];k=s+16|0;n=(c[r>>2]|0)+56|0;o=k+40|0;do{c[k>>2]=c[n>>2];k=k+4|0;n=n+4|0}while((k|0)<(o|0));k=s+56|0;n=(c[r>>2]|0)+16|0;o=k+40|0;do{c[k>>2]=c[n>>2];k=k+4|0;n=n+4|0}while((k|0)<(o|0));a[s+112>>0]=1;c[s+116>>2]=q;q=t}k=1;while(1){if((k|0)>=(i|0)){w=6;break}if(!(a[(c[(c[f+(k+g<<2)>>2]|0)+16>>2]|0)+113>>0]|0))k=k+1|0;else{w=7;break}}a:do if((w|0)==6)if(!(u<<24>>24)){k=c[q+16>>2]|0;if(c[k+96>>2]|0){Dg(b,d,e,q,j);break}if((j|0)==2){A=c[q>>2]&3;Eg(c[((A|0)==3?q:q+48|0)+40>>2]|0,c[((A|0)==2?q:q+-48|0)+40>>2]|0,f,g,i,2);break}t=a[k+49>>0]|0;u=a[k+89>>0]|0;if(!(t<<24>>24==1&u<<24>>24!=4)?!(t<<24>>24!=4&u<<24>>24==1):0){p=c[q>>2]&3;o=c[((p|0)==3?q:q+48|0)+40>>2]|0;p=c[((p|0)==2?q:q+-48|0)+40>>2]|0;k=c[o+16>>2]|0;n=c[k+232>>2]|0;if((n|0)>0){u=c[(c[b+16>>2]|0)+196>>2]|0;t=n+~(a[(c[(c[b+60>>2]|0)+16>>2]|0)+113>>0]&1)|0;m=+h[(c[(c[c[u+(t<<6)+4>>2]>>2]|0)+16>>2]|0)+24>>3]-+h[u+(t<<6)+16>>3]-+h[k+24>>3]-+h[u+(n<<6)+24>>3]}else m=+(c[(c[b+16>>2]|0)+252>>2]|0);C=+(i+1|0);v=+(c[d+12>>2]|0)/C;m=m/C;Gg(b,d,e,o,q,y,1);Gg(b,d,e,p,q,z,0);s=y+52|0;t=z+52|0;p=(j|0)==10;q=e+80|0;k=0;while(1){if((k|0)>=(i|0))break a;r=c[f+(k+g<<2)>>2]|0;o=c[s>>2]|0;n=o+-1|0;G=+h[y+56+(n<<5)>>3];F=+h[y+56+(n<<5)+16>>3];E=+h[y+56+(n<<5)+24>>3];h[16878]=G;h[16879]=E;k=k+1|0;C=+(k|0);D=v*C;h[16880]=F+D;C=E+m*C;h[16881]=C;h[16882]=G;h[16883]=C;n=(c[t>>2]|0)+-1|0;G=+h[z+56+(n<<5)+16>>3];h[16884]=G;h[16885]=C+m;E=+h[z+56+(n<<5)>>3];F=+h[z+56+(n<<5)+24>>3];h[16888]=G;h[16887]=F;h[16886]=E-D;h[16889]=C;n=0;while(1){if((n|0)>=(o|0)){n=0;break}o=y+56+(n<<5)|0;c[x>>2]=c[o>>2];c[x+4>>2]=c[o+4>>2];c[x+8>>2]=c[o+8>>2];c[x+12>>2]=c[o+12>>2];c[x+16>>2]=c[o+16>>2];c[x+20>>2]=c[o+20>>2];c[x+24>>2]=c[o+24>>2];c[x+28>>2]=c[o+28>>2];Lz(e,x);n=n+1|0;o=c[s>>2]|0}while(1){if((n|0)==3)break;j=135024+(n<<5)|0;c[x>>2]=c[j>>2];c[x+4>>2]=c[j+4>>2];c[x+8>>2]=c[j+8>>2];c[x+12>>2]=c[j+12>>2];c[x+16>>2]=c[j+16>>2];c[x+20>>2]=c[j+20>>2];c[x+24>>2]=c[j+24>>2];c[x+28>>2]=c[j+28>>2];Lz(e,x);n=n+1|0}o=c[t>>2]|0;while(1){n=o+-1|0;if((o|0)<=0)break;o=z+56+(n<<5)|0;c[x>>2]=c[o>>2];c[x+4>>2]=c[o+4>>2];c[x+8>>2]=c[o+8>>2];c[x+12>>2]=c[o+12>>2];c[x+16>>2]=c[o+16>>2];c[x+20>>2]=c[o+20>>2];c[x+24>>2]=c[o+24>>2];c[x+28>>2]=c[o+28>>2];Lz(e,x);o=n}if(p)n=ny(e,A)|0;else n=ty(e,A)|0;o=c[A>>2]|0;if(!o)break a;Jz(r,c[((c[r>>2]&3|0)==2?r:r+-48|0)+40>>2]|0,n,o,17224);c[q>>2]=0}}Fg(b,d,e,f,g,i,q,(j|0)==10&1)}else w=7;while(0);if((w|0)==7)Cg(b,f,g,i,q,j);l=B;return}function eg(b,d,e,f,g,i,j){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;i=i|0;j=j|0;var k=0,m=0.0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0;ba=l;l=l+2576|0;S=ba+2528|0;_=ba+2568|0;k=ba+2352|0;n=ba+2176|0;t=ba+1904|0;Y=ba+1808|0;$=ba+1712|0;T=ba+1016|0;U=ba+320|0;V=ba+256|0;X=ba+2564|0;Z=ba+2560|0;z=ba+288|0;A=ba+224|0;L=ba+192|0;M=ba+160|0;N=ba+128|0;P=ba+96|0;Q=ba+64|0;R=ba+32|0;W=ba;s=t+16|0;c[s>>2]=k;o=Y+16|0;c[o>>2]=n;aa=$+16|0;c[aa>>2]=ba+2e3;if(!(c[41920]|0)){c[41920]=ww(32e3)|0;c[41921]=ww(32e3)|0;c[41922]=2e3;c[41923]=2e3}u=c[f+(g<<2)>>2]|0;K=c[u>>2]&3;p=u+48|0;q=u+-48|0;K=(c[(c[(c[((K|0)==3?u:p)+40>>2]|0)+16>>2]|0)+232>>2]|0)-(c[(c[(c[((K|0)==2?u:q)+40>>2]|0)+16>>2]|0)+232>>2]|0)|0;r=u+16|0;if((((K|0)>-1?K:0-K|0)|0)<=1){k=c[r>>2]|0;if(!(c[k+164>>2]&32)){K=u;n=0}else{n=c[s>>2]|0;TN(n|0,k|0,176)|0;w=t;x=u;y=w+48|0;do{c[w>>2]=c[x>>2];w=w+4|0;x=x+4|0}while((w|0)<(y|0));c[s>>2]=n;w=c[t>>2]&3;c[((w|0)==3?t:t+48|0)+40>>2]=c[((c[u>>2]&3|0)==2?u:q)+40>>2];c[((w|0)==2?t:t+-48|0)+40>>2]=c[((c[u>>2]&3|0)==3?u:p)+40>>2];w=n+16|0;x=(c[r>>2]|0)+56|0;y=w+40|0;do{c[w>>2]=c[x>>2];w=w+4|0;x=x+4|0}while((w|0)<(y|0));k=c[s>>2]|0;w=k+56|0;x=(c[r>>2]|0)+16|0;y=w+40|0;do{c[w>>2]=c[x>>2];w=w+4|0;x=x+4|0}while((w|0)<(y|0));a[k+112>>0]=1;n=0;J=12}}else{TN(k|0,c[r>>2]|0,176)|0;w=t;x=u;y=w+48|0;do{c[w>>2]=c[x>>2];w=w+4|0;x=x+4|0}while((w|0)<(y|0));w=t+48|0;x=p;y=w+48|0;do{c[w>>2]=c[x>>2];w=w+4|0;x=x+4|0}while((w|0)<(y|0));c[s>>2]=k;k=c[r>>2]|0;if(!(c[k+164>>2]&32)){TN(n|0,k|0,176)|0;w=Y;x=u;y=w+48|0;do{c[w>>2]=c[x>>2];w=w+4|0;x=x+4|0}while((w|0)<(y|0));c[o>>2]=n;o=c[t>>2]|0;c[((o&3|0)==3?t:t+48|0)+40>>2]=c[((c[u>>2]&3|0)==3?u:p)+40>>2];w=Y+48|0;x=p;y=w+48|0;do{c[w>>2]=c[x>>2];w=w+4|0;x=x+4|0}while((w|0)<(y|0))}else{n=c[o>>2]|0;TN(n|0,k|0,176)|0;w=Y;x=u;y=w+48|0;do{c[w>>2]=c[x>>2];w=w+4|0;x=x+4|0}while((w|0)<(y|0));c[o>>2]=n;w=c[Y>>2]&3;c[((w|0)==3?Y:Y+48|0)+40>>2]=c[((c[u>>2]&3|0)==2?u:q)+40>>2];c[((w|0)==2?Y:Y+-48|0)+40>>2]=c[((c[u>>2]&3|0)==3?u:p)+40>>2];w=n+16|0;x=(c[r>>2]|0)+56|0;y=w+40|0;do{c[w>>2]=c[x>>2];w=w+4|0;x=x+4|0}while((w|0)<(y|0));k=c[o>>2]|0;w=k+56|0;x=(c[r>>2]|0)+16|0;y=w+40|0;do{c[w>>2]=c[x>>2];w=w+4|0;x=x+4|0}while((w|0)<(y|0));a[k+112>>0]=1;c[k+116>>2]=u;o=c[t>>2]|0;c[((o&3|0)==3?t:t+48|0)+40>>2]=c[((c[u>>2]&3|0)==2?u:q)+40>>2];w=(c[s>>2]|0)+16|0;x=(c[r>>2]|0)+56|0;y=w+40|0;do{c[w>>2]=c[x>>2];w=w+4|0;x=x+4|0}while((w|0)<(y|0))}k=cg(u)|0;while(1){n=c[(c[k+16>>2]|0)+172>>2]|0;if(!n)break;else k=n}c[((o&3|0)==2?t:t+-48|0)+40>>2]=c[((c[k>>2]&3|0)==2?k:k+-48|0)+40>>2];k=c[s>>2]|0;a[k+84>>0]=0;a[k+112>>0]=1;n=k+56|0;c[n>>2]=0;c[n+4>>2]=0;c[n+8>>2]=0;c[n+12>>2]=0;n=1;J=12}if((J|0)==12){c[k+116>>2]=u;K=t}H=(j|0)==2;if(H?(v=ig(b,K,c[41920]|0,_)|0,c[Z>>2]=v,(v|0)!=0):0)J=63;else J=15;a:do if((J|0)==15){G=(j|0)==10;c[Z>>2]=0;o=c[K>>2]&3;k=c[((o|0)==3?K:K+48|0)+40>>2]|0;o=c[((o|0)==2?K:K+-48|0)+40>>2]|0;c[_>>2]=o;jg(z,b,d,k,0,K);c[T>>2]=c[z>>2];c[T+4>>2]=c[z+4>>2];c[T+8>>2]=c[z+8>>2];c[T+12>>2]=c[z+12>>2];c[T+16>>2]=c[z+16>>2];c[T+20>>2]=c[z+20>>2];c[T+24>>2]=c[z+24>>2];c[T+28>>2]=c[z+28>>2];c[V>>2]=c[z>>2];c[V+4>>2]=c[z+4>>2];c[V+8>>2]=c[z+8>>2];c[V+12>>2]=c[z+12>>2];c[V+16>>2]=c[z+16>>2];c[V+20>>2]=c[z+20>>2];Mz(e,K,1,T,kg(k)|0);B=T+52|0;I=(c[B>>2]|0)+-1|0;D=V+24|0;h[D>>3]=+h[T+56+(I<<5)+24>>3];E=V+8|0;h[E>>3]=+h[T+56+(I<<5)+8>>3];I=c[k+16>>2]|0;F=b+16|0;m=+h[I+24>>3]-+h[(c[(c[F>>2]|0)+196>>2]|0)+(c[I+232>>2]<<6)+16>>3];c[S>>2]=c[V>>2];c[S+4>>2]=c[V+4>>2];c[S+8>>2]=c[V+8>>2];c[S+12>>2]=c[V+12>>2];c[S+16>>2]=c[V+16>>2];c[S+20>>2]=c[V+20>>2];c[S+24>>2]=c[V+24>>2];c[S+28>>2]=c[V+28>>2];lg(A,S,1,m);c[V>>2]=c[A>>2];c[V+4>>2]=c[A+4>>2];c[V+8>>2]=c[A+8>>2];c[V+12>>2]=c[A+12>>2];c[V+16>>2]=c[A+16>>2];c[V+20>>2]=c[A+20>>2];c[V+24>>2]=c[A+24>>2];c[V+28>>2]=c[A+28>>2];A=V+16|0;if(+h[V>>3]<+h[A>>3]?+h[E>>3]<+h[D>>3]:0){I=c[B>>2]|0;c[B>>2]=I+1;I=T+56+(I<<5)|0;c[I>>2]=c[V>>2];c[I+4>>2]=c[V+4>>2];c[I+8>>2]=c[V+8>>2];c[I+12>>2]=c[V+12>>2];c[I+16>>2]=c[V+16>>2];c[I+20>>2]=c[V+20>>2];c[I+24>>2]=c[V+24>>2];c[I+28>>2]=c[V+28>>2]}w=b+60|0;C=U+52|0;x=e+56|0;y=e+69|0;j=e+16|0;z=e+29|0;I=K;q=0;r=-1;b:while(1){s=k;t=0;k=0;u=I;while(1){p=o;v=o;if((a[(c[p+16>>2]|0)+156>>0]|0)!=1)break b;if(($a[c[17228>>2]&31](p)|0)<<24>>24)break b;o=t|1;ca=135024+(t<<5)|0;mg(L,d,b,c[(c[s+16>>2]|0)+232>>2]|0);c[ca>>2]=c[L>>2];c[ca+4>>2]=c[L+4>>2];c[ca+8>>2]=c[L+8>>2];c[ca+12>>2]=c[L+12>>2];c[ca+16>>2]=c[L+16>>2];c[ca+20>>2]=c[L+20>>2];c[ca+24>>2]=c[L+24>>2];c[ca+28>>2]=c[L+28>>2];if(!k){q=ng(p)|0;k=(q|0)<((a[(c[(c[w>>2]|0)+16>>2]|0)+113>>0]<<1&2)+3&255|0);q=k?q:q+-2|0;r=k?r:1;k=(k^1)&1}if(!((k|0)==0|(r|0)>0))break;ca=135024+(o<<5)|0;jg(M,b,d,p,u,c[c[(c[p+16>>2]|0)+180>>2]>>2]|0);c[ca>>2]=c[M>>2];c[ca+4>>2]=c[M+4>>2];c[ca+8>>2]=c[M+8>>2];c[ca+12>>2]=c[M+12>>2];c[ca+16>>2]=c[M+16>>2];c[ca+20>>2]=c[M+20>>2];c[ca+24>>2]=c[M+24>>2];c[ca+28>>2]=c[M+28>>2];ca=c[c[(c[v+16>>2]|0)+180>>2]>>2]|0;o=c[ca>>2]&3;s=c[((o|0)==3?ca:ca+48|0)+40>>2]|0;o=c[((o|0)==2?ca:ca+-48|0)+40>>2]|0;c[_>>2]=o;t=t+2|0;r=r+-1|0;u=ca}jg(N,b,d,p,u,c[c[(c[p+16>>2]|0)+180>>2]>>2]|0);c[U>>2]=c[N>>2];c[U+4>>2]=c[N+4>>2];c[U+8>>2]=c[N+8>>2];c[U+12>>2]=c[N+12>>2];c[U+16>>2]=c[N+16>>2];c[U+20>>2]=c[N+20>>2];c[U+24>>2]=c[N+24>>2];c[U+28>>2]=c[N+28>>2];Pz(e,u,1,U,kg(c[((c[u>>2]&3|0)==2?u:u+-48|0)+40>>2]|0)|0);ca=U+56+((c[C>>2]|0)+-1<<5)|0;t=c[v+16>>2]|0;m=+h[(c[(c[F>>2]|0)+196>>2]|0)+(c[t+232>>2]<<6)+24>>3]+ +h[t+24>>3];c[S>>2]=c[ca>>2];c[S+4>>2]=c[ca+4>>2];c[S+8>>2]=c[ca+8>>2];c[S+12>>2]=c[ca+12>>2];c[S+16>>2]=c[ca+16>>2];c[S+20>>2]=c[ca+20>>2];c[S+24>>2]=c[ca+24>>2];c[S+28>>2]=c[ca+28>>2];lg(V,S,4,m);if(+h[V>>3]<+h[A>>3]?+h[E>>3]<+h[D>>3]:0){ca=c[C>>2]|0;c[C>>2]=ca+1;ca=U+56+(ca<<5)|0;c[ca>>2]=c[V>>2];c[ca+4>>2]=c[V+4>>2];c[ca+8>>2]=c[V+8>>2];c[ca+12>>2]=c[V+12>>2];c[ca+16>>2]=c[V+16>>2];c[ca+20>>2]=c[V+20>>2];c[ca+24>>2]=c[V+24>>2];c[ca+28>>2]=c[V+28>>2]}h[x>>3]=1.5707963267948966;a[y>>0]=1;og(e,I,u,T,U,o);if(!G){k=ty(e,X)|0;o=c[X>>2]|0;if(H&(o|0)>4){ca=k+16|0;c[ca>>2]=c[k>>2];c[ca+4>>2]=c[k+4>>2];c[ca+8>>2]=c[k+8>>2];c[ca+12>>2]=c[k+12>>2];ca=k+32|0;o=k+(o+-1<<4)|0;c[ca>>2]=c[o>>2];c[ca+4>>2]=c[o+4>>2];c[ca+8>>2]=c[o+8>>2];c[ca+12>>2]=c[o+12>>2];UN(k+48|0,o|0,16)|0;c[X>>2]=4;o=4}else J=33}else{k=ny(e,X)|0;o=c[X>>2]|0;J=33}if((J|0)==33){J=0;if(!o)break a}u=c[Z>>2]|0;p=u+o|0;if((p|0)>(c[41922]|0)){c[41922]=p<<1;t=yw(c[41920]|0,p<<5)|0;c[41920]=t;o=c[X>>2]|0}else t=c[41920]|0;s=0;p=u;while(1){if((s|0)>=(o|0))break;ca=t+(p<<4)|0;u=k+(s<<4)|0;c[ca>>2]=c[u>>2];c[ca+4>>2]=c[u+4>>2];c[ca+8>>2]=c[u+8>>2];c[ca+12>>2]=c[u+12>>2];s=s+1|0;p=p+1|0}c[Z>>2]=p;o=pg(c[c[(c[v+16>>2]|0)+180>>2]>>2]|0,q,t,Z)|0;qg(I,e);p=c[o>>2]&3;k=c[((p|0)==3?o:o+48|0)+40>>2]|0;p=c[((p|0)==2?o:o+-48|0)+40>>2]|0;c[_>>2]=p;I=k+16|0;jg(P,b,d,k,c[c[(c[I>>2]|0)+172>>2]>>2]|0,o);c[T>>2]=c[P>>2];c[T+4>>2]=c[P+4>>2];c[T+8>>2]=c[P+8>>2];c[T+12>>2]=c[P+12>>2];c[T+16>>2]=c[P+16>>2];c[T+20>>2]=c[P+20>>2];c[T+24>>2]=c[P+24>>2];c[T+28>>2]=c[P+28>>2];Mz(e,o,1,T,kg(k)|0);ca=T+56+((c[B>>2]|0)+-1<<5)|0;I=c[I>>2]|0;m=+h[I+24>>3]-+h[(c[(c[F>>2]|0)+196>>2]|0)+(c[I+232>>2]<<6)+16>>3];c[S>>2]=c[ca>>2];c[S+4>>2]=c[ca+4>>2];c[S+8>>2]=c[ca+8>>2];c[S+12>>2]=c[ca+12>>2];c[S+16>>2]=c[ca+16>>2];c[S+20>>2]=c[ca+20>>2];c[S+24>>2]=c[ca+24>>2];c[S+28>>2]=c[ca+28>>2];lg(V,S,1,m);if(+h[V>>3]<+h[A>>3]?+h[E>>3]<+h[D>>3]:0){ca=c[B>>2]|0;c[B>>2]=ca+1;ca=T+56+(ca<<5)|0;c[ca>>2]=c[V>>2];c[ca+4>>2]=c[V+4>>2];c[ca+8>>2]=c[V+8>>2];c[ca+12>>2]=c[V+12>>2];c[ca+16>>2]=c[V+16>>2];c[ca+20>>2]=c[V+20>>2];c[ca+24>>2]=c[V+24>>2];c[ca+28>>2]=c[V+28>>2]}h[j>>3]=-1.5707963267948966;a[z>>0]=1;I=o;o=p}k=t|1;r=135024+(t<<5)|0;mg(Q,d,b,c[(c[s+16>>2]|0)+232>>2]|0);c[r>>2]=c[Q>>2];c[r+4>>2]=c[Q+4>>2];c[r+8>>2]=c[Q+8>>2];c[r+12>>2]=c[Q+12>>2];c[r+16>>2]=c[Q+16>>2];c[r+20>>2]=c[Q+20>>2];c[r+24>>2]=c[Q+24>>2];c[r+28>>2]=c[Q+28>>2];jg(R,b,d,p,u,0);c[U>>2]=c[R>>2];c[U+4>>2]=c[R+4>>2];c[U+8>>2]=c[R+8>>2];c[U+12>>2]=c[R+12>>2];c[U+16>>2]=c[R+16>>2];c[U+20>>2]=c[R+20>>2];c[U+24>>2]=c[R+24>>2];c[U+28>>2]=c[R+28>>2];c[V>>2]=c[R>>2];c[V+4>>2]=c[R+4>>2];c[V+8>>2]=c[R+8>>2];c[V+12>>2]=c[R+12>>2];c[V+16>>2]=c[R+16>>2];c[V+20>>2]=c[R+20>>2];c[V+24>>2]=c[R+24>>2];c[V+28>>2]=c[R+28>>2];r=(n|0)!=0;s=u+-48|0;Pz(e,r?Y:u,1,U,kg(c[((c[u>>2]&3|0)==2?u:s)+40>>2]|0)|0);ca=(c[C>>2]|0)+-1|0;h[D>>3]=+h[U+56+(ca<<5)+24>>3];h[E>>3]=+h[U+56+(ca<<5)+8>>3];ca=c[v+16>>2]|0;m=+h[(c[(c[F>>2]|0)+196>>2]|0)+(c[ca+232>>2]<<6)+24>>3]+ +h[ca+24>>3];c[S>>2]=c[V>>2];c[S+4>>2]=c[V+4>>2];c[S+8>>2]=c[V+8>>2];c[S+12>>2]=c[V+12>>2];c[S+16>>2]=c[V+16>>2];c[S+20>>2]=c[V+20>>2];c[S+24>>2]=c[V+24>>2];c[S+28>>2]=c[V+28>>2];lg(W,S,4,m);c[V>>2]=c[W>>2];c[V+4>>2]=c[W+4>>2];c[V+8>>2]=c[W+8>>2];c[V+12>>2]=c[W+12>>2];c[V+16>>2]=c[W+16>>2];c[V+20>>2]=c[W+20>>2];c[V+24>>2]=c[W+24>>2];c[V+28>>2]=c[W+28>>2];if(+h[V>>3]<+h[A>>3]?+h[E>>3]<+h[D>>3]:0){ca=c[C>>2]|0;c[C>>2]=ca+1;ca=U+56+(ca<<5)|0;c[ca>>2]=c[V>>2];c[ca+4>>2]=c[V+4>>2];c[ca+8>>2]=c[V+8>>2];c[ca+12>>2]=c[V+12>>2];c[ca+16>>2]=c[V+16>>2];c[ca+20>>2]=c[V+20>>2];c[ca+24>>2]=c[V+24>>2];c[ca+28>>2]=c[V+28>>2]}og(e,I,u,T,U,k);if(G)q=ny(e,X)|0;else q=ty(e,X)|0;k=c[X>>2]|0;if(!(H&(k|0)>4)){if(!k)break}else{ca=q+16|0;c[ca>>2]=c[q>>2];c[ca+4>>2]=c[q+4>>2];c[ca+8>>2]=c[q+8>>2];c[ca+12>>2]=c[q+12>>2];ca=q+32|0;k=q+(k+-1<<4)|0;c[ca>>2]=c[k>>2];c[ca+4>>2]=c[k+4>>2];c[ca+8>>2]=c[k+8>>2];c[ca+12>>2]=c[k+12>>2];UN(q+48|0,k|0,16)|0;c[X>>2]=4;k=4}o=c[Z>>2]|0;n=o+k|0;if((n|0)>(c[41922]|0)){c[41922]=n<<1;p=yw(c[41920]|0,n<<5)|0;c[41920]=p;k=c[X>>2]|0}else p=c[41920]|0;n=0;while(1){if((n|0)>=(k|0))break;ca=p+(o<<4)|0;X=q+(n<<4)|0;c[ca>>2]=c[X>>2];c[ca+4>>2]=c[X+4>>2];c[ca+8>>2]=c[X+8>>2];c[ca+12>>2]=c[X+12>>2];n=n+1|0;o=o+1|0}c[Z>>2]=o;qg(I,e);if(r)k=(c[Y>>2]&3|0)==2?Y:Y+-48|0;else k=(c[u>>2]&3|0)==2?u:s;c[_>>2]=c[k+40>>2];v=o;J=63}while(0);c:do if((J|0)==63){if((i|0)==1){Jz(K,c[_>>2]|0,c[41920]|0,v,17224);break}t=d+12|0;u=v+-1|0;m=+((O(c[t>>2]|0,i+-1|0)|0)/2|0|0);n=c[41920]|0;k=1;while(1){if((k|0)>=(u|0))break;ca=n+(k<<4)|0;h[ca>>3]=+h[ca>>3]-m;k=k+1|0}k=c[41922]|0;if((k|0)>(c[41923]|0)){c[41923]=k;o=yw(c[41921]|0,k<<4)|0;c[41921]=o;n=c[41920]|0}else o=c[41921]|0;k=0;while(1){if((k|0)>=(v|0))break;ca=o+(k<<4)|0;d=n+(k<<4)|0;c[ca>>2]=c[d>>2];c[ca+4>>2]=c[d+4>>2];c[ca+8>>2]=c[d+8>>2];c[ca+12>>2]=c[d+12>>2];k=k+1|0}Jz(K,c[_>>2]|0,o,v,17224);r=$+48|0;s=$+-48|0;q=1;while(1){if((q|0)>=(i|0))break c;o=c[f+(q+g<<2)>>2]|0;p=o+16|0;k=c[p>>2]|0;if(c[k+164>>2]&32){n=c[aa>>2]|0;TN(n|0,k|0,176)|0;w=$;x=o;y=w+48|0;do{c[w>>2]=c[x>>2];w=w+4|0;x=x+4|0}while((w|0)<(y|0));c[aa>>2]=n;w=c[$>>2]&3;c[((w|0)==3?$:r)+40>>2]=c[((c[o>>2]&3|0)==2?o:o+-48|0)+40>>2];c[((w|0)==2?$:s)+40>>2]=c[((c[o>>2]&3|0)==3?o:o+48|0)+40>>2];w=n+16|0;x=(c[p>>2]|0)+56|0;y=w+40|0;do{c[w>>2]=c[x>>2];w=w+4|0;x=x+4|0}while((w|0)<(y|0));k=c[aa>>2]|0;w=k+56|0;x=(c[p>>2]|0)+16|0;y=w+40|0;do{c[w>>2]=c[x>>2];w=w+4|0;x=x+4|0}while((w|0)<(y|0));a[k+112>>0]=1;c[k+116>>2]=o;o=$}p=c[41920]|0;k=1;while(1){if((k|0)>=(u|0))break;ca=p+(k<<4)|0;h[ca>>3]=+h[ca>>3]+ +(c[t>>2]|0);k=k+1|0}n=c[41921]|0;k=0;while(1){if((k|0)>=(v|0))break;ca=n+(k<<4)|0;_=p+(k<<4)|0;c[ca>>2]=c[_>>2];c[ca+4>>2]=c[_+4>>2];c[ca+8>>2]=c[_+8>>2];c[ca+12>>2]=c[_+12>>2];k=k+1|0}Jz(o,c[((c[o>>2]&3|0)==2?o:o+-48|0)+40>>2]|0,n,v,17224);q=q+1|0}}while(0);l=ba;return}function fg(a){a=a|0;var b=0,d=0,e=0;b=co(a)|0;while(1){if(!b)break;d=Pm(a,b)|0;while(1){if(!d)break;if(($a[c[4306]&31](d)|0)<<24>>24?(e=c[(c[d+16>>2]|0)+8>>2]|0,e|0):0)gg(e);d=Rm(a,d)|0}b=eo(a,b)|0}return}function gg(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;f=c[a+4>>2]|0;g=ww(f*48|0)|0;b=g;d=0;e=(c[a>>2]|0)+((f+-1|0)*48|0)|0;while(1){if((d|0)>=(f|0)){b=0;break}hg(e,b);b=b+48|0;d=d+1|0;e=e+-48|0}while(1){d=c[a>>2]|0;if((b|0)>=(f|0))break;_I(c[d+(b*48|0)>>2]|0);b=b+1|0}_I(d);c[a>>2]=g;return}function hg(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;g=c[a+4>>2]|0;h=ww(g<<4)|0;d=h;e=0;f=(c[a>>2]|0)+(g+-1<<4)|0;while(1){if((e|0)>=(g|0))break;c[d>>2]=c[f>>2];c[d+4>>2]=c[f+4>>2];c[d+8>>2]=c[f+8>>2];c[d+12>>2]=c[f+12>>2];d=d+16|0;e=e+1|0;f=f+-16|0}c[b>>2]=h;c[b+4>>2]=g;c[b+8>>2]=c[a+12>>2];c[b+12>>2]=c[a+8>>2];h=b+16|0;g=a+32|0;c[h>>2]=c[g>>2];c[h+4>>2]=c[g+4>>2];c[h+8>>2]=c[g+8>>2];c[h+12>>2]=c[g+12>>2];h=b+32|0;g=a+16|0;c[h>>2]=c[g>>2];c[h+4>>2]=c[g+4>>2];c[h+8>>2]=c[g+8>>2];c[h+12>>2]=c[g+12>>2];return}function ig(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,i=0.0,j=0.0,k=0.0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;x=l;l=l+96|0;q=x+80|0;s=x+64|0;r=x+48|0;u=x+32|0;v=x+16|0;w=x;m=d;while(1){t=m+16|0;g=c[t>>2]|0;if(!(a[g+112>>0]|0))break;m=c[g+116>>2]|0}g=c[m>>2]&3;o=c[((g|0)==2?m:m+-48|0)+40>>2]|0;g=c[((g|0)==3?m:m+48|0)+40>>2]|0;m=o+16|0;n=g+16|0;y=(c[(c[m>>2]|0)+232>>2]|0)-(c[(c[n>>2]|0)+232>>2]|0)|0;switch(((y|0)>-1?y:0-y|0)|0){case 1:{g=0;break}case 2:{if(!(a[(c[(c[b+60>>2]|0)+16>>2]|0)+113>>0]&1))p=6;else g=0;break}default:p=6}do if((p|0)==6){if((c[((c[d>>2]&3|0)==3?d:d+48|0)+40>>2]|0)==(g|0)){c[f>>2]=o;y=(c[n>>2]|0)+16|0;p=(c[t>>2]|0)+16|0;c[s>>2]=c[y>>2];c[s+4>>2]=c[y+4>>2];c[s+8>>2]=c[y+8>>2];c[s+12>>2]=c[y+12>>2];c[q>>2]=c[p>>2];c[q+4>>2]=c[p+4>>2];c[q+8>>2]=c[p+8>>2];c[q+12>>2]=c[p+12>>2];Ag(u,s,q);p=(c[m>>2]|0)+16|0;y=(c[t>>2]|0)+56|0;c[s>>2]=c[p>>2];c[s+4>>2]=c[p+4>>2];c[s+8>>2]=c[p+8>>2];c[s+12>>2]=c[p+12>>2];c[q>>2]=c[y>>2];c[q+4>>2]=c[y+4>>2];c[q+8>>2]=c[y+8>>2];c[q+12>>2]=c[y+12>>2];Ag(v,s,q)}else{c[f>>2]=g;y=(c[m>>2]|0)+16|0;p=(c[t>>2]|0)+56|0;c[s>>2]=c[y>>2];c[s+4>>2]=c[y+4>>2];c[s+8>>2]=c[y+8>>2];c[s+12>>2]=c[y+12>>2];c[q>>2]=c[p>>2];c[q+4>>2]=c[p+4>>2];c[q+8>>2]=c[p+8>>2];c[q+12>>2]=c[p+12>>2];Ag(u,s,q);p=(c[n>>2]|0)+16|0;y=(c[t>>2]|0)+16|0;c[s>>2]=c[p>>2];c[s+4>>2]=c[p+4>>2];c[s+8>>2]=c[p+8>>2];c[s+12>>2]=c[p+12>>2];c[q>>2]=c[y>>2];c[q+4>>2]=c[y+4>>2];c[q+8>>2]=c[y+8>>2];c[q+12>>2]=c[y+12>>2];Ag(v,s,q)}g=c[(c[t>>2]|0)+96>>2]|0;if(!g){g=e+16|0;c[e>>2]=c[u>>2];c[e+4>>2]=c[u+4>>2];c[e+8>>2]=c[u+8>>2];c[e+12>>2]=c[u+12>>2];c[g>>2]=c[u>>2];c[g+4>>2]=c[u+4>>2];c[g+8>>2]=c[u+8>>2];c[g+12>>2]=c[u+12>>2];g=e+48|0;y=e+32|0;c[y>>2]=c[v>>2];c[y+4>>2]=c[v+4>>2];c[y+8>>2]=c[v+8>>2];c[y+12>>2]=c[v+12>>2];c[g>>2]=c[v>>2];c[g+4>>2]=c[v+4>>2];c[g+8>>2]=c[v+8>>2];c[g+12>>2]=c[v+12>>2];g=4;break}j=+h[g+24>>3];i=+h[g+32>>3];p=(c[(c[(ro(o)|0)+16>>2]|0)+116>>2]&1|0)==0;k=p?i:j;y=(c[(c[t>>2]|0)+96>>2]|0)+56|0;c[w>>2]=c[y>>2];c[w+4>>2]=c[y+4>>2];c[w+8>>2]=c[y+8>>2];c[w+12>>2]=c[y+12>>2];c[r>>2]=c[v>>2];c[r+4>>2]=c[v+4>>2];c[r+8>>2]=c[v+8>>2];c[r+12>>2]=c[v+12>>2];c[s>>2]=c[u>>2];c[s+4>>2]=c[u+4>>2];c[s+8>>2]=c[u+8>>2];c[s+12>>2]=c[u+12>>2];c[q>>2]=c[y>>2];c[q+4>>2]=c[y+4>>2];c[q+8>>2]=c[y+8>>2];c[q+12>>2]=c[y+12>>2];y=(Bg(r,s,q)|0)==0;i=(p?j:i)*.5;j=+h[w>>3];if(y){h[w>>3]=j-i;y=w+8|0;h[y>>3]=+h[y>>3]+k*.5}else{h[w>>3]=j+i;y=w+8|0;h[y>>3]=+h[y>>3]-k*.5}g=e+16|0;c[e>>2]=c[u>>2];c[e+4>>2]=c[u+4>>2];c[e+8>>2]=c[u+8>>2];c[e+12>>2]=c[u+12>>2];c[g>>2]=c[u>>2];c[g+4>>2]=c[u+4>>2];c[g+8>>2]=c[u+8>>2];c[g+12>>2]=c[u+12>>2];g=e+32|0;y=e+48|0;u=e+64|0;c[u>>2]=c[w>>2];c[u+4>>2]=c[w+4>>2];c[u+8>>2]=c[w+8>>2];c[u+12>>2]=c[w+12>>2];c[y>>2]=c[w>>2];c[y+4>>2]=c[w+4>>2];c[y+8>>2]=c[w+8>>2];c[y+12>>2]=c[w+12>>2];c[g>>2]=c[w>>2];c[g+4>>2]=c[w+4>>2];c[g+8>>2]=c[w+8>>2];c[g+12>>2]=c[w+12>>2];g=e+80|0;y=e+96|0;c[y>>2]=c[v>>2];c[y+4>>2]=c[v+4>>2];c[y+8>>2]=c[v+8>>2];c[y+12>>2]=c[v+12>>2];c[g>>2]=c[v>>2];c[g+4>>2]=c[v+4>>2];c[g+8>>2]=c[v+8>>2];c[g+12>>2]=c[v+12>>2];g=7}while(0);l=x;return g|0}function jg(b,d,e,f,g,i){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;i=i|0;var j=0.0,k=0,l=0,m=0.0,n=0,o=0.0,p=0.0,q=0;q=c[f+16>>2]|0;p=+h[q+16>>3];j=p-+h[q+88>>3];m=j+-4.0;l=wg(d,f,g,i,-1)|0;if(!l){n=~~(j+(m>=0.0?-3.5:-4.5));k=c[e>>2]|0;k=(k|0)>(n|0)?n:k}else{k=xg(d,f,l)|0;do if(!k){n=c[l+16>>2]|0;j=+h[n+240>>3]+ +h[n+16>>3];if(!(a[n+156>>0]|0)){j=+(c[(c[d+16>>2]|0)+248>>2]|0)*.5+j;break}else{j=j+ +(c[e+8>>2]|0);break}}else j=+h[(c[k+16>>2]|0)+32>>3]+ +(c[e+8>>2]|0);while(0);o=j=0.0?.5:-.5))}o=+(k|0);n=(a[q+156>>0]|0)==1;if(n?(c[q+104>>2]|0)!=0:0)m=p+10.0;else m=p+4.0+ +h[q+96>>3];l=wg(d,f,g,i,1)|0;if(!l){f=~~(m+(m>=0.0?.5:-.5));k=c[e+4>>2]|0;k=(k|0)<(f|0)?f:k}else{k=xg(d,f,l)|0;do if(!k){f=c[l+16>>2]|0;j=+h[f+16>>3]-+h[f+88>>3];if(!(a[f+156>>0]|0)){j=j-+(c[(c[d+16>>2]|0)+248>>2]|0)*.5;break}else{j=j-+(c[e+8>>2]|0);break}}else j=+h[(c[k+16>>2]|0)+16>>3]-+(c[e+8>>2]|0);while(0);m=j>m?j:m;k=~~(m+(m>=0.0?.5:-.5))}j=+(k|0);if(n?(c[q+104>>2]|0)!=0:0){j=j-+h[q+96>>3];if(j>3];d=c[(c[d+16>>2]|0)+196>>2]|0;q=c[q+232>>2]|0;m=p-+h[d+(q<<6)+16>>3];p=+h[d+(q<<6)+24>>3]+p;h[b>>3]=o;h[b+8>>3]=m;h[b+16>>3]=j;h[b+24>>3]=p;return}function kg(b){b=b|0;b=c[b+16>>2]|0;if((a[b+156>>0]|0)==1)if((c[b+176>>2]|0)>1)b=1;else b=(c[b+184>>2]|0)>1&1;else b=0;return b|0}function lg(a,b,d,e){a=a|0;b=b|0;d=d|0;e=+e;var f=0,g=0;g=l;l=l+32|0;f=g;switch(d|0){case 1:{vg(f,+h[b>>3],e,+h[b+16>>3],+h[b+8>>3]);break}case 4:{vg(f,+h[b>>3],+h[b+24>>3],+h[b+16>>3],e);break}default:{}}c[a>>2]=c[f>>2];c[a+4>>2]=c[f+4>>2];c[a+8>>2]=c[f+8>>2];c[a+12>>2]=c[f+12>>2];c[a+16>>2]=c[f+16>>2];c[a+20>>2]=c[f+20>>2];c[a+24>>2]=c[f+24>>2];c[a+28>>2]=c[f+28>>2];l=g;return}function mg(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,g=0.0,i=0.0,j=0.0,k=0,l=0,m=0,n=0,o=0;l=c[b+16>>2]|0;k=l+(e<<5)|0;j=+h[k>>3];m=l+(e<<5)+8|0;g=+h[m>>3];n=l+(e<<5)+16|0;f=+h[n>>3];l=l+(e<<5)+24|0;i=+h[l>>3];if(j==f){d=c[(c[d+16>>2]|0)+196>>2]|0;o=e+1|0;j=+(c[b>>2]|0);g=+h[d+(o<<6)+24>>3]+ +h[(c[(c[c[d+(o<<6)+4>>2]>>2]|0)+16>>2]|0)+24>>3];f=+(c[b+4>>2]|0);i=+h[(c[(c[c[d+(e<<6)+4>>2]>>2]|0)+16>>2]|0)+24>>3]-+h[d+(e<<6)+16>>3];h[k>>3]=j;h[m>>3]=g;h[n>>3]=f;h[l>>3]=i}h[a>>3]=j;h[a+8>>3]=g;h[a+16>>3]=f;h[a+24>>3]=i;return}function ng(b){b=b|0;var d=0,e=0;b=c[b+16>>2]|0;e=b+16|0;d=0;while(1){b=c[c[b+180>>2]>>2]|0;b=c[(c[((c[b>>2]&3|0)==2?b:b+-48|0)+40>>2]|0)+16>>2]|0;if((a[b+156>>0]|0)!=1)break;if((c[b+184>>2]|0)!=1)break;if((c[b+176>>2]|0)!=1)break;if(+h[b+16>>3]!=+h[e>>3])break;d=d+1|0}return d|0}function og(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0;k=l;l=l+32|0;j=k;h=sg(b,-1)|0;b=sg(b,1)|0;if(!((h|0)!=0?!(_z(h)|0):0))i=3;do if((i|0)==3){if(b|0?(_z(b)|0)==0:0)break;h=tg(d,-1)|0;b=tg(d,1)|0;if(h|0?(_z(h)|0)==0:0)break;if(b|0?(_z(b)|0)==0:0)break;h=e+52|0;b=0;while(1){if((b|0)>=(c[h>>2]|0))break;d=e+56+(b<<5)|0;c[j>>2]=c[d>>2];c[j+4>>2]=c[d+4>>2];c[j+8>>2]=c[d+8>>2];c[j+12>>2]=c[d+12>>2];c[j+16>>2]=c[d+16>>2];c[j+20>>2]=c[d+20>>2];c[j+24>>2]=c[d+24>>2];c[j+28>>2]=c[d+28>>2];Lz(a,j);b=b+1|0}h=c[a+80>>2]|0;i=g+-3|0;b=0;while(1){if((b|0)>=(g|0))break;e=135024+(b<<5)|0;c[j>>2]=c[e>>2];c[j+4>>2]=c[e+4>>2];c[j+8>>2]=c[e+8>>2];c[j+12>>2]=c[e+12>>2];c[j+16>>2]=c[e+16>>2];c[j+20>>2]=c[e+20>>2];c[j+24>>2]=c[e+24>>2];c[j+28>>2]=c[e+28>>2];Lz(a,j);b=b+1|0}d=h+1|0;i=i+d|0;h=c[f+52>>2]|0;while(1){b=h+-1|0;if((h|0)<=0)break;h=f+56+(b<<5)|0;c[j>>2]=c[h>>2];c[j+4>>2]=c[h+4>>2];c[j+8>>2]=c[h+8>>2];c[j+12>>2]=c[h+12>>2];c[j+16>>2]=c[h+16>>2];c[j+20>>2]=c[h+20>>2];c[j+24>>2]=c[h+24>>2];c[j+28>>2]=c[h+28>>2];Lz(a,j);h=b}ug(a,d,i)}while(0);l=k;return}function pg(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;f=c[e>>2]|0;while(1){if(!b)break;a=c[c[(c[(c[((c[a>>2]&3|0)==2?a:a+-48|0)+40>>2]|0)+16>>2]|0)+180>>2]>>2]|0;b=b+-1|0}c[e>>2]=f+1;g=d+(f<<4)|0;b=d+(f+-1<<4)|0;c[g>>2]=c[b>>2];c[g+4>>2]=c[b+4>>2];c[g+8>>2]=c[b+8>>2];c[g+12>>2]=c[b+12>>2];f=c[e>>2]|0;c[e>>2]=f+1;f=d+(f<<4)|0;c[f>>2]=c[b>>2];c[f+4>>2]=c[b+4>>2];c[f+8>>2]=c[b+8>>2];c[f+12>>2]=c[b+12>>2];f=d+(c[e>>2]<<4)|0;e=(c[(c[((c[a>>2]&3|0)==3?a:a+48|0)+40>>2]|0)+16>>2]|0)+16|0;c[f>>2]=c[e>>2];c[f+4>>2]=c[e+4>>2];c[f+8>>2]=c[e+8>>2];c[f+12>>2]=c[e+12>>2];return a|0}function qg(b,d){b=b|0;d=d|0;var e=0,f=0.0,g=0.0,i=0,j=0,k=0,l=0,m=0;m=d+84|0;l=d+80|0;e=0;d=b;a:while(1){j=c[((c[d>>2]&3|0)==2?d:d+-48|0)+40>>2]|0;k=j+16|0;if((a[(c[k>>2]|0)+156>>0]|0)!=1)break;if(($a[c[17228>>2]&31](j)|0)<<24>>24)break;d=c[l>>2]|0;while(1){if((e|0)>=(d|0))break a;if(!(+h[(c[m>>2]|0)+(e<<5)+8>>3]>+h[(c[k>>2]|0)+24>>3]))break;e=e+1|0}d=c[m>>2]|0;b=c[k>>2]|0;do if(!(+h[d+(e<<5)+24>>3]<+h[b+24>>3])){g=+h[d+(e<<5)>>3];i=~~g;f=+h[d+(e<<5)+16>>3];if(!(c[b+104>>2]|0)){rg(j,i,~~((f+g)*.5),~~f);break}else{rg(j,i,~~f,~~(+h[b+96>>3]+f));break}}while(0);d=c[c[(c[k>>2]|0)+180>>2]>>2]|0}return}function rg(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;a=c[a+16>>2]|0;h[a+16>>3]=+(d|0);h[a+88>>3]=+(d-b|0);h[a+96>>3]=+(e-d|0);return}function sg(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;h=c[a>>2]&3;i=c[(c[(c[((h|0)==3?a:a+48|0)+40>>2]|0)+16>>2]|0)+180>>2]|0;h=((h|0)==2?a:a+-48|0)+40|0;g=0;a=0;while(1){e=c[i+(g<<2)>>2]|0;if(!e)break;f=c[(c[(c[((c[e>>2]&3|0)==2?e:e+-48|0)+40>>2]|0)+16>>2]|0)+236>>2]|0;do if((O(f-(c[(c[(c[h>>2]|0)+16>>2]|0)+236>>2]|0)|0,b)|0)>=1){d=c[e+16>>2]|0;if(!(c[d+8>>2]|0)){d=c[d+116>>2]|0;if(!d)break;if(!(c[(c[d+16>>2]|0)+8>>2]|0))break}if(a|0?(O((c[(c[(c[((c[a>>2]&3|0)==2?a:a+-48|0)+40>>2]|0)+16>>2]|0)+236>>2]|0)-f|0,b)|0)<=0:0)break;a=e}while(0);g=g+1|0}return a|0}function tg(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;h=c[a>>2]&3;i=c[(c[(c[((h|0)==2?a:a+-48|0)+40>>2]|0)+16>>2]|0)+172>>2]|0;h=((h|0)==3?a:a+48|0)+40|0;g=0;a=0;while(1){e=c[i+(g<<2)>>2]|0;if(!e)break;f=c[(c[(c[((c[e>>2]&3|0)==3?e:e+48|0)+40>>2]|0)+16>>2]|0)+236>>2]|0;do if((O(f-(c[(c[(c[h>>2]|0)+16>>2]|0)+236>>2]|0)|0,b)|0)>=1){d=c[e+16>>2]|0;if(!(c[d+8>>2]|0)){d=c[d+116>>2]|0;if(!d)break;if(!(c[(c[d+16>>2]|0)+8>>2]|0))break}if(a|0?(O((c[(c[(c[((c[a>>2]&3|0)==3?a:a+48|0)+40>>2]|0)+16>>2]|0)+236>>2]|0)-f|0,b)|0)<=0:0)break;a=e}while(0);g=g+1|0}return a|0}function ug(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0,g=0,i=0,j=0,k=0,l=0,m=0.0;l=a+84|0;i=b+-1|0;while(1){if((i|0)>(d|0))break;f=c[l>>2]|0;j=f+(i<<5)|0;e=+h[j>>3];if(!(i-b&1)){f=f+(i<<5)+16|0;m=+h[f>>3];g=~~((m+e)*.5);if(e>=m){h[j>>3]=+(g+-8|0);h[f>>3]=+(g+8|0)}}else{f=f+(i<<5)+16|0;m=+h[f>>3];g=~~((m+e)*.5);if(e+16.0>m){h[j>>3]=+(g+-8|0);h[f>>3]=+(g+8|0)}}i=i+1|0}k=(c[a+80>>2]|0)+-1|0;g=0;while(1){if((g|0)>=(k|0))break;i=c[l>>2]|0;f=i+(g<<5)|0;j=g+1|0;a=i+(j<<5)|0;if(!((g|0)<(b|0)|(g|0)>(d|0))?(g-b&1|0)==0:0){e=+h[f>>3]+16.0;f=i+(j<<5)+16|0;if(e>+h[f>>3])h[f>>3]=e;e=+h[i+(g<<5)+16>>3]+-16.0;if(!(e<+h[a>>3])){g=j;continue}h[a>>3]=e;g=j;continue}if(!((g|0)<(d|0)&(j|0)>=(b|0))){g=j;continue}if(j-b&1|0){g=j;continue}e=+h[i+(j<<5)+16>>3];if(+h[f>>3]+16.0>e)h[f>>3]=e+-16.0;f=i+(g<<5)+16|0;e=+h[a>>3];if(!(+h[f>>3]+-16.0>3]=e+16.0;g=j}return}function vg(a,b,c,d,e){a=a|0;b=+b;c=+c;d=+d;e=+e;h[a>>3]=b;h[a+8>>3]=c;h[a+16>>3]=d;h[a+24>>3]=e;return}function wg(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0;k=c[(c[b+16>>2]|0)+196>>2]|0;h=c[d+16>>2]|0;j=c[h+232>>2]|0;i=k+(j<<6)|0;j=k+(j<<6)+4|0;h=c[h+236>>2]|0;a:do{h=h+g|0;if((h|0)<=-1){b=0;break}if((h|0)>=(c[i>>2]|0)){b=0;break}b=c[(c[j>>2]|0)+(h<<2)>>2]|0;k=c[b+16>>2]|0;switch(a[k+156>>0]|0){case 0:break a;case 1:{if(c[k+104>>2]|0)break a;break}default:{}}}while((zg(b,d,e,f)|0)<<24>>24!=0);return b|0}function xg(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;d=c[d+16>>2]|0;if(!(a[d+156>>0]|0)){i=c[d+212>>2]|0;h=i}else{i=c[(c[(c[c[d+180>>2]>>2]|0)+16>>2]|0)+116>>2]|0;g=c[i>>2]&3;h=c[(c[(c[((g|0)==2?i:i+-48|0)+40>>2]|0)+16>>2]|0)+212>>2]|0;i=c[(c[(c[((g|0)==3?i:i+48|0)+40>>2]|0)+16>>2]|0)+212>>2]|0}d=c[e+16>>2]|0;if(!(a[d+156>>0]|0)){e=c[d+212>>2]|0;e=(e|0)==(b|0)?0:e;return ((e|0)==(h|0)|((e|0)==0|(e|0)==(i|0))?0:e)|0}f=c[(c[(c[c[d+180>>2]>>2]|0)+16>>2]|0)+116>>2]|0;g=c[f>>2]&3;d=c[(c[(c[((g|0)==3?f:f+48|0)+40>>2]|0)+16>>2]|0)+212>>2]|0;d=(d|0)==(b|0)?0:d;if(!(!((d|0)==(h|0)|((d|0)==0|(d|0)==(i|0)))?(yg(d,e)|0)!=0:0)){d=c[(c[(c[((g|0)==2?f:f+-48|0)+40>>2]|0)+16>>2]|0)+212>>2]|0;d=(d|0)==(b|0)?0:d;if((d|0)==(h|0)|((d|0)==0|(d|0)==(i|0)))d=0;else{e=(yg(d,e)|0)==0;return (e?0:d)|0}}return d|0}function yg(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0;d=c[a+16>>2]|0;a=c[b+16>>2]|0;f=+h[a+16>>3];if((+h[d+16>>3]<=f?f<=+h[d+32>>3]:0)?(e=+h[a+24>>3],+h[d+24>>3]<=e):0)a=e<=+h[d+40>>3]&1;else a=0;return a|0}function zg(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0;i=c[b+16>>2]|0;j=(c[i+236>>2]|0)>(c[(c[d+16>>2]|0)+236>>2]|0);a:do if((c[i+184>>2]|0)==1){b:do if(f|0){h=0;b=c[c[i+180>>2]>>2]|0;while(1){if((h|0)>=2)break b;b=c[((c[b>>2]&3|0)==2?b:b+-48|0)+40>>2]|0;d=c[((c[f>>2]&3|0)==2?f:f+-48|0)+40>>2]|0;if((b|0)==(d|0))break b;g=c[b+16>>2]|0;b=c[d+16>>2]|0;if(j^(c[g+236>>2]|0)>(c[b+236>>2]|0)){b=1;break a}if((c[g+184>>2]|0)!=1)break b;if(!(a[g+156>>0]|0))break b;if((c[b+184>>2]|0)!=1)break b;if(!(a[b+156>>0]|0))break b;h=h+1|0;f=c[c[b+180>>2]>>2]|0;b=c[c[g+180>>2]>>2]|0}}while(0);if(e|0?(c[i+176>>2]|0)==1:0){g=0;d=e;b=c[c[i+172>>2]>>2]|0;while(1){if((g|0)>=2){b=0;break a}b=c[((c[b>>2]&3|0)==3?b:b+48|0)+40>>2]|0;d=c[((c[d>>2]&3|0)==3?d:d+48|0)+40>>2]|0;if((b|0)==(d|0)){b=0;break a}f=c[b+16>>2]|0;b=c[d+16>>2]|0;if(j^(c[f+236>>2]|0)>(c[b+236>>2]|0)){b=1;break a}if((c[f+176>>2]|0)!=1){b=0;break a}if(!(a[f+156>>0]|0)){b=0;break a}if((c[b+176>>2]|0)!=1){b=0;break a}if(!(a[b+156>>0]|0)){b=0;break a}g=g+1|0;d=c[c[b+172>>2]>>2]|0;b=c[c[f+172>>2]>>2]|0}}else b=0}else b=0;while(0);return b|0}function Ag(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0;d=+h[c+8>>3]+ +h[b+8>>3];h[a>>3]=+h[c>>3]+ +h[b>>3];h[a+8>>3]=d;return}function Bg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0,e=0.0;d=+h[b+8>>3];e=+h[b>>3];return (~~((+h[c>>3]-e)*(+h[a+8>>3]-d)-(+h[a>>3]-e)*(+h[c+8>>3]-d))|0)>0|0}function Cg(b,d,e,f,g,i){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;i=i|0;var j=0,k=0,m=0.0,n=0,o=0,p=0,q=0,r=0,s=0.0,t=0,u=0,v=0.0,w=0.0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0;R=l;l=l+256|0;D=R+232|0;C=R+216|0;P=R+88|0;O=R+80|0;K=R+64|0;L=R+200|0;M=R+184|0;N=R;E=R+168|0;F=R+152|0;G=R+136|0;H=R+120|0;I=R+104|0;B=c[g>>2]&3;J=c[((B|0)==3?g:g+48|0)+40>>2]|0;B=c[((B|0)==2?g:g+-48|0)+40>>2]|0;do if((By(J)|0)!=2?(By(B)|0)!=2:0){g=0;j=0;k=0;while(1){if((k|0)>=(f|0))break;A=c[(c[d+(k+e<<2)>>2]|0)+16>>2]|0;g=g+((c[A+96>>2]|0)!=0&1)|0;if(!((a[A+44>>0]|0)==0?(a[A+84>>0]|0)==0:0))j=1;k=k+1|0}if(!j)if(!g){Eg(J,B,d,e,f,i);break}else{Jg(J,B,d,e,f,i,g);break}y=vw(156)|0;z=Kg(b,y)|0;t=Ip(z,78320,1)|0;No(t,122277,280,1)|0;Km(t,80018,80032)|0;m=+h[(c[B+16>>2]|0)+16>>3];s=+h[(c[J+16>>2]|0)+16>>3];A=b+16|0;q=(c[(c[A>>2]|0)+116>>2]&1|0)==0;r=q?B:J;q=q?J:B;t=Lg(t,q)|0;u=Lg(z,r)|0;g=0;p=0;while(1){if((p|0)>=(f|0))break;j=d+(p+e<<2)|0;while(1){o=c[j>>2]|0;n=o+16|0;j=c[n>>2]|0;if(!(a[j+112>>0]|0))break;else j=j+116|0}if((c[((c[o>>2]&3|0)==3?o:o+48|0)+40>>2]|0)==(q|0))k=Mg(z,t,u,o)|0;else k=Mg(z,u,t,o)|0;j=c[n>>2]|0;c[j+120>>2]=k;if(!g)if((a[j+44>>0]|0)==0?(a[j+84>>0]|0)==0:0){c[(c[k+16>>2]|0)+120>>2]=o;g=k}else g=0;p=p+1|0}if(!g)x=an(z,t,u,0,1)|0;else x=g;Cm(x,c[42218]|0,78324)|0;g=z+16|0;n=c[g>>2]|0;c[n+144>>2]=c[(c[A>>2]|0)+144>>2];c[n+188>>2]=z;IB(z,i);Bf(z);kj(z,0);uh(z,0);xi(z,0);q=q+16|0;i=c[q>>2]|0;n=c[r+16>>2]|0;r=t+16|0;o=c[r>>2]|0;p=o+16|0;v=+(~~m|0);w=+(~~((+h[(c[u+16>>2]|0)+16>>3]+ +h[p>>3])*.5)|0);m=+(~~s|0);s=+(~~((+h[i+16>>3]-+h[i+96>>3]+ +h[n+16>>3]+ +h[n+88>>3])*.5)|0);n=o+24|0;g=(c[g>>2]|0)+192|0;while(1){j=c[g>>2]|0;if(!j)break;do if((j|0)!=(t|0)){g=c[j+16>>2]|0;k=g+24|0;if((j|0)==(u|0)){h[k>>3]=m;h[g+16>>3]=w;break}else{h[k>>3]=s;break}}else{h[n>>3]=v;h[p>>3]=w;g=o}while(0);g=g+164|0}ek(z);Yf(z,0);$x(z);k=c[q>>2]|0;g=c[r>>2]|0;if(!(c[(c[A>>2]|0)+116>>2]&1)){j=g+16|0;m=+h[k+24>>3]-+h[g+24>>3]}else{j=g+24|0;m=+h[g+16>>3]+ +h[k+24>>3]}h[K>>3]=+h[k+16>>3]-+h[j>>3];h[K+8>>3]=m;i=N+16|0;t=N+32|0;u=N+48|0;r=0;while(1){if((r|0)>=(f|0))break;g=d+(r+e<<2)|0;while(1){j=c[g>>2]|0;q=j+16|0;g=c[q>>2]|0;if(!(a[g+112>>0]|0))break;else g=g+116|0}o=c[g+120>>2]|0;p=o+16|0;g=c[p>>2]|0;if(!((o|0)==(x|0)&(c[g+120>>2]|0)==0)){n=c[c[g+8>>2]>>2]|0;o=n+4|0;j=Iz(j,c[o>>2]|0)|0;c[j+8>>2]=c[n+8>>2];g=j+16|0;k=n+16|0;S=c[(c[A>>2]|0)+116>>2]&1;c[C>>2]=c[k>>2];c[C+4>>2]=c[k+4>>2];c[C+8>>2]=c[k+8>>2];c[C+12>>2]=c[k+12>>2];c[D>>2]=c[K>>2];c[D+4>>2]=c[K+4>>2];c[D+8>>2]=c[K+8>>2];c[D+12>>2]=c[K+12>>2];Ng(L,C,D,S);c[g>>2]=c[L>>2];c[g+4>>2]=c[L+4>>2];c[g+8>>2]=c[L+8>>2];c[g+12>>2]=c[L+12>>2];c[j+12>>2]=c[n+12>>2];g=j+32|0;S=n+32|0;k=c[(c[A>>2]|0)+116>>2]&1;c[C>>2]=c[S>>2];c[C+4>>2]=c[S+4>>2];c[C+8>>2]=c[S+8>>2];c[C+12>>2]=c[S+12>>2];c[D>>2]=c[K>>2];c[D+4>>2]=c[K+4>>2];c[D+8>>2]=c[K+8>>2];c[D+12>>2]=c[K+12>>2];Ng(M,C,D,k);c[g>>2]=c[M>>2];c[g+4>>2]=c[M+4>>2];c[g+8>>2]=c[M+8>>2];c[g+12>>2]=c[M+12>>2];g=0;while(1){if((g|0)>=(c[o>>2]|0))break;k=(c[j>>2]|0)+(g<<4)|0;T=(c[n>>2]|0)+(g<<4)|0;S=c[(c[A>>2]|0)+116>>2]&1;c[C>>2]=c[T>>2];c[C+4>>2]=c[T+4>>2];c[C+8>>2]=c[T+8>>2];c[C+12>>2]=c[T+12>>2];c[D>>2]=c[K>>2];c[D+4>>2]=c[K+4>>2];c[D+8>>2]=c[K+8>>2];c[D+12>>2]=c[K+12>>2];Ng(E,C,D,S);c[k>>2]=c[E>>2];c[k+4>>2]=c[E+4>>2];c[k+8>>2]=c[E+8>>2];c[k+12>>2]=c[E+12>>2];c[N>>2]=c[E>>2];c[N+4>>2]=c[E+4>>2];c[N+8>>2]=c[E+8>>2];c[N+12>>2]=c[E+12>>2];k=g+1|0;if((k|0)>=(c[o>>2]|0)){Q=48;break}S=(c[j>>2]|0)+(k<<4)|0;k=(c[n>>2]|0)+(k<<4)|0;T=c[(c[A>>2]|0)+116>>2]&1;c[C>>2]=c[k>>2];c[C+4>>2]=c[k+4>>2];c[C+8>>2]=c[k+8>>2];c[C+12>>2]=c[k+12>>2];c[D>>2]=c[K>>2];c[D+4>>2]=c[K+4>>2];c[D+8>>2]=c[K+8>>2];c[D+12>>2]=c[K+12>>2];Ng(F,C,D,T);c[S>>2]=c[F>>2];c[S+4>>2]=c[F+4>>2];c[S+8>>2]=c[F+8>>2];c[S+12>>2]=c[F+12>>2];c[i>>2]=c[F>>2];c[i+4>>2]=c[F+4>>2];c[i+8>>2]=c[F+8>>2];c[i+12>>2]=c[F+12>>2];S=g+2|0;T=(c[j>>2]|0)+(S<<4)|0;S=(c[n>>2]|0)+(S<<4)|0;k=c[(c[A>>2]|0)+116>>2]&1;c[C>>2]=c[S>>2];c[C+4>>2]=c[S+4>>2];c[C+8>>2]=c[S+8>>2];c[C+12>>2]=c[S+12>>2];c[D>>2]=c[K>>2];c[D+4>>2]=c[K+4>>2];c[D+8>>2]=c[K+8>>2];c[D+12>>2]=c[K+12>>2];Ng(G,C,D,k);c[T>>2]=c[G>>2];c[T+4>>2]=c[G+4>>2];c[T+8>>2]=c[G+8>>2];c[T+12>>2]=c[G+12>>2];c[t>>2]=c[G>>2];c[t+4>>2]=c[G+4>>2];c[t+8>>2]=c[G+8>>2];c[t+12>>2]=c[G+12>>2];T=g+3|0;k=(c[n>>2]|0)+(T<<4)|0;S=c[(c[A>>2]|0)+116>>2]&1;c[C>>2]=c[k>>2];c[C+4>>2]=c[k+4>>2];c[C+8>>2]=c[k+8>>2];c[C+12>>2]=c[k+12>>2];c[D>>2]=c[K>>2];c[D+4>>2]=c[K+4>>2];c[D+8>>2]=c[K+8>>2];c[D+12>>2]=c[K+12>>2];Ng(H,C,D,S);c[u>>2]=c[H>>2];c[u+4>>2]=c[H+4>>2];c[u+8>>2]=c[H+8>>2];c[u+12>>2]=c[H+12>>2];eu((c[A>>2]|0)+16|0,N);g=T}if((Q|0)==48)Q=0;g=c[(c[q>>2]|0)+96>>2]|0;if(g|0){T=g+56|0;p=(c[(c[p>>2]|0)+96>>2]|0)+56|0;S=c[(c[A>>2]|0)+116>>2]&1;c[C>>2]=c[p>>2];c[C+4>>2]=c[p+4>>2];c[C+8>>2]=c[p+8>>2];c[C+12>>2]=c[p+12>>2];c[D>>2]=c[K>>2];c[D+4>>2]=c[K+4>>2];c[D+8>>2]=c[K+8>>2];c[D+12>>2]=c[K+12>>2];Ng(I,C,D,S);c[T>>2]=c[I>>2];c[T+4>>2]=c[I+4>>2];c[T+8>>2]=c[I+8>>2];c[T+12>>2]=c[I+12>>2];T=c[(c[q>>2]|0)+96>>2]|0;a[T+81>>0]=1;bB(b,T)}}r=r+1|0}Og(z,y)}else Q=3;while(0);if((Q|0)==3?(c[41924]|0)==0:0){c[41924]=1;_l(0,78197,O)|0;Q=Dn(J)|0;S=(qn(b)|0)!=0;T=Dn(B)|0;c[P>>2]=Q;c[P+4>>2]=S?122546:122549;c[P+8>>2]=T;_l(3,78303,P)|0}l=R;return}function Dg(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0;z=l;l=l+1600|0;u=z+1552|0;n=z+1536|0;t=z+840|0;v=z+144|0;w=z+1584|0;j=z+32|0;s=z+16|0;o=z;q=c[f>>2]&3;p=c[((q|0)==3?f:f+48|0)+40>>2]|0;x=f+-48|0;q=c[((q|0)==2?f:x)+40>>2]|0;r=f+16|0;k=c[r>>2]|0;i=c[k+172>>2]|0;while(1){m=c[(c[i+16>>2]|0)+172>>2]|0;if(!m)break;else i=m}k=(c[k+96>>2]|0)+56|0;i=(c[((c[i>>2]&3|0)==3?i:i+48|0)+40>>2]|0)+16|0;m=(c[i>>2]|0)+16|0;c[k>>2]=c[m>>2];c[k+4>>2]=c[m+4>>2];c[k+8>>2]=c[m+8>>2];c[k+12>>2]=c[m+12>>2];k=c[r>>2]|0;a[(c[k+96>>2]|0)+81>>0]=1;if((g|0)!=2){k=c[i>>2]|0;C=+h[k+16>>3];E=C-+h[k+88>>3];C=+h[k+96>>3]+C;B=+h[k+24>>3];D=+h[k+80>>3]*.5+B;k=c[(c[b+16>>2]|0)+196>>2]|0;m=c[p+16>>2]|0;j=c[m+232>>2]|0;B=+(~~(+(~~(B-+h[k+(j<<6)+16>>3]-+h[m+24>>3]+ +h[k+(j<<6)+24>>3])|0)*.16666666666666666)|0);B=D-(B<5.0?5.0:B);Gg(b,d,e,p,f,t,1);Gg(b,d,e,q,f,v,0);j=t+52|0;k=c[j>>2]|0;m=k+-1|0;A=+h[t+56+(m<<5)>>3];h[16878]=A;h[16879]=+h[t+56+(m<<5)+24>>3];h[16880]=E;h[16881]=B;h[16882]=A;h[16883]=B;m=v+52|0;i=(c[m>>2]|0)+-1|0;A=+h[v+56+(i<<5)+16>>3];h[16884]=A;h[16885]=D;h[16886]=C;h[16889]=B;h[16887]=+h[v+56+(i<<5)+24>>3];h[16888]=A;i=0;while(1){if((i|0)>=(k|0)){i=0;break}k=t+56+(i<<5)|0;c[u>>2]=c[k>>2];c[u+4>>2]=c[k+4>>2];c[u+8>>2]=c[k+8>>2];c[u+12>>2]=c[k+12>>2];c[u+16>>2]=c[k+16>>2];c[u+20>>2]=c[k+20>>2];c[u+24>>2]=c[k+24>>2];c[u+28>>2]=c[k+28>>2];Lz(e,u);i=i+1|0;k=c[j>>2]|0}while(1){if((i|0)==3)break;t=135024+(i<<5)|0;c[u>>2]=c[t>>2];c[u+4>>2]=c[t+4>>2];c[u+8>>2]=c[t+8>>2];c[u+12>>2]=c[t+12>>2];c[u+16>>2]=c[t+16>>2];c[u+20>>2]=c[t+20>>2];c[u+24>>2]=c[t+24>>2];c[u+28>>2]=c[t+28>>2];Lz(e,u);i=i+1|0}j=c[m>>2]|0;while(1){i=j+-1|0;if((j|0)<=0)break;j=v+56+(i<<5)|0;c[u>>2]=c[j>>2];c[u+4>>2]=c[j+4>>2];c[u+8>>2]=c[j+8>>2];c[u+12>>2]=c[j+12>>2];c[u+16>>2]=c[j+16>>2];c[u+20>>2]=c[j+20>>2];c[u+24>>2]=c[j+24>>2];c[u+28>>2]=c[j+28>>2];Lz(e,u);j=i}if((g|0)==10)j=ny(e,w)|0;else j=ty(e,w)|0;i=c[w>>2]|0;if(i|0)y=17}else{i=(c[p+16>>2]|0)+16|0;v=k+16|0;c[n>>2]=c[i>>2];c[n+4>>2]=c[i+4>>2];c[n+8>>2]=c[i+8>>2];c[n+12>>2]=c[i+12>>2];c[u>>2]=c[v>>2];c[u+4>>2]=c[v+4>>2];c[u+8>>2]=c[v+8>>2];c[u+12>>2]=c[v+12>>2];Ag(s,n,u);v=(c[q+16>>2]|0)+16|0;i=(c[r>>2]|0)+56|0;c[n>>2]=c[v>>2];c[n+4>>2]=c[v+4>>2];c[n+8>>2]=c[v+8>>2];c[n+12>>2]=c[v+12>>2];c[u>>2]=c[i>>2];c[u+4>>2]=c[i+4>>2];c[u+8>>2]=c[i+8>>2];c[u+12>>2]=c[i+12>>2];Ag(o,n,u);i=c[(c[r>>2]|0)+96>>2]|0;D=+h[i+56>>3];E=+h[i+64>>3]-+h[i+32>>3]*.5;i=j+16|0;c[j>>2]=c[s>>2];c[j+4>>2]=c[s+4>>2];c[j+8>>2]=c[s+8>>2];c[j+12>>2]=c[s+12>>2];c[i>>2]=c[s>>2];c[i+4>>2]=c[s+4>>2];c[i+8>>2]=c[s+8>>2];c[i+12>>2]=c[s+12>>2];i=j+32|0;v=j+48|0;y=j+64|0;h[j+64>>3]=D;h[j+72>>3]=E;c[v>>2]=c[y>>2];c[v+4>>2]=c[y+4>>2];c[v+8>>2]=c[y+8>>2];c[v+12>>2]=c[y+12>>2];c[i>>2]=c[y>>2];c[i+4>>2]=c[y+4>>2];c[i+8>>2]=c[y+8>>2];c[i+12>>2]=c[y+12>>2];i=j+80|0;y=j+96|0;c[y>>2]=c[o>>2];c[y+4>>2]=c[o+4>>2];c[y+8>>2]=c[o+8>>2];c[y+12>>2]=c[o+12>>2];c[i>>2]=c[o>>2];c[i+4>>2]=c[o+4>>2];c[i+8>>2]=c[o+8>>2];c[i+12>>2]=c[o+12>>2];c[w>>2]=7;i=7;y=17}if((y|0)==17)Jz(f,c[((c[f>>2]&3|0)==2?f:x)+40>>2]|0,j,i,17224);l=z;return}function Eg(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var i=0.0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0.0,s=0,t=0.0,u=0,v=0,w=0,x=0,y=0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0;N=l;l=l+352|0;x=N+336|0;w=N+320|0;L=N+128|0;u=N+304|0;y=N+288|0;M=N+112|0;E=N+96|0;F=N+80|0;G=N+64|0;H=N+48|0;I=N+32|0;J=N+16|0;K=N;a=a+16|0;q=(c[a>>2]|0)+16|0;v=(c[d+(e<<2)>>2]|0)+16|0;s=(c[v>>2]|0)+16|0;c[w>>2]=c[q>>2];c[w+4>>2]=c[q+4>>2];c[w+8>>2]=c[q+8>>2];c[w+12>>2]=c[q+12>>2];c[x>>2]=c[s>>2];c[x+4>>2]=c[s+4>>2];c[x+8>>2]=c[s+8>>2];c[x+12>>2]=c[s+12>>2];Ag(u,w,x);C=+h[u>>3];D=+h[u+8>>3];u=(c[b+16>>2]|0)+16|0;v=(c[v>>2]|0)+56|0;c[w>>2]=c[u>>2];c[w+4>>2]=c[u+4>>2];c[w+8>>2]=c[u+8>>2];c[w+12>>2]=c[u+12>>2];c[x>>2]=c[v>>2];c[x+4>>2]=c[v+4>>2];c[x+8>>2]=c[v+8>>2];c[x+12>>2]=c[v+12>>2];Ag(y,w,x);A=+h[y>>3];B=+h[y+8>>3];if((f|0)>1){z=+h[(c[a>>2]|0)+80>>3];i=z*.5;z=z/+(f+-1|0)}else{i=0.0;z=0.0}p=(g|8|0)==10;m=L+8|0;q=L+16|0;r=(A+C*2.0)*.3333333333333333;s=L+32|0;t=(A*2.0+C)*.3333333333333333;n=L+24|0;u=L+48|0;v=L+64|0;w=L+80|0;x=L+96|0;y=L+112|0;k=L+128|0;o=L+136|0;i=D-i;b=0;while(1){if((b|0)>=(f|0))break;j=c[d+(b+e<<2)>>2]|0;h[L>>3]=C;h[m>>3]=D;if(p){Ig(M,r,i);c[q>>2]=c[M>>2];c[q+4>>2]=c[M+4>>2];c[q+8>>2]=c[M+8>>2];c[q+12>>2]=c[M+12>>2];Ig(E,t,i);c[s>>2]=c[E>>2];c[s+4>>2]=c[E+4>>2];c[s+8>>2]=c[E+8>>2];c[s+12>>2]=c[E+12>>2];a=4;g=3}else{h[q>>3]=C;h[n>>3]=D;Ig(F,r,i);c[s>>2]=c[F>>2];c[s+4>>2]=c[F+4>>2];c[s+8>>2]=c[F+8>>2];c[s+12>>2]=c[F+12>>2];Ig(G,r,i);c[u>>2]=c[G>>2];c[u+4>>2]=c[G+4>>2];c[u+8>>2]=c[G+8>>2];c[u+12>>2]=c[G+12>>2];Ig(H,r,i);c[v>>2]=c[H>>2];c[v+4>>2]=c[H+4>>2];c[v+8>>2]=c[H+8>>2];c[v+12>>2]=c[H+12>>2];Ig(I,t,i);c[w>>2]=c[I>>2];c[w+4>>2]=c[I+4>>2];c[w+8>>2]=c[I+8>>2];c[w+12>>2]=c[I+12>>2];Ig(J,t,i);c[x>>2]=c[J>>2];c[x+4>>2]=c[J+4>>2];c[x+8>>2]=c[J+8>>2];c[x+12>>2]=c[J+12>>2];Ig(K,t,i);c[y>>2]=c[K>>2];c[y+4>>2]=c[K+4>>2];c[y+8>>2]=c[K+8>>2];c[y+12>>2]=c[K+12>>2];h[k>>3]=A;h[o>>3]=B;a=10;g=9}h[L+(g<<4)>>3]=A;h[L+(g<<4)+8>>3]=B;Jz(j,c[((c[j>>2]&3|0)==2?j:j+-48|0)+40>>2]|0,L,a,17224);i=i+z;b=b+1|0}l=N;return}function Fg(a,d,e,f,g,i,j,k){a=a|0;d=d|0;e=e|0;f=f|0;g=g|0;i=i|0;j=j|0;k=k|0;var m=0,n=0.0,o=0,p=0,q=0,r=0,s=0.0,t=0,u=0,v=0,w=0,x=0,y=0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0;x=l;l=l+1440|0;t=x+1392|0;v=x+1424|0;w=x+696|0;u=x;r=c[j>>2]&3;q=c[((r|0)==3?j:j+48|0)+40>>2]|0;r=c[((r|0)==2?j:j+-48|0)+40>>2]|0;m=c[q+16>>2]|0;o=c[m+232>>2]|0;p=c[a+16>>2]|0;if((o|0)<(b[p+238>>1]|0)){y=c[p+196>>2]|0;p=o+1|0;n=+h[m+24>>3]-+h[y+(o<<6)+32>>3]-+h[(c[(c[c[y+(p<<6)+4>>2]>>2]|0)+16>>2]|0)+24>>3]-+h[y+(p<<6)+40>>3]}else n=+(c[p+252>>2]|0);z=+(i+1|0);s=+(c[d+12>>2]|0)/z;n=n/z;Hg(a,d,e,q,j,w,1);Hg(a,d,e,r,j,u,0);r=w+52|0;j=u+52|0;a=(k|0)==0;d=e+80|0;m=0;while(1){if((m|0)>=(i|0))break;q=c[f+(m+g<<2)>>2]|0;p=c[r>>2]|0;o=p+-1|0;D=+h[w+56+(o<<5)>>3];B=+h[w+56+(o<<5)+8>>3];C=+h[w+56+(o<<5)+16>>3];h[16878]=D;h[16881]=B;m=m+1|0;z=+(m|0);A=s*z;h[16880]=C+A;z=B-n*z;h[16879]=z;h[16882]=D;h[16885]=z;o=(c[j>>2]|0)+-1|0;D=+h[u+56+(o<<5)+16>>3];h[16884]=D;h[16883]=z-n;B=+h[u+56+(o<<5)>>3];C=+h[u+56+(o<<5)+8>>3];h[16888]=D;h[16889]=C;h[16886]=B-A;h[16887]=z;o=0;while(1){if((o|0)>=(p|0)){o=0;break}p=w+56+(o<<5)|0;c[t>>2]=c[p>>2];c[t+4>>2]=c[p+4>>2];c[t+8>>2]=c[p+8>>2];c[t+12>>2]=c[p+12>>2];c[t+16>>2]=c[p+16>>2];c[t+20>>2]=c[p+20>>2];c[t+24>>2]=c[p+24>>2];c[t+28>>2]=c[p+28>>2];Lz(e,t);o=o+1|0;p=c[r>>2]|0}while(1){if((o|0)==3)break;y=135024+(o<<5)|0;c[t>>2]=c[y>>2];c[t+4>>2]=c[y+4>>2];c[t+8>>2]=c[y+8>>2];c[t+12>>2]=c[y+12>>2];c[t+16>>2]=c[y+16>>2];c[t+20>>2]=c[y+20>>2];c[t+24>>2]=c[y+24>>2];c[t+28>>2]=c[y+28>>2];Lz(e,t);o=o+1|0}p=c[j>>2]|0;while(1){o=p+-1|0;if((p|0)<=0)break;p=u+56+(o<<5)|0;c[t>>2]=c[p>>2];c[t+4>>2]=c[p+4>>2];c[t+8>>2]=c[p+8>>2];c[t+12>>2]=c[p+12>>2];c[t+16>>2]=c[p+16>>2];c[t+20>>2]=c[p+20>>2];c[t+24>>2]=c[p+24>>2];c[t+28>>2]=c[p+28>>2];Lz(e,t);p=o}if(a)o=ty(e,v)|0;else o=ny(e,v)|0;p=c[v>>2]|0;if(!p)break;Jz(q,c[((c[q>>2]&3|0)==2?q:q+-48|0)+40>>2]|0,o,p,17224);c[d>>2]=0}l=x;return}function Gg(a,b,d,e,f,g,i){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;i=i|0;var j=0,k=0,m=0,n=0,o=0,p=0.0;n=l;l=l+128|0;j=n+96|0;k=n+64|0;o=n+32|0;m=n;jg(o,a,b,e,0,f);c[g>>2]=c[o>>2];c[g+4>>2]=c[o+4>>2];c[g+8>>2]=c[o+8>>2];c[g+12>>2]=c[o+12>>2];c[g+16>>2]=c[o+16>>2];c[g+20>>2]=c[o+20>>2];c[g+24>>2]=c[o+24>>2];c[g+28>>2]=c[o+28>>2];c[k>>2]=c[o>>2];c[k+4>>2]=c[o+4>>2];c[k+8>>2]=c[o+8>>2];c[k+12>>2]=c[o+12>>2];c[k+16>>2]=c[o+16>>2];c[k+20>>2]=c[o+20>>2];c[k+24>>2]=c[o+24>>2];c[k+28>>2]=c[o+28>>2];c[g+48>>2]=4;if(!(i<<24>>24))Pz(d,f,2,g,0);else Mz(d,f,2,g,0);b=g+52|0;f=(c[b>>2]|0)+-1|0;o=k+24|0;h[o>>3]=+h[g+56+(f<<5)+24>>3];i=k+8|0;h[i>>3]=+h[g+56+(f<<5)+8>>3];e=c[e+16>>2]|0;p=+h[(c[(c[a+16>>2]|0)+196>>2]|0)+(c[e+232>>2]<<6)+24>>3]+ +h[e+24>>3];c[j>>2]=c[k>>2];c[j+4>>2]=c[k+4>>2];c[j+8>>2]=c[k+8>>2];c[j+12>>2]=c[k+12>>2];c[j+16>>2]=c[k+16>>2];c[j+20>>2]=c[k+20>>2];c[j+24>>2]=c[k+24>>2];c[j+28>>2]=c[k+28>>2];lg(m,j,4,p);c[k>>2]=c[m>>2];c[k+4>>2]=c[m+4>>2];c[k+8>>2]=c[m+8>>2];c[k+12>>2]=c[m+12>>2];c[k+16>>2]=c[m+16>>2];c[k+20>>2]=c[m+20>>2];c[k+24>>2]=c[m+24>>2];c[k+28>>2]=c[m+28>>2];if(+h[k>>3]<+h[k+16>>3]?+h[i>>3]<+h[o>>3]:0){o=c[b>>2]|0;c[b>>2]=o+1;o=g+56+(o<<5)|0;c[o>>2]=c[k>>2];c[o+4>>2]=c[k+4>>2];c[o+8>>2]=c[k+8>>2];c[o+12>>2]=c[k+12>>2];c[o+16>>2]=c[k+16>>2];c[o+20>>2]=c[k+20>>2];c[o+24>>2]=c[k+24>>2];c[o+28>>2]=c[k+28>>2]}l=n;return}function Hg(a,b,d,e,f,g,i){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;i=i|0;var j=0,k=0,m=0,n=0,o=0,p=0.0;n=l;l=l+128|0;j=n+96|0;k=n+64|0;o=n+32|0;m=n;jg(o,a,b,e,0,f);c[g>>2]=c[o>>2];c[g+4>>2]=c[o+4>>2];c[g+8>>2]=c[o+8>>2];c[g+12>>2]=c[o+12>>2];c[g+16>>2]=c[o+16>>2];c[g+20>>2]=c[o+20>>2];c[g+24>>2]=c[o+24>>2];c[g+28>>2]=c[o+28>>2];c[k>>2]=c[o>>2];c[k+4>>2]=c[o+4>>2];c[k+8>>2]=c[o+8>>2];c[k+12>>2]=c[o+12>>2];c[k+16>>2]=c[o+16>>2];c[k+20>>2]=c[o+20>>2];c[k+24>>2]=c[o+24>>2];c[k+28>>2]=c[o+28>>2];c[g+48>>2]=1;if(!(i<<24>>24))Pz(d,f,2,g,0);else Mz(d,f,2,g,0);b=g+52|0;f=(c[b>>2]|0)+-1|0;o=k+24|0;h[o>>3]=+h[g+56+(f<<5)+24>>3];i=k+8|0;h[i>>3]=+h[g+56+(f<<5)+8>>3];e=c[e+16>>2]|0;p=+h[e+24>>3]-+h[(c[(c[a+16>>2]|0)+196>>2]|0)+(c[e+232>>2]<<6)+24>>3];c[j>>2]=c[k>>2];c[j+4>>2]=c[k+4>>2];c[j+8>>2]=c[k+8>>2];c[j+12>>2]=c[k+12>>2];c[j+16>>2]=c[k+16>>2];c[j+20>>2]=c[k+20>>2];c[j+24>>2]=c[k+24>>2];c[j+28>>2]=c[k+28>>2];lg(m,j,1,p);c[k>>2]=c[m>>2];c[k+4>>2]=c[m+4>>2];c[k+8>>2]=c[m+8>>2];c[k+12>>2]=c[m+12>>2];c[k+16>>2]=c[m+16>>2];c[k+20>>2]=c[m+20>>2];c[k+24>>2]=c[m+24>>2];c[k+28>>2]=c[m+28>>2];if(+h[k>>3]<+h[k+16>>3]?+h[i>>3]<+h[o>>3]:0){o=c[b>>2]|0;c[b>>2]=o+1;o=g+56+(o<<5)|0;c[o>>2]=c[k>>2];c[o+4>>2]=c[k+4>>2];c[o+8>>2]=c[k+8>>2];c[o+12>>2]=c[k+12>>2];c[o+16>>2]=c[k+16>>2];c[o+20>>2]=c[k+20>>2];c[o+24>>2]=c[k+24>>2];c[o+28>>2]=c[k+28>>2]}l=n;return}function Ig(a,b,c){a=a|0;b=+b;c=+c;h[a>>3]=b;h[a+8>>3]=c;return}function Jg(b,d,e,f,g,i,j){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;i=i|0;j=j|0;var k=0,m=0,n=0,o=0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0,z=0,A=0.0,B=0.0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0.0;Y=l;l=l+288|0;R=Y+256|0;Q=Y+240|0;P=Y+224|0;V=Y+280|0;W=Y+272|0;X=Y+32|0;S=Y+16|0;T=Y;m=Y+208|0;n=Y+192|0;o=c[e+(f<<2)>>2]|0;U=vw(g<<2)|0;k=0;while(1){if((k|0)>=(g|0))break;c[U+(k<<2)>>2]=c[e+(k+f<<2)>>2];k=k+1|0}rL(U,g,4,11);e=b+16|0;f=(c[e>>2]|0)+16|0;o=o+16|0;C=(c[o>>2]|0)+16|0;c[Q>>2]=c[f>>2];c[Q+4>>2]=c[f+4>>2];c[Q+8>>2]=c[f+8>>2];c[Q+12>>2]=c[f+12>>2];c[R>>2]=c[C>>2];c[R+4>>2]=c[C+4>>2];c[R+8>>2]=c[C+8>>2];c[R+12>>2]=c[C+12>>2];Ag(m,Q,R);c[S>>2]=c[m>>2];c[S+4>>2]=c[m+4>>2];c[S+8>>2]=c[m+8>>2];c[S+12>>2]=c[m+12>>2];C=d+16|0;f=(c[C>>2]|0)+16|0;o=(c[o>>2]|0)+56|0;c[Q>>2]=c[f>>2];c[Q+4>>2]=c[f+4>>2];c[Q+8>>2]=c[f+8>>2];c[Q+12>>2]=c[f+12>>2];c[R>>2]=c[o>>2];c[R+4>>2]=c[o+4>>2];c[R+8>>2]=c[o+8>>2];c[R+12>>2]=c[o+12>>2];Ag(n,Q,R);c[T>>2]=c[n>>2];c[T+4>>2]=c[n+4>>2];c[T+8>>2]=c[n+8>>2];c[T+12>>2]=c[n+12>>2];w=+h[(c[e>>2]|0)+96>>3]+ +h[S>>3];x=+h[T>>3]-+h[(c[C>>2]|0)+88>>3];u=x+w;v=u*.5;C=c[U>>2]|0;c[X>>2]=c[S>>2];c[X+4>>2]=c[S+4>>2];c[X+8>>2]=c[S+8>>2];c[X+12>>2]=c[S+12>>2];o=X+16|0;c[o>>2]=c[S>>2];c[o+4>>2]=c[S+4>>2];c[o+8>>2]=c[S+8>>2];c[o+12>>2]=c[S+12>>2];e=X+32|0;c[e>>2]=c[T>>2];c[e+4>>2]=c[T+4>>2];c[e+8>>2]=c[T+8>>2];c[e+12>>2]=c[T+12>>2];f=X+48|0;c[f>>2]=c[T>>2];c[f+4>>2]=c[T+4>>2];c[f+8>>2]=c[T+8>>2];c[f+12>>2]=c[T+12>>2];Jz(C,c[((c[C>>2]&3|0)==2?C:C+-48|0)+40>>2]|0,X,4,17224);C=c[(c[C+16>>2]|0)+96>>2]|0;h[C+56>>3]=v;z=S+8|0;r=+h[z>>3];s=+h[C+32>>3];h[C+64>>3]=(s+6.0)*.5+r;a[C+81>>0]=1;r=r+3.0;B=+h[C+24>>3];A=(u-B)*.5;B=(B+u)*.5;C=X+24|0;D=X+40|0;E=X+56|0;F=X+64|0;G=T+8|0;H=X+72|0;I=X+80|0;J=X+88|0;K=X+96|0;L=X+104|0;M=X+112|0;N=X+120|0;O=V+4|0;n=(i|0)==6&1;q=0.0;p=0.0;s=s+r;m=1;while(1){if((m|0)>=(j|0)){y=6;break}d=c[U+(m<<2)>>2]|0;if(!(m&1)){c[X>>2]=c[S>>2];c[X+4>>2]=c[S+4>>2];c[X+8>>2]=c[S+8>>2];c[X+12>>2]=c[S+12>>2];h[o>>3]=A;h[C>>3]=+h[z>>3];h[e>>3]=A;h[D>>3]=s;h[f>>3]=B;h[E>>3]=s;h[F>>3]=B;t=+h[G>>3];h[H>>3]=t;Z=+h[T>>3];h[I>>3]=Z;h[J>>3]=t;h[K>>3]=Z;Z=s+6.0;h[L>>3]=Z;h[M>>3]=+h[S>>3];h[N>>3]=Z;s=+h[(c[(c[d+16>>2]|0)+96>>2]|0)+32>>3];t=Z+s*.5;s=Z+s}else{k=d+16|0;b=c[(c[k>>2]|0)+96>>2]|0;if((m|0)==1){p=+h[b+24>>3];q=(p+u)*.5;p=(u-p)*.5}r=r+-6.0-+h[b+32>>3];c[X>>2]=c[S>>2];c[X+4>>2]=c[S+4>>2];c[X+8>>2]=c[S+8>>2];c[X+12>>2]=c[S+12>>2];h[o>>3]=+h[S>>3];t=r+-6.0;h[C>>3]=t;h[e>>3]=+h[T>>3];h[D>>3]=t;c[f>>2]=c[T>>2];c[f+4>>2]=c[T+4>>2];c[f+8>>2]=c[T+8>>2];c[f+12>>2]=c[T+12>>2];h[F>>3]=q;h[H>>3]=+h[G>>3];h[I>>3]=q;h[J>>3]=r;h[K>>3]=p;h[L>>3]=r;h[M>>3]=p;h[N>>3]=+h[z>>3];t=+h[(c[(c[k>>2]|0)+96>>2]|0)+32>>3]*.5+r}c[O>>2]=8;c[V>>2]=X;c[P>>2]=c[S>>2];c[P+4>>2]=c[S+4>>2];c[P+8>>2]=c[S+8>>2];c[P+12>>2]=c[S+12>>2];c[Q>>2]=c[T>>2];c[Q+4>>2]=c[T+4>>2];c[Q+8>>2]=c[T+8>>2];c[Q+12>>2]=c[T+12>>2];c[R>>2]=c[V>>2];c[R+4>>2]=c[V+4>>2];k=jy(P,Q,R,W,n)|0;b=c[W>>2]|0;if(!b)break;i=c[(c[d+16>>2]|0)+96>>2]|0;h[i+56>>3]=v;h[i+64>>3]=t;a[i+81>>0]=1;Jz(d,c[((c[d>>2]&3|0)==2?d:d+-48|0)+40>>2]|0,k,b,17224);m=m+1|0}a:do if((y|0)==6){v=(x+w*2.0)*.3333333333333333;u=(x*2.0+w)*.3333333333333333;while(1){if((m|0)>=(g|0))break;d=c[U+(m<<2)>>2]|0;if(!(m&1)){c[X>>2]=c[S>>2];c[X+4>>2]=c[S+4>>2];c[X+8>>2]=c[S+8>>2];c[X+12>>2]=c[S+12>>2];h[o>>3]=A;h[C>>3]=+h[z>>3];h[e>>3]=A;h[D>>3]=s;h[f>>3]=B;h[E>>3]=s;h[F>>3]=B;t=+h[G>>3];h[H>>3]=t;Z=+h[T>>3];h[I>>3]=Z;h[J>>3]=t;h[K>>3]=Z;Z=s+6.0;h[L>>3]=Z;h[M>>3]=+h[S>>3];s=Z;t=p;p=Z}else{y=(m|0)==1;t=y?v:p;q=y?u:q;p=r+-6.0;c[X>>2]=c[S>>2];c[X+4>>2]=c[S+4>>2];c[X+8>>2]=c[S+8>>2];c[X+12>>2]=c[S+12>>2];h[o>>3]=+h[S>>3];r=r+-12.0;h[C>>3]=r;h[e>>3]=+h[T>>3];h[D>>3]=r;c[f>>2]=c[T>>2];c[f+4>>2]=c[T+4>>2];c[f+8>>2]=c[T+8>>2];c[f+12>>2]=c[T+12>>2];h[F>>3]=q;h[H>>3]=+h[G>>3];h[I>>3]=q;h[J>>3]=p;h[K>>3]=t;h[L>>3]=p;h[M>>3]=t;r=p;p=+h[z>>3]}h[N>>3]=p;c[O>>2]=8;c[V>>2]=X;c[P>>2]=c[S>>2];c[P+4>>2]=c[S+4>>2];c[P+8>>2]=c[S+8>>2];c[P+12>>2]=c[S+12>>2];c[Q>>2]=c[T>>2];c[Q+4>>2]=c[T+4>>2];c[Q+8>>2]=c[T+8>>2];c[Q+12>>2]=c[T+12>>2];c[R>>2]=c[V>>2];c[R+4>>2]=c[V+4>>2];k=jy(P,Q,R,W,n)|0;b=c[W>>2]|0;if(!b)break a;Jz(d,c[((c[d>>2]&3|0)==2?d:d+-48|0)+40>>2]|0,k,b,17224);m=m+1|0;p=t}_I(U)}while(0);l=Y;return}function Kg(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,i=0,j=0,k=0;g=l;l=l+16|0;f=g;j=(qn(b)|0)==0;j=j?17648:17640;a[f>>0]=a[j>>0]|0;a[f+1>>0]=a[j+1>>0]|0;a[f+2>>0]=a[j+2>>0]|0;a[f+3>>0]=a[j+3>>0]|0;f=gn(78335,f,0)|0;No(f,122277,280,1)|0;ym(f,0,80018,174181)|0;j=vw(96)|0;e=c[f+16>>2]|0;c[e+8>>2]=j;i=c[b+16>>2]|0;k=c[i+8>>2]|0;h[j>>3]=+h[k>>3];h[j+24>>3]=+h[k+24>>3];a[e+115>>0]=a[i+115>>0]|0;c[e+116>>2]=c[i+116>>2]&1^1;c[e+248>>2]=c[i+248>>2];c[e+252>>2]=c[i+252>>2];e=Dm(so(b)|0,1,0)|0;while(1){if(!e)break;ym(f,1,c[e+8>>2]|0,c[e+12>>2]|0)|0;e=Dm(so(b)|0,1,e)|0}e=Dm(so(b)|0,2,0)|0;while(1){if(!e)break;ym(f,2,c[e+8>>2]|0,c[e+12>>2]|0)|0;e=Dm(so(b)|0,2,e)|0}if(!(ym(f,2,96251,0)|0))ym(f,2,96251,174181)|0;if(!(ym(f,2,96242,0)|0))ym(f,2,96242,174181)|0;Pg(f,d);l=g;return f|0}function Lg(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;e=l;l=l+16|0;d=e;a=no(a,Dn(b)|0,1)|0;No(a,122241,304,1)|0;Mm(b,a)|0;if((By(b)|0)==2){f=b+16|0;b=ww((rJ(c[c[(c[f>>2]|0)+104>>2]>>2]|0)|0)+3|0)|0;c[d>>2]=c[c[(c[f>>2]|0)+104>>2]>>2];pL(b,78330,d)|0;Km(a,86240,b)|0}l=e;return a|0}function Mg(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;c=an(a,b,c,0,1)|0;No(c,122254,176,1)|0;Mm(d,c)|0;return c|0}function Ng(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0.0;i=l;l=l+32|0;g=i+16|0;f=i;if(e|0){j=+h[b>>3];e=b+8|0;h[b>>3]=+h[e>>3];h[e>>3]=-j};c[f>>2]=c[b>>2];c[f+4>>2]=c[b+4>>2];c[f+8>>2]=c[b+8>>2];c[f+12>>2]=c[b+12>>2];c[g>>2]=c[d>>2];c[g+4>>2]=c[d+4>>2];c[g+8>>2]=c[d+8>>2];c[g+12>>2]=c[d+12>>2];Ag(a,f,g);l=i;return}function Og(a,b){a=a|0;b=b|0;c[42233]=c[b>>2];c[42237]=c[b+4>>2];c[42238]=c[b+8>>2];c[42218]=c[b+12>>2];c[42219]=c[b+16>>2];c[42225]=c[b+20>>2];c[42224]=c[b+24>>2];c[42223]=c[b+28>>2];c[42249]=c[b+32>>2];c[42241]=c[b+36>>2];c[42226]=c[b+40>>2];c[42236]=c[b+44>>2];c[42245]=c[b+48>>2];c[42244]=c[b+52>>2];c[42243]=c[b+56>>2];c[42248]=c[b+60>>2];c[42242]=c[b+64>>2];c[42227]=c[b+68>>2];c[42189]=c[b+72>>2];c[42190]=c[b+76>>2];c[42191]=c[b+80>>2];c[42201]=c[b+84>>2];c[42194]=c[b+88>>2];c[42195]=c[b+92>>2];c[42196]=c[b+96>>2];c[42198]=c[b+100>>2];c[42199]=c[b+104>>2];c[42202]=c[b+108>>2];c[42205]=c[b+112>>2];c[42203]=c[b+116>>2];c[42204]=c[b+120>>2];c[42207]=c[b+124>>2];c[42206]=c[b+128>>2];c[42208]=c[b+132>>2];c[42209]=c[b+136>>2];c[42200]=c[b+140>>2];c[42212]=c[b+144>>2];c[42184]=c[b+148>>2];c[42181]=c[b+152>>2];_I(b);Ef(a);ln(a)|0;return}function Pg(a,b){a=a|0;b=b|0;c[b>>2]=c[42233];c[b+4>>2]=c[42237];c[b+8>>2]=c[42238];c[b+12>>2]=c[42218];c[b+16>>2]=c[42219];c[b+20>>2]=c[42225];c[b+24>>2]=c[42224];c[b+28>>2]=c[42223];c[b+32>>2]=c[42249];c[b+36>>2]=c[42241];c[b+40>>2]=c[42226];c[b+44>>2]=c[42236];c[b+48>>2]=c[42245];c[b+52>>2]=c[42244];c[b+56>>2]=c[42243];c[b+60>>2]=c[42248];c[b+64>>2]=c[42242];c[b+68>>2]=c[42227];c[b+72>>2]=c[42189];c[b+76>>2]=c[42190];c[b+80>>2]=c[42191];c[b+84>>2]=c[42201];c[b+88>>2]=c[42194];c[b+92>>2]=c[42195];c[b+96>>2]=c[42196];c[b+100>>2]=c[42198];c[b+104>>2]=c[42199];c[b+108>>2]=c[42202];c[b+112>>2]=c[42205];c[b+116>>2]=c[42203];c[b+120>>2]=c[42204];c[b+124>>2]=c[42207];c[b+128>>2]=c[42206];c[b+132>>2]=c[42208];c[b+136>>2]=c[42209];c[b+140>>2]=c[42200];c[b+144>>2]=c[42212];c[b+152>>2]=c[42181];c[b+148>>2]=c[42184];c[42233]=0;c[42237]=ym(a,2,80259,0)|0;c[42238]=ym(a,2,80268,0)|0;b=ym(a,2,86614,0)|0;c[42218]=b;if(!b)c[42218]=ym(a,2,86614,174181)|0;c[42219]=0;c[42225]=0;c[42224]=ym(a,2,86494,0)|0;c[42223]=ym(a,2,86485,0)|0;c[42249]=ym(a,2,86790,0)|0;c[42241]=0;c[42226]=ym(a,2,86240,0)|0;c[42236]=ym(a,2,78340,0)|0;c[42245]=0;c[42244]=ym(a,2,86690,0)|0;c[42243]=ym(a,2,86676,0)|0;c[42248]=ym(a,2,86781,0)|0;c[42242]=0;c[42227]=0;c[42189]=ym(a,1,96049,0)|0;c[42190]=ym(a,1,96043,0)|0;c[42191]=ym(a,1,90671,0)|0;c[42201]=0;c[42194]=ym(a,1,86485,0)|0;c[42195]=ym(a,1,86494,0)|0;c[42196]=0;c[42198]=ym(a,1,86240,0)|0;c[42199]=0;c[42202]=0;c[42205]=ym(a,1,86446,0)|0;c[42203]=ym(a,1,86529,0)|0;c[42204]=ym(a,1,86535,0)|0;c[42207]=ym(a,1,86547,0)|0;c[42206]=ym(a,1,86385,0)|0;c[42208]=ym(a,1,86552,0)|0;c[42209]=ym(a,1,78352,0)|0;c[42200]=0;c[42212]=0;c[42184]=ym(a,0,86446,0)|0;return}function Qg(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,g=0.0,i=0.0;d=c[(c[(c[a>>2]|0)+16>>2]|0)+96>>2]|0;a=c[(c[(c[b>>2]|0)+16>>2]|0)+96>>2]|0;b=(a|0)!=0;if(d)if(b?(f=+h[d+24>>3],i=+h[d+32>>3],e=+h[a+24>>3],g=+h[a+32>>3],!(f>e)):0)if(!(fg)a=-1;else a=i>2]|0)+116>>2]|0;if(!b)break;else a=b}b=c[a>>2]&3;d=c[(c[((b|0)==2?a:a+-48|0)+40>>2]|0)+16>>2]|0;e=c[d+232>>2]|0;a=c[(c[((b|0)==3?a:a+48|0)+40>>2]|0)+16>>2]|0;b=c[a+232>>2]|0;if((e|0)<=(b|0))if((e|0)<(b|0))a=1;else a=(c[d+236>>2]|0)<(c[a+236>>2]|0)&1;else a=0;return a|0}function Sg(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;d=l;l=l+16|0;e=d+8|0;f=d;h=(c[a+16>>2]|0)+180|0;g=(c[b+16>>2]|0)+172|0;c[f>>2]=c[h>>2];c[f+4>>2]=c[h+4>>2];c[e>>2]=c[g>>2];c[e+4>>2]=c[g+4>>2];b=Tg(a,f,b,e)|0;l=d;return b|0}function Tg(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;f=c[b+4>>2]|0;a:do if((f|0)>0?(g=c[e+4>>2]|0,(g|0)>0):0)if((f|0)<(g|0)){f=c[b>>2]|0;e=0;while(1){b=c[f+(e<<2)>>2]|0;if(!b){b=0;break a}if((c[((c[b>>2]&3|0)==2?b:b+-48|0)+40>>2]|0)==(d|0))break;else e=e+1|0}}else{f=c[e>>2]|0;e=0;while(1){b=c[f+(e<<2)>>2]|0;if(!b){b=0;break a}if((c[((c[b>>2]&3|0)==3?b:b+48|0)+40>>2]|0)==(a|0))break;else e=e+1|0}}else b=0;while(0);return b|0}function Ug(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;d=l;l=l+16|0;e=d+8|0;f=d;h=(c[a+16>>2]|0)+188|0;g=(c[b+16>>2]|0)+196|0;c[f>>2]=c[h>>2];c[f+4>>2]=c[h+4>>2];c[e>>2]=c[g>>2];c[e+4>>2]=c[g+4>>2];b=Tg(a,f,b,e)|0;l=d;return b|0}function Vg(a){a=a|0;var b=0,d=0,e=0,f=0;e=a+48|0;d=c[(c[((c[a>>2]&3|0)==3?a:e)+40>>2]|0)+16>>2]|0;b=c[d+180>>2]|0;if(!b)b=ww((c[d+184>>2]<<2)+8|0)|0;else b=yw(b,(c[d+184>>2]<<2)+8|0)|0;c[(c[(c[((c[a>>2]&3|0)==3?a:e)+40>>2]|0)+16>>2]|0)+180>>2]=b;f=c[(c[((c[a>>2]&3|0)==3?a:e)+40>>2]|0)+16>>2]|0;d=c[f+180>>2]|0;f=f+184|0;b=c[f>>2]|0;c[f>>2]=b+1;c[d+(b<<2)>>2]=a;e=c[(c[((c[a>>2]&3|0)==3?a:e)+40>>2]|0)+16>>2]|0;c[(c[e+180>>2]|0)+(c[e+184>>2]<<2)>>2]=0;e=a+-48|0;b=c[(c[((c[a>>2]&3|0)==2?a:e)+40>>2]|0)+16>>2]|0;d=c[b+172>>2]|0;if(!d)b=ww((c[b+176>>2]<<2)+8|0)|0;else b=yw(d,(c[b+176>>2]<<2)+8|0)|0;c[(c[(c[((c[a>>2]&3|0)==2?a:e)+40>>2]|0)+16>>2]|0)+172>>2]=b;b=c[(c[((c[a>>2]&3|0)==2?a:e)+40>>2]|0)+16>>2]|0;d=c[b+172>>2]|0;b=b+176|0;f=c[b>>2]|0;c[b>>2]=f+1;c[d+(f<<2)>>2]=a;f=c[(c[((c[a>>2]&3|0)==2?a:e)+40>>2]|0)+16>>2]|0;c[(c[f+172>>2]|0)+(c[f+176>>2]<<2)>>2]=0;return a|0}function Wg(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;e=a+4|0;f=c[e>>2]|0;d=0;while(1){if((d|0)>=(f|0))break;g=c[a>>2]|0;h=g+(d<<2)|0;if((c[h>>2]|0)==(b|0)){i=4;break}else d=d+1|0}if((i|0)==4){i=f+-1|0;c[e>>2]=i;c[h>>2]=c[g+(i<<2)>>2];c[(c[a>>2]|0)+(i<<2)>>2]=0}return}function Xg(a){a=a|0;if(!a)ma(78393,78403,117,78412);else{Wg((c[(c[((c[a>>2]&3|0)==3?a:a+48|0)+40>>2]|0)+16>>2]|0)+180|0,a);Wg((c[(c[((c[a>>2]&3|0)==2?a:a+-48|0)+40>>2]|0)+16>>2]|0)+172|0,a);return}}function Yg(a){a=a|0;var b=0,d=0,e=0,f=0;e=a+48|0;d=c[(c[((c[a>>2]&3|0)==3?a:e)+40>>2]|0)+16>>2]|0;b=c[d+204>>2]|0;if(!b)b=ww((c[d+208>>2]<<2)+8|0)|0;else b=yw(b,(c[d+208>>2]<<2)+8|0)|0;c[(c[(c[((c[a>>2]&3|0)==3?a:e)+40>>2]|0)+16>>2]|0)+204>>2]=b;f=c[(c[((c[a>>2]&3|0)==3?a:e)+40>>2]|0)+16>>2]|0;b=c[f+204>>2]|0;f=f+208|0;d=c[f>>2]|0;c[f>>2]=d+1;c[b+(d<<2)>>2]=a;e=c[(c[((c[a>>2]&3|0)==3?a:e)+40>>2]|0)+16>>2]|0;c[(c[e+204>>2]|0)+(c[e+208>>2]<<2)>>2]=0;return}function Zg(a){a=a|0;_g(a,(c[(c[((c[a>>2]&3|0)==3?a:a+48|0)+40>>2]|0)+16>>2]|0)+204|0);return}function _g(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;h=b+4|0;e=c[h>>2]|0;f=c[b>>2]|0;d=0;while(1){if((d|0)>=(e|0)){g=4;break}if((c[f+(d<<2)>>2]|0)==(a|0))break;else d=d+1|0}if((g|0)==4){if(!f)d=ww((e<<2)+8|0)|0;else d=yw(f,(e<<2)+8|0)|0;c[b>>2]=d;f=c[h>>2]|0;g=f+1|0;c[h>>2]=g;c[d+(f<<2)>>2]=a;c[(c[b>>2]|0)+(g<<2)>>2]=0}return}function $g(d,e,f){d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;n=vw(96)|0;g=n+48|0;c[g>>2]=c[g>>2]|3;c[n>>2]=c[n>>2]&-4|2;h=vw(176)|0;m=n+16|0;c[m>>2]=h;c[((c[n>>2]&3|0)==3?n:g)+40>>2]=d;j=n+-48|0;c[((c[n>>2]&3|0)==2?n:j)+40>>2]=e;a[h+112>>0]=1;if(!f){c[h+156>>2]=1;b[h+154>>1]=1;b[h+168>>1]=1;b[h+170>>1]=1}else{c[n>>2]=c[n>>2]&15|c[f>>2]&-16;c[g>>2]=c[g>>2]&15|c[f>>2]&-16;l=f+16|0;i=c[l>>2]|0;b[h+168>>1]=b[i+168>>1]|0;b[h+154>>1]=b[i+154>>1]|0;c[h+156>>2]=c[i+156>>2];b[h+170>>1]=b[i+170>>1]|0;d=c[((c[n>>2]&3|0)==3?n:g)+40>>2]|0;e=c[f>>2]&3;k=f+48|0;if((d|0)!=(c[((e|0)==3?f:k)+40>>2]|0)){g=f+-48|0;if((d|0)==(c[((e|0)==2?f:g)+40>>2]|0)){h=h+16|0;d=i+56|0;e=h+40|0;do{c[h>>2]=c[d>>2];h=h+4|0;d=d+4|0}while((h|0)<(e|0))}}else{h=h+16|0;d=i+16|0;e=h+40|0;do{c[h>>2]=c[d>>2];h=h+4|0;d=d+4|0}while((h|0)<(e|0));g=f+-48|0}d=c[((c[n>>2]&3|0)==2?n:j)+40>>2]|0;e=c[f>>2]&3;if((d|0)!=(c[((e|0)==2?f:g)+40>>2]|0)){if((d|0)==(c[((e|0)==3?f:k)+40>>2]|0)){h=(c[m>>2]|0)+56|0;d=(c[l>>2]|0)+16|0;e=h+40|0;do{c[h>>2]=c[d>>2];h=h+4|0;d=d+4|0}while((h|0)<(e|0))}}else{h=(c[m>>2]|0)+56|0;d=(c[l>>2]|0)+56|0;e=h+40|0;do{c[h>>2]=c[d>>2];h=h+4|0;d=d+4|0}while((h|0)<(e|0))}d=(c[l>>2]|0)+172|0;if(!(c[d>>2]|0))c[d>>2]=n;c[(c[m>>2]|0)+116>>2]=f}return n|0}function ah(a,b,c){a=a|0;b=b|0;c=c|0;return Vg($g(a,b,c)|0)|0}function bh(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;a=(c[a+16>>2]|0)+192|0;f=c[a>>2]|0;d=c[b+16>>2]|0;c[d+164>>2]=f;e=f;if(f|0)c[(c[e+16>>2]|0)+168>>2]=b;c[a>>2]=b;c[d+168>>2]=0;if((e|0)==(b|0))ma(78429,78403,215,78445);else return}function ch(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;if((a|0)==(b|0))ma(78455,78403,220,78462);f=c[b+16>>2]|0;d=f+164|0;if(c[d>>2]|0)ma(78475,78403,221,78462);e=(c[a+16>>2]|0)+164|0;c[d>>2]=c[e>>2];d=c[e>>2]|0;if(d|0)c[(c[d+16>>2]|0)+168>>2]=b;c[f+168>>2]=a;c[e>>2]=b;return}function dh(a,b){a=a|0;b=b|0;var d=0,e=0;if(!(eh(a,b)|0))ma(78494,78403,231,78515);b=c[b+16>>2]|0;d=c[b+164>>2]|0;e=d;b=b+168|0;if(d|0)c[(c[d+16>>2]|0)+168>>2]=c[b>>2];b=c[b>>2]|0;if(!b)c[(c[a+16>>2]|0)+192>>2]=e;else c[(c[b+16>>2]|0)+164>>2]=e;return}function eh(a,b){a=a|0;b=b|0;a=(c[a+16>>2]|0)+192|0;while(1){a=c[a>>2]|0;if((a|0)==0|(a|0)==(b|0))break;a=(c[a+16>>2]|0)+164|0}return a|0}function fh(b){b=b|0;var d=0,e=0,f=0,g=0;d=vw(64)|0;c[d>>2]=c[d>>2]&-4|1;e=d+16|0;c[e>>2]=vw(304)|0;c[d+24>>2]=so(b)|0;g=c[e>>2]|0;a[g+156>>0]=1;h[g+96>>3]=1.0;h[g+88>>3]=1.0;h[g+80>>3]=1.0;c[g+216>>2]=1;c[g+176>>2]=0;g=vw(20)|0;f=c[e>>2]|0;c[f+172>>2]=g;c[f+184>>2]=0;f=vw(20)|0;c[(c[e>>2]|0)+180>>2]=f;bh(b,d);b=(c[b+16>>2]|0)+232|0;c[b>>2]=(c[b>>2]|0)+1;return d|0}function gh(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0;g=d+48|0;e=c[(c[((c[d>>2]&3|0)==3?d:g)+40>>2]|0)+16>>2]|0;f=c[e+188>>2]|0;if(!f)e=ww((c[e+192>>2]<<2)+8|0)|0;else e=yw(f,(c[e+192>>2]<<2)+8|0)|0;c[(c[(c[((c[d>>2]&3|0)==3?d:g)+40>>2]|0)+16>>2]|0)+188>>2]=e;h=c[(c[((c[d>>2]&3|0)==3?d:g)+40>>2]|0)+16>>2]|0;f=c[h+188>>2]|0;h=h+192|0;e=c[h>>2]|0;c[h>>2]=e+1;c[f+(e<<2)>>2]=d;g=c[(c[((c[d>>2]&3|0)==3?d:g)+40>>2]|0)+16>>2]|0;c[(c[g+188>>2]|0)+(c[g+192>>2]<<2)>>2]=0;g=d+-48|0;e=c[(c[((c[d>>2]&3|0)==2?d:g)+40>>2]|0)+16>>2]|0;f=c[e+196>>2]|0;if(!f)e=ww((c[e+200>>2]<<2)+8|0)|0;else e=yw(f,(c[e+200>>2]<<2)+8|0)|0;c[(c[(c[((c[d>>2]&3|0)==2?d:g)+40>>2]|0)+16>>2]|0)+196>>2]=e;e=c[(c[((c[d>>2]&3|0)==2?d:g)+40>>2]|0)+16>>2]|0;f=c[e+196>>2]|0;e=e+200|0;h=c[e>>2]|0;c[e>>2]=h+1;c[f+(h<<2)>>2]=d;h=c[(c[((c[d>>2]&3|0)==2?d:g)+40>>2]|0)+16>>2]|0;c[(c[h+196>>2]|0)+(c[h+200>>2]<<2)>>2]=0;a[(c[b+16>>2]|0)+240>>0]=1;a[(c[(Vf(b)|0)+16>>2]|0)+240>>0]=1;return}function hh(a){a=a|0;var b=0,d=0;if(!a)ma(78393,78403,269,78532);b=c[(c[a+16>>2]|0)+116>>2]|0;if(b|0?(d=(c[b+16>>2]|0)+172|0,(c[d>>2]|0)==(a|0)):0)c[d>>2]=0;Wg((c[(c[((c[a>>2]&3|0)==3?a:a+48|0)+40>>2]|0)+16>>2]|0)+188|0,a);Wg((c[(c[((c[a>>2]&3|0)==2?a:a+-48|0)+40>>2]|0)+16>>2]|0)+196|0,a);return}function ih(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;f=l;l=l+16|0;d=(c[a+16>>2]|0)+172|0;e=c[d>>2]|0;do if((e|0)!=(b|0))if(!e){c[d>>2]=b;jh(a,b);break}else ma(80440,78403,340,78570);else _l(0,78549,f)|0;while(0);l=f;return}function jh(a,d){a=a|0;d=d|0;var f=0,g=0,h=0,i=0;f=(c[d+16>>2]|0)+170|0;i=c[a+16>>2]|0;a=b[i+170>>1]|0;if((e[f>>1]|0)<(a&65535))b[f>>1]=a;g=i+168|0;h=i+154|0;f=i+156|0;a=d;while(1){if(!a)break;d=c[a+16>>2]|0;i=d+168|0;b[i>>1]=(e[i>>1]|0)+(e[g>>1]|0);i=d+154|0;b[i>>1]=(e[i>>1]|0)+(e[h>>1]|0);i=d+156|0;c[i>>2]=(c[i>>2]|0)+(c[f>>2]|0);a=c[d+172>>2]|0}return}function kh(d){d=d|0;var e=0,f=0,g=0,h=0;f=d+16|0;e=c[(c[f>>2]|0)+172>>2]|0;a:while(1){if(!e)break;lh(e,d);h=c[e+16>>2]|0;g=c[h+172>>2]|0;if(!(b[h+168>>1]|0))mh(e);while(1){if((a[(c[e+16>>2]|0)+112>>0]|0)!=1){e=g;continue a}e=c[(c[((c[e>>2]&3|0)==2?e:e+-48|0)+40>>2]|0)+16>>2]|0;if((a[e+156>>0]|0)!=1){e=g;continue a}if((c[e+184>>2]|0)!=1){e=g;continue a}e=c[c[e+180>>2]>>2]|0;lh(e,d)}}c[(c[f>>2]|0)+172>>2]=0;return}function lh(a,d){a=a|0;d=d|0;var f=0;f=c[d+16>>2]|0;d=c[a+16>>2]|0;a=d+168|0;b[a>>1]=(e[a>>1]|0)-(e[f+168>>1]|0);a=d+154|0;b[a>>1]=(e[a>>1]|0)-(e[f+154>>1]|0);d=d+156|0;c[d>>2]=(c[d>>2]|0)-(c[f+156>>2]|0);return}function mh(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;if(!a)ma(78393,78403,128,78583);g=a+48|0;d=0;while(1){b=c[a>>2]|0;e=(c[(c[((b&3|0)==3?a:g)+40>>2]|0)+16>>2]|0)+180|0;f=c[(c[e>>2]|0)+(d<<2)>>2]|0;if(!f)break;if((f|0)==(a|0))Wg(e,a);d=d+1|0}g=a+-48|0;f=0;while(1){d=(c[(c[((b&3|0)==2?a:g)+40>>2]|0)+16>>2]|0)+172|0;e=c[(c[d>>2]|0)+(f<<2)>>2]|0;if(!e)break;if((e|0)==(a|0)){Wg(d,a);b=c[a>>2]|0}f=f+1|0}return}function nh(d){d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;p=l;l=l+1040|0;n=p+1032|0;o=p;m=p+8|0;k=d+16|0;d=c[k>>2]|0;j=b[d+236>>1]|0;while(1){if((j|0)>(b[d+238>>1]|0))break;i=c[d+196>>2]|0;h=i+(j<<6)|0;i=i+(j<<6)+4|0;g=0;d=0;while(1){if((g|0)>=(c[h>>2]|0))break;e=c[(c[i>>2]|0)+(g<<2)>>2]|0;f=e+16|0;if(c[(c[f>>2]|0)+112>>2]|0){if(!d){a[n>>0]=a[17644]|0;a[n+1>>0]=a[17645]|0;a[n+2>>0]=a[17646]|0;a[n+3>>0]=a[17647]|0;d=gn(78605,n,0)|0}c[o>>2]=g;pL(m,122187,o)|0;t=no(d,m,1)|0;No(t,78608,24,1)|0;q=c[(c[f>>2]|0)+180>>2]|0;r=c[q>>2]|0;r=c[(c[(c[((c[r>>2]&3|0)==2?r:r+-48|0)+40>>2]|0)+16>>2]|0)+236>>2]|0;q=c[q+4>>2]|0;q=c[(c[(c[((c[q>>2]&3|0)==2?q:q+-48|0)+40>>2]|0)+16>>2]|0)+236>>2]|0;s=(r|0)>(q|0);f=c[t+16>>2]|0;c[f+12>>2]=s?q:r;c[f+16>>2]=s?r:q;c[f+20>>2]=e}g=g+1|0}if(d|0){if((mn(d)|0)>1)oh(d,h);ln(d)|0}j=j+1|0;d=c[k>>2]|0}l=p;return}function oh(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;d=0;h=co(a)|0;a:while(1){if(!h)break;i=eo(a,h)|0;j=h+16|0;g=i;while(1){if(!g){h=i;continue a}f=c[g+16>>2]|0;e=c[j>>2]|0;if((c[f+16>>2]|0)>(c[e+12>>2]|0)){if((c[e+16>>2]|0)<=(c[f+12>>2]|0))an(a,h,g,0,1)|0}else{an(a,g,h,0,1)|0;d=1}g=eo(a,g)|0}}do if(d|0){h=Ip(a,78613,1)|0;j=vw((mn(a)|0)<<2)|0;i=vw((mn(a)|0)<<2)|0;f=b+4|0;e=co(a)|0;b:while(1){if(!e){d=23;break}if((c[(c[e+16>>2]|0)+8>>2]|0)==0?on(a,e,1,1)|0:0){c:do if(ph(a,e,h,i)|0){g=mn(h)|0;if((qh(a,h,j)|0)!=(g|0)){d=17;break b}rL(i,g,4,12);d=0;while(1){if((d|0)>=(g|0))break c;b=i+(d<<2)|0;k=c[j+(d<<2)>>2]|0;c[(c[k+16>>2]|0)+236>>2]=c[b>>2];c[(c[f>>2]|0)+(c[b>>2]<<2)>>2]=k;d=d+1|0}}while(0);sh(h)}e=eo(a,e)|0}if((d|0)==17)ma(78618,78628,265,78639);else if((d|0)==23){_I(j);break}}while(0);return}function ph(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;h=c[b+16>>2]|0;c[h+8>>2]=1;h=c[(c[(c[h+20>>2]|0)+16>>2]|0)+236>>2]|0;c[e+((mn(d)|0)<<2)>>2]=h;io(d,b,1)|0;h=Pm(a,b)|0;f=0;while(1){if(!h)break;j=c[h>>2]&3;g=c[((j|0)==2?h:h+-48|0)+40>>2]|0;i=c[g+16>>2]|0;f=f+((c[(c[(c[i+20>>2]|0)+16>>2]|0)+236>>2]|0)>(c[(c[(c[(c[(c[((j|0)==3?h:h+48|0)+40>>2]|0)+16>>2]|0)+20>>2]|0)+16>>2]|0)+236>>2]|0)&1)|0;if(!(c[i+8>>2]|0))f=(ph(a,g,d,e)|0)+f|0;h=Rm(a,h)|0}h=Sm(a,b)|0;while(1){if(!h)break;i=c[h>>2]&3;g=c[((i|0)==3?h:h+48|0)+40>>2]|0;j=c[g+16>>2]|0;f=f+((c[(c[(c[(c[(c[((i|0)==2?h:h+-48|0)+40>>2]|0)+16>>2]|0)+20>>2]|0)+16>>2]|0)+236>>2]|0)>(c[(c[(c[j+20>>2]|0)+16>>2]|0)+236>>2]|0)&1)|0;if(!(c[j+8>>2]|0))f=(ph(a,g,d,e)|0)+f|0;h=Tm(a,h)|0}return f|0}function qh(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;f=0;while(1){e=th(a,b)|0;if(!e)break;c[d+(f<<2)>>2]=c[(c[e+16>>2]|0)+20>>2];po(b,e)|0;e=Pm(a,e)|0;while(1){if(!e)break;g=Rm(a,e)|0;dn(a,e)|0;e=g}f=f+1|0}return f|0}function rh(a,b){a=a|0;b=b|0;return (c[a>>2]|0)-(c[b>>2]|0)|0}function sh(a){a=a|0;var b=0,c=0;b=co(a)|0;while(1){if(!b)break;c=eo(a,b)|0;po(a,b)|0;b=c}return}function th(a,b){a=a|0;b=b|0;var c=0;c=co(b)|0;while(1){if(!c){c=0;break}if(!(on(a,c,1,0)|0))break;c=eo(b,c)|0}return c|0}function uh(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;vh(b);i=b+16|0;f=0;e=0;while(1){if((f|0)>=(c[(c[i>>2]|0)+220>>2]|0))break;wh(b,f);f=f+1|0;e=(xh(b,0,d)|0)+e|0}yh(b);h=1;while(1){f=c[i>>2]|0;g=c[f+180>>2]|0;if((h|0)>(g|0))break;g=(zh(c[(c[f+184>>2]|0)+(h<<2)>>2]|0,d)|0)+e|0;h=h+1|0;e=g}do if((g|0)>0){f=Im(b,78653)|0;if(f|0?(IA(f)|0)<<24>>24==0:0)break;Yk(b);a[173893]=1;e=xh(b,2,d)|0}while(0);Ah(b,e);return}function vh(d){d=d|0;var e=0;if(0)xA();a[173893]=0;c[41927]=d;e=((nn(Vf(d)|0)|0)<<2)+4|0;c[41926]=vw(e)|0;c[41925]=vw(e)|0;qi(d);e=d+16|0;if(b[(c[e>>2]|0)+136>>1]&16)ri(d);Fk(d);tl(d,1);si(d);Hh(d);e=c[e>>2]|0;c[41928]=b[e+236>>1];c[41929]=b[e+238>>1];return}function wh(a,d){a=a|0;d=d|0;var e=0,f=0,g=0;a=c[a+16>>2]|0;c[a+192>>2]=c[(c[a+216>>2]|0)+(d<<2)>>2];a:do if((d|0)>0){d=b[a+238>>1]|0;e=a+196|0;a=b[a+236>>1]|0;while(1){if((a|0)>(d|0))break a;f=c[e>>2]|0;g=f+(a<<6)+4|0;f=f+(a<<6)|0;c[g>>2]=(c[g>>2]|0)+(c[f>>2]<<2);c[f>>2]=0;a=a+1|0}}while(0);return}function xh(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0;o=l;l=l+32|0;n=o;if((b|0)>1){e=Xh(0)|0;Yh(a)}else e=2147483647;m=c[13918]|0;k=b;f=0;b=e;while(1){if((k|0)>=3)break;f=c[42180]|0;if((k|0)==2)if((e|0)>(b|0)){_h(a);e=b}else e=b;else{e=(f|0)<4?f:4;if((Vf(a)|0)==(a|0))Zh(a,k);if(!k)Ih(a);Jh(a);g=Xh(0)|0;if((g|0)>(b|0)){f=e;e=g}else{Yh(a);f=e;e=g;b=g}}g=0;j=0;while(1){if((j|0)>=(f|0))break;if(0){c[n>>2]=k;c[n+4>>2]=j;c[n+8>>2]=g;c[n+12>>2]=e;c[n+16>>2]=b;zL(m,79046,n)|0}i=g+1|0;if((e|0)==0|(g|0)>=(c[41930]|0))break;$h(a,j);e=Xh(0)|0;if((e|0)>(b|0))g=i;else{Yh(a);g=+h[20878]*+(b|0)>+(e|0)?0:i;b=e}j=j+1|0}if(!e){e=0;break}else k=k+1|0}if((e|0)>(b|0))_h(a);if((b|0)>0){ai(a,0);e=Xh(0)|0}else e=b;a:do if(d|0){b=0;while(1){if((b|0)>=(f|0))break a;bi(a);b=b+1|0}}while(0);l=o;return e|0}function yh(a){a=a|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0;p=l;l=l+16|0;n=p;Wh(a);k=a+16|0;d=c[k>>2]|0;m=c[13918]|0;j=b[d+236>>1]|0;while(1){if((j|0)>(b[d+238>>1]|0))break;e=c[d+196>>2]|0;f=c[e+(j<<6)+8>>2]|0;c[e+(j<<6)>>2]=f;g=c[e+(j<<6)+12>>2]|0;c[e+(j<<6)+4>>2]=g;i=0;while(1){if((i|0)>=(f|0))break;h=c[g+(i<<2)>>2]|0;if(!h){o=6;break}c[(c[h+16>>2]|0)+236>>2]=i;i=i+1|0}if((o|0)==6){o=0;if(0){e=Dn(a)|0;d=c[(c[(c[k>>2]|0)+196>>2]|0)+(j<<6)>>2]|0;c[n>>2]=e;c[n+4>>2]=j;c[n+8>>2]=i;c[n+12>>2]=d;zL(m,78996,n)|0;d=c[k>>2]|0;e=c[d+196>>2]|0}c[e+(j<<6)>>2]=i}j=j+1|0}l=p;return}function zh(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;Sk(a);Hh(a);Ih(a);Jh(a);f=a+16|0;d=xh(a,2,b)|0;e=1;while(1){g=c[f>>2]|0;if((e|0)>(c[g+180>>2]|0))break;d=(zh(c[(c[g+184>>2]|0)+(e<<2)>>2]|0,b)|0)+d|0;e=e+1|0}Kh(a);return d|0}function Ah(d,e){d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0.0;q=l;l=l+16|0;p=q;f=c[41925]|0;if(f|0){_I(f);c[41925]=0}f=c[41926]|0;if(f|0){_I(f);c[41926]=0}o=d+16|0;f=1;while(1){g=c[o>>2]|0;if((f|0)>(c[g+180>>2]|0))break;Bh(c[(c[g+184>>2]|0)+(f<<2)>>2]|0);f=f+1|0}n=b[g+236>>1]|0;f=g;while(1){if((n|0)>(b[f+238>>1]|0))break;else m=0;while(1){f=c[f+196>>2]|0;if((m|0)>=(c[f+(n<<6)>>2]|0))break;k=(c[(c[f+(n<<6)+4>>2]|0)+(m<<2)>>2]|0)+16|0;f=c[k>>2]|0;c[f+236>>2]=m;f=c[f+188>>2]|0;a:do if(f|0){g=0;while(1){i=c[f+(g<<2)>>2]|0;if(!i)break a;j=i+16|0;if((a[(c[j>>2]|0)+112>>0]|0)==4){hh(i);_I(c[j>>2]|0);_I(i);g=g+-1|0;f=c[(c[k>>2]|0)+188>>2]|0}g=g+1|0}}while(0);m=m+1|0;f=c[o>>2]|0}Ch(c[f+(n<<6)+56>>2]|0);n=n+1|0;f=c[o>>2]|0}if(0){o=c[13918]|0;d=Dn(d)|0;r=+yA();c[p>>2]=d;c[p+4>>2]=e;h[p+8>>3]=r;zL(o,78664,p)|0}l=q;return}function Bh(a){a=a|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;g=a+16|0;d=1;while(1){f=c[g>>2]|0;if((d|0)>(c[f+180>>2]|0))break;Bh(c[(c[f+184>>2]|0)+(d<<2)>>2]|0);d=d+1|0}a:do if(c[f+268>>2]|0){e=b[f+236>>1]|0;d=f;while(1){if((e|0)>(b[d+238>>1]|0))break a;j=c[(c[d+268>>2]|0)+(e<<2)>>2]|0;i=Dh(a,j,-1)|0;j=Dh(a,j,1)|0;c[(c[(c[g>>2]|0)+268>>2]|0)+(e<<2)>>2]=i;k=c[(c[(c[(Vf(a)|0)+16>>2]|0)+196>>2]|0)+(e<<6)+4>>2]|0;i=c[(c[i+16>>2]|0)+236>>2]|0;f=c[g>>2]|0;h=c[f+196>>2]|0;c[h+(e<<6)+4>>2]=k+(i<<2);c[h+(e<<6)>>2]=(c[(c[j+16>>2]|0)+236>>2]|0)+1-i;e=e+1|0;d=f}}while(0);return}function Ch(a){a=a|0;if(a|0){_I(c[a+8>>2]|0);_I(a)}return}function Dh(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=b;while(1){b=Eh(b,c)|0;if(!b)break;if(Fh(a,b)|0){d=b;continue}e=(Gh(a,b)|0)==0;d=e?d:b}return d|0}function Eh(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;if(!a)ma(78703,78628,1023,78705);if((b|0)<0){a=c[a+16>>2]|0;e=c[a+236>>2]|0;if((e|0)>0){a=(c[(c[(c[41927]|0)+16>>2]|0)+196>>2]|0)+(c[a+232>>2]<<6)+4|0;d=e+-1|0;f=7}else g=0}else{a=c[a+16>>2]|0;e=c[a+236>>2]|0;a=(c[(c[(c[41927]|0)+16>>2]|0)+196>>2]|0)+(c[a+232>>2]<<6)+4|0;d=e+1|0;f=7}if((f|0)==7){a=c[(c[a>>2]|0)+(d<<2)>>2]|0;if(a)if((O((c[(c[a+16>>2]|0)+236>>2]|0)-e|0,b)|0)>0)g=a;else ma(78714,78628,1029,78705);else g=0}return g|0}function Fh(b,d){b=b|0;d=d|0;if(!(a[(c[d+16>>2]|0)+156>>0]|0))b=(Bo(b,d)|0)!=0&1;else b=0;return b|0}function Gh(b,d){b=b|0;d=d|0;var e=0,f=0;d=c[d+16>>2]|0;if(((a[d+156>>0]|0)==1?(c[d+176>>2]|0)==1:0)?(c[d+184>>2]|0)==1:0){d=c[d+180>>2]|0;while(1){d=c[d>>2]|0;e=c[d+16>>2]|0;if(!(a[e+112>>0]|0))break;else d=e+116|0}if(Bo(b,d)|0)d=1;else f=7}else f=7;if((f|0)==7)d=0;return d|0}function Hh(b){b=b|0;var d=0,e=0,f=0;f=l;l=l+16|0;e=f;d=c[42184]|0;a:do if((d|0)!=0|(c[42205]|0)!=0){d=FA(b,d,0)|0;if(d|0){switch(a[d>>0]|0){case 0:break a;case 111:{if(!(xJ(d,78916)|0)){Rh(b,1);break a}break}case 105:{if(!(xJ(d,83705)|0)){Rh(b,0);break a}break}default:{}}c[e>>2]=d;_l(1,78920,e)|0;break}d=Jp(b)|0;while(1){if(!d)break;if(!(Cj(d)|0))Hh(d);d=Kp(d)|0}if(c[42205]|0)Sh(b)}while(0);l=f;return}function Ih(d){d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0;k=d+16|0;e=c[k>>2]|0;j=b[e+236>>1]|0;while(1){if((j|0)>(b[e+238>>1]|0))break;else{f=0;i=0}while(1){g=c[e+196>>2]|0;h=c[g+(j<<6)>>2]|0;if((i|0)>=(h|0))break;g=c[(c[(c[g+(j<<6)+4>>2]|0)+(i<<2)>>2]|0)+16>>2]|0;a[g+158>>0]=0;a[g+157>>0]=0;c[g+284>>2]=i;if((f|0)==0&(c[g+192>>2]|0)>0){f=Ph(h,h)|0;e=c[k>>2]|0;c[(c[e+196>>2]|0)+(j<<6)+56>>2]=f;f=1}i=i+1|0}a:do if(f){i=0;f=h;while(1){if((i|0)>=(f|0))break a;h=c[(c[g+(j<<6)+4>>2]|0)+(i<<2)>>2]|0;if(!(a[(c[h+16>>2]|0)+157>>0]|0)){Qh(d,h);e=c[k>>2]|0;f=c[e+196>>2]|0;g=f;f=c[f+(j<<6)>>2]|0}i=i+1|0}}while(0);j=j+1|0}return}function Jh(d){d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;s=d+16|0;e=c[s>>2]|0;if(a[e+240>>0]|0){h=0;r=b[e+236>>1]|0;q=0;i=0;a:while(1){if((r|0)>(b[e+238>>1]|0))break;f=c[e+196>>2]|0;g=c[f+(r<<6)>>2]|0;if(!g){g=q;f=i}else{f=c[f+(r<<6)+4>>2]|0;o=c[(c[(c[f>>2]|0)+16>>2]|0)+236>>2]|0;e=0;while(1){if((e|0)>=(g|0))break;a[(c[(c[f+(e<<2)>>2]|0)+16>>2]|0)+157>>0]=0;e=e+1|0}e=(e<<2)+4|0;if(!h)p=ww(e)|0;else p=yw(i,e)|0;m=0;n=0;while(1){e=c[s>>2]|0;f=c[e+196>>2]|0;g=c[f+(r<<6)>>2]|0;if((g|0)<=(n|0))break;j=c[(c[f+(r<<6)+4>>2]|0)+(((c[e+116>>2]&1|0)==0?g+~n|0:n)<<2)>>2]|0;l=j+16|0;e=0;k=0;while(1){i=c[l>>2]|0;if((e|0)>=(c[i+200>>2]|0)){f=0;g=0;e=i;break}i=k+((Lh(d,c[(c[i+196>>2]|0)+(e<<2)>>2]|0)|0)!=0&1)|0;e=e+1|0;k=i}while(1){if((g|0)>=(c[e+192>>2]|0))break;i=f+((Lh(d,c[(c[e+188>>2]|0)+(g<<2)>>2]|0)|0)!=0&1)|0;f=i;g=g+1|0;e=c[l>>2]|0}if(f|k)if((k|0)==0&(a[e+157>>0]|0)==0)e=(Mh(d,j,p+(m<<2)|0,r)|0)+m|0;else e=m;else{c[p+(m<<2)>>2]=j;e=m+1|0}m=e;n=n+1|0}b:do if(m){c:do if(!(c[e+116>>2]&1)){f=p;e=p+(m<<2)|0;while(1){e=e+-4|0;if(f>>>0>=e>>>0){g=0;break c}n=c[f>>2]|0;c[f>>2]=c[e>>2];c[e>>2]=n;f=f+4|0}}else g=0;while(0);while(1){e=c[s>>2]|0;i=c[e+196>>2]|0;f=c[i+(r<<6)>>2]|0;if((g|0)>=(f|0)){m=0;g=i;break}n=c[p+(g<<2)>>2]|0;c[(c[i+(r<<6)+4>>2]|0)+(g<<2)>>2]=n;c[(c[n+16>>2]|0)+236>>2]=g+o;g=g+1|0}while(1){if((m|0)>=(f|0))break b;l=(c[(c[g+(r<<6)+4>>2]|0)+(m<<2)>>2]|0)+16|0;i=c[(c[l>>2]|0)+188>>2]|0;if(i){k=0;f=i;while(1){g=c[f+(k<<2)>>2]|0;e=c[s>>2]|0;if(!g)break;j=c[g>>2]&3;i=c[(c[(c[((j|0)==2?g:g+-48|0)+40>>2]|0)+16>>2]|0)+236>>2]|0;j=c[(c[(c[((j|0)==3?g:g+48|0)+40>>2]|0)+16>>2]|0)+236>>2]|0;if(!(c[e+116>>2]&1))if((i|0)<(j|0))t=36;else e=k;else if((i|0)>(j|0))t=36;else e=k;if((t|0)==36){t=0;if(Lh(d,g)|0){t=37;break a}hh(g);Nh(d,g);e=k+-1|0;f=c[(c[l>>2]|0)+188>>2]|0}k=e+1|0}f=c[e+196>>2]|0;g=f;f=c[f+(r<<6)>>2]|0}m=m+1|0}}while(0);a[(c[(c[(c[41927]|0)+16>>2]|0)+196>>2]|0)+(r<<6)+49>>0]=0;h=p;g=p;f=p}r=r+1|0;q=g;i=f}if((t|0)==37)ma(78762,78628,1561,78801);if(h|0)_I(q)}return}function Kh(a){a=a|0;var d=0,e=0;e=a+16|0;a=c[e>>2]|0;a:do if(c[a+268>>2]|0){d=b[a+236>>1]|0;while(1){if((d|0)>(b[a+238>>1]|0))break a;c[(c[a+268>>2]|0)+(d<<2)>>2]=c[c[(c[a+196>>2]|0)+(d<<6)+4>>2]>>2];d=d+1|0;a=c[e>>2]|0}}while(0);return}function Lh(a,b){a=a|0;b=b|0;if((c[(c[b+16>>2]|0)+156>>2]|0)!=0?(Oh(a,c[((c[b>>2]&3|0)==3?b:b+48|0)+40>>2]|0)|0)!=0:0)a=(Oh(a,c[((c[b>>2]&3|0)==2?b:b+-48|0)+40>>2]|0)|0)!=0&1;else a=0;return a|0}function Mh(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0;l=d+16|0;g=c[l>>2]|0;a[g+157>>0]=1;a:do if((c[g+192>>2]|0)>0){h=0;j=0;while(1){i=c[(c[g+188>>2]|0)+(j<<2)>>2]|0;if(!i)break a;if((Lh(b,i)|0)!=0?(k=c[((c[i>>2]&3|0)==2?i:i+-48|0)+40>>2]|0,(a[(c[k+16>>2]|0)+157>>0]|0)==0):0)h=(Mh(b,k,e+(h<<2)|0,f)|0)+h|0;j=j+1|0;g=c[l>>2]|0}}else h=0;while(0);if((c[g+232>>2]|0)==(f|0)){c[e+(h<<2)>>2]=d;return h+1|0}else ma(78814,78628,1490,78830);return 0}function Nh(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;i=c[d>>2]&3;j=c[((i|0)==2?d:d+-48|0)+40>>2]|0;f=c[(c[j+16>>2]|0)+188>>2]|0;a:do if(!f){e=d+48|0;m=15}else{l=d+48|0;g=((i|0)==3?d:l)+40|0;e=0;while(1){h=c[f+(e<<2)>>2]|0;if(!h){e=l;m=15;break a}if((c[((c[h>>2]&3|0)==2?h:h+-48|0)+40>>2]|0)==(c[g>>2]|0))break;else e=e+1|0}ih(d,h);e=(c[d+16>>2]|0)+172|0;if(!(c[e>>2]|0))c[e>>2]=h;e=c[h+16>>2]|0;if((a[e+112>>0]|0)==4?(k=e+116|0,(c[k>>2]|0)==0):0)c[k>>2]=d;e=c[(c[((c[d>>2]&3|0)==3?d:l)+40>>2]|0)+16>>2]|0;f=c[e+204>>2]|0;if(!f)e=ww((c[e+208>>2]<<2)+8|0)|0;else e=yw(f,(c[e+208>>2]<<2)+8|0)|0;c[(c[(c[((c[d>>2]&3|0)==3?d:l)+40>>2]|0)+16>>2]|0)+204>>2]=e;i=c[(c[((c[d>>2]&3|0)==3?d:l)+40>>2]|0)+16>>2]|0;j=c[i+204>>2]|0;i=i+208|0;k=c[i>>2]|0;c[i>>2]=k+1;c[j+(k<<2)>>2]=d;d=c[(c[((c[d>>2]&3|0)==3?d:l)+40>>2]|0)+16>>2]|0;c[(c[d+204>>2]|0)+(c[d+208>>2]<<2)>>2]=0}while(0);if((m|0)==15){m=$g(j,c[((i|0)==3?d:e)+40>>2]|0,d)|0;l=c[d+16>>2]|0;d=c[m+16>>2]|0;a[d+112>>0]=(a[l+112>>0]|0)==4?4:3;c[d+96>>2]=c[l+96>>2];gh(b,m)}return}function Oh(a,b){a=a|0;b=b|0;var c=0;c=Fh(a,b)|0;return Gh(a,b)|0|c|0}function Ph(a,b){a=a|0;b=b|0;var d=0;d=vw(12)|0;c[d>>2]=a;c[d+4>>2]=b;c[d+8>>2]=vw(O(b,a)|0)|0;return d|0}function Qh(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;o=d+16|0;l=c[o>>2]|0;k=c[(c[(c[b+16>>2]|0)+196>>2]|0)+(c[l+232>>2]<<6)+56>>2]|0;a[l+157>>0]=1;a[l+158>>0]=1;l=(c[(c[(Vf(b)|0)+16>>2]|0)+180>>2]|0)>0;e=c[o>>2]|0;f=c[e+188>>2]|0;a:do if(f){m=k+4|0;n=k+8|0;d=0;b:while(1){j=c[f+(d<<2)>>2]|0;if(!j){p=e;break a}if(l){if((Bo(b,c[((c[j>>2]&3|0)==3?j:j+48|0)+40>>2]|0)|0)!=0?(Bo(b,c[((c[j>>2]&3|0)==2?j:j+-48|0)+40>>2]|0)|0)!=0:0)q=7}else q=7;do if((q|0)==7){q=0;h=j+16|0;if(c[(c[h>>2]|0)+156>>2]|0){e=c[j>>2]&3;g=j+-48|0;r=c[(c[((e|0)==2?j:g)+40>>2]|0)+16>>2]|0;i=c[r+284>>2]|0;f=(i|0)<(c[k>>2]|0);if((a[r+158>>0]|0)==1){if(!f){q=10;break b}e=c[(c[(c[((e|0)==3?j:j+48|0)+40>>2]|0)+16>>2]|0)+284>>2]|0;f=c[m>>2]|0;if((e|0)>=(f|0)){q=12;break b}a[(c[n>>2]|0)+((O(f,i)|0)+e)>>0]=1;hh(j);d=d+-1|0;if((a[(c[h>>2]|0)+112>>0]|0)==4)break;Nh(b,j);break}else{if(!f){q=16;break b}e=c[(c[(c[((e|0)==3?j:j+48|0)+40>>2]|0)+16>>2]|0)+284>>2]|0;f=c[m>>2]|0;if((e|0)>=(f|0)){q=18;break b}a[(c[n>>2]|0)+((O(f,e)|0)+i)>>0]=1;e=c[((c[j>>2]&3|0)==2?j:g)+40>>2]|0;if(a[(c[e+16>>2]|0)+157>>0]|0)break;Qh(b,e);break}}}while(0);f=c[o>>2]|0;d=d+1|0;e=f;f=c[f+188>>2]|0}if((q|0)==10)ma(78840,78628,1251,78872);else if((q|0)==12)ma(78884,78628,1252,78872);else if((q|0)==16)ma(78840,78628,1260,78872);else if((q|0)==18)ma(78884,78628,1261,78872)}else p=e;while(0);a[p+158>>0]=0;return}function Rh(a,b){a=a|0;b=b|0;var c=0;c=co(a)|0;while(1){if(!c)break;Th(a,c,b);c=eo(a,c)|0}return}function Sh(b){b=b|0;var d=0,e=0,f=0,g=0,h=0;g=l;l=l+16|0;f=g;d=co(b)|0;while(1){if(!d)break;e=FA(d,c[42205]|0,0)|0;a:do if(e|0){switch(a[e>>0]|0){case 0:break a;case 111:{if(!(xJ(e,78916)|0)){Th(b,d,1);break a}break}case 105:{if(!(xJ(e,83705)|0)){Th(b,d,0);break a}break}default:{}}h=Dn(d)|0;c[f>>2]=e;c[f+4>>2]=h;_l(1,78951,f)|0}while(0);d=eo(b,d)|0}l=g;return}function Th(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;j=c[41926]|0;h=d+16|0;f=c[h>>2]|0;a:do if(!(c[f+212>>2]|0)){i=(e|0)!=0;b:do if(i){g=0;d=0;e=f;while(1){f=c[(c[e+180>>2]|0)+(g<<2)>>2]|0;if(!f)break b;if(!(Uh(f)|0)){c[j+(d<<2)>>2]=f;d=d+1|0;e=c[h>>2]|0}g=g+1|0}}else{g=0;d=0;e=f;while(1){f=c[(c[e+172>>2]|0)+(g<<2)>>2]|0;if(!f)break b;if(!(Uh(f)|0)){c[j+(d<<2)>>2]=f;d=d+1|0;e=c[h>>2]|0}g=g+1|0}}while(0);if((d|0)>=2){c[j+(d<<2)>>2]=0;rL(j,d,4,13);h=i?2:3;g=i?-1:1;f=1;while(1){d=c[j+(f<<2)>>2]|0;if(!d)break a;e=c[j+(f+-1<<2)>>2]|0;e=c[((c[e>>2]&3|0)==(h|0)?e:e+(g*48|0)|0)+40>>2]|0;d=c[((c[d>>2]&3|0)==(h|0)?d:d+(g*48|0)|0)+40>>2]|0;if(Ug(e,d)|0)break a;i=$g(e,d,0)|0;a[(c[i+16>>2]|0)+112>>0]=4;gh(b,i);f=f+1|0}}}while(0);return}function Uh(a){a=a|0;var b=0;while(1){b=c[(c[a+16>>2]|0)+116>>2]|0;if(!b)break;else a=b}b=c[a>>2]&3;return (c[(c[(c[((b|0)==3?a:a+48|0)+40>>2]|0)+16>>2]|0)+212>>2]|0)!=(c[(c[(c[((b|0)==2?a:a+-48|0)+40>>2]|0)+16>>2]|0)+212>>2]|0)|0}function Vh(a,b){a=a|0;b=b|0;return ((c[c[a>>2]>>2]|0)>>>4)-((c[c[b>>2]>>2]|0)>>>4)|0}function Wh(a){a=a|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0;f=c[a+16>>2]|0;g=f+220|0;h=c[g>>2]|0;if((h|0)>=2){i=f+216|0;a=0;e=0;while(1){if((e|0)>=(h|0))break;d=c[(c[i>>2]|0)+(e<<2)>>2]|0;if(a|0)c[(c[a+16>>2]|0)+164>>2]=d;j=c[d+16>>2]|0;c[j+168>>2]=a;a=d;d=j;while(1){d=c[d+164>>2]|0;if(!d)break;a=d;d=c[d+16>>2]|0}e=e+1|0}c[g>>2]=1;c[f+192>>2]=c[c[f+216>>2]>>2];b[f+236>>1]=c[41928];b[f+238>>1]=c[41929]}return}function Xh(d){d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;i=c[41927]|0;j=i+16|0;f=c[j>>2]|0;g=0;h=b[f+236>>1]|0;while(1){if((h|0)>=(b[f+238>>1]|0))break;d=c[f+196>>2]|0;if(!(a[d+(h<<6)+49>>0]|0)){e=oi(i,h)|0;d=c[j>>2]|0;f=c[d+196>>2]|0;c[f+(h<<6)+52>>2]=e;a[f+(h<<6)+49>>0]=1}else{e=c[d+(h<<6)+52>>2]|0;d=f}g=e+g|0;h=h+1|0;f=d}return g|0}function Yh(a){a=a|0;var d=0,e=0,f=0,g=0,i=0,j=0;a=c[a+16>>2]|0;g=b[a+238>>1]|0;i=a+196|0;a=b[a+236>>1]|0;while(1){if((a|0)>(g|0))break;f=c[i>>2]|0;e=c[f+(a<<6)>>2]|0;f=f+(a<<6)+4|0;d=0;while(1){if((d|0)>=(e|0))break;j=c[(c[(c[f>>2]|0)+(d<<2)>>2]|0)+16>>2]|0;h[j+16>>3]=+(c[j+236>>2]|0);d=d+1|0}a=a+1|0}return}function Zh(d,e){d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0;r=l;l=l+16|0;m=r;n=d+16|0;o=zA(c[(c[n>>2]|0)+232>>2]|0)|0;j=c[n>>2]|0;f=j+192|0;g=f;while(1){g=c[g>>2]|0;if(!g)break;g=c[g+16>>2]|0;a[g+157>>0]=0;g=g+164|0}h=b[j+238>>1]|0;i=j+196|0;g=b[j+236>>1]|0;while(1){if((g|0)>(h|0))break;c[(c[i>>2]|0)+(g<<6)>>2]=0;g=g+1|0}i=(e|0)==0;while(1){g=c[f>>2]|0;if(!g)break;h=g+16|0;f=c[h>>2]|0;if((c[c[(i?f+172|0:f+180|0)>>2]>>2]|0)==0?(k=f+157|0,(a[k>>0]|0)==0):0){a[k>>0]=1;BA(o,g);while(1){f=CA(o)|0;if(!f)break;if((a[(c[f+16>>2]|0)+159>>0]|0)==7){Xk(d,f,e,o);continue}else{mi(d,f);ni(o,f,e);continue}}f=c[h>>2]|0}f=f+164|0}if(CA(o)|0)_l(1,79159,m)|0;f=c[n>>2]|0;j=b[f+236>>1]|0;while(1){if((j|0)>(b[f+238>>1]|0))break;a[(c[(c[(c[41927]|0)+16>>2]|0)+196>>2]|0)+(j<<6)+49>>0]=0;if((c[f+116>>2]&1|0)!=0?(p=c[f+196>>2]|0,q=c[p+(j<<6)>>2]|0,(q|0)>0):0){g=c[p+(j<<6)+4>>2]|0;h=q+-1|0;i=(h|0)/2|0;f=0;while(1){if((f|0)>(i|0))break;gi(c[g+(f<<2)>>2]|0,c[g+(h-f<<2)>>2]|0);f=f+1|0}f=c[n>>2]|0}j=j+1|0}if((Vf(d)|0)==(d|0)?(Xh(0)|0)>0:0)ai(d,0);AA(o);l=r;return}function _h(d){d=d|0;var e=0,f=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;n=d+16|0;d=c[n>>2]|0;f=b[d+236>>1]|0;e=b[d+238>>1]|0;l=e<<16>>16;m=d+196|0;g=f;while(1){if((g|0)>(l|0))break;k=c[m>>2]|0;j=c[k+(g<<6)>>2]|0;k=k+(g<<6)+4|0;i=0;while(1){if((i|0)>=(j|0))break;o=c[(c[(c[k>>2]|0)+(i<<2)>>2]|0)+16>>2]|0;c[o+236>>2]=~~+h[o+16>>3];i=i+1|0}g=g+1|0}while(1){if((f|0)>(e<<16>>16|0))break;a[(c[(c[(c[41927]|0)+16>>2]|0)+196>>2]|0)+(f<<6)+49>>0]=0;o=c[d+196>>2]|0;rL(c[o+(f<<6)+4>>2]|0,c[o+(f<<6)>>2]|0,4,14);o=c[n>>2]|0;f=f+1|0;e=b[o+238>>1]|0;d=o}return}function $h(a,d){a=a|0;d=d|0;var e=0,f=0,g=0;g=((d|0)%4|0|0)<2&1;e=c[a+16>>2]|0;if(!(d&1)){d=b[e+236>>1]|0;f=1;e=b[e+238>>1]|0;d=(d<<16>>16<=(b[(c[(c[41927]|0)+16>>2]|0)+236>>1]|0)&1)+(d<<16>>16)|0}else{d=b[e+238>>1]|0;f=-1;e=b[e+236>>1]|0;d=((d<<16>>16>=(b[(c[(c[41927]|0)+16>>2]|0)+238>>1]|0))<<31>>31)+(d<<16>>16)|0}e=f+e|0;while(1){if((d|0)==(e|0))break;ji(a,d,g,(ii(a,d,d-f|0)|0)&255);d=d+f|0}ai(a,g^1);return}function ai(d,e){d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0;k=d+16|0;g=c[k>>2]|0;i=b[g+236>>1]|0;j=b[g+238>>1]|0;h=g+196|0;f=i<<16>>16;while(1){if((f|0)>(j|0)){h=i;break}a[(c[h>>2]|0)+(f<<6)+48>>0]=1;f=f+1|0}while(1){f=0;h=h<<16>>16;while(1){if((h|0)>(b[g+238>>1]|0))break;if(a[(c[g+196>>2]|0)+(h<<6)+48>>0]|0){f=(hi(d,h,e)|0)+f|0;g=c[k>>2]|0}h=h+1|0}if((f|0)<=0)break;h=b[g+236>>1]|0}return}function bi(d){d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;o=d+16|0;e=c[o>>2]|0;n=b[e+238>>1]|0;a:while(1){if((n|0)<(b[e+236>>1]|0)){e=16;break}f=c[e+196>>2]|0;a[f+(n<<6)+48>>0]=0;p=(n|0)>0;q=n+1|0;g=0;b:while(1){l=(c[f+(n<<6)>>2]|0)+-1|0;m=f+(n<<6)+4|0;k=f+(q<<6)|0;while(1){if((g|0)>=(l|0))break b;j=c[m>>2]|0;i=c[j+(g<<2)>>2]|0;g=g+1|0;j=c[j+(g<<2)>>2]|0;if((c[(c[i+16>>2]|0)+236>>2]|0)>=(c[(c[j+16>>2]|0)+236>>2]|0)){e=7;break a}if(ci(d,i,j)|0)continue;if(p){f=di(i,j)|0;h=di(j,i)|0}else{f=0;h=0}if((c[k>>2]|0)>0){f=(ei(i,j)|0)+f|0;h=(ei(j,i)|0)+h|0}if((h|0)<=(f|0))break}fi(d,n,i,j);e=c[o>>2]|0;f=c[e+196>>2]|0}n=n+-1|0}if((e|0)==7)ma(79110,78628,721,79136);else if((e|0)==16)return}function ci(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0;j=c[d+16>>2]|0;i=c[j+212>>2]|0;f=c[e+16>>2]|0;g=c[f+212>>2]|0;h=(i|0)!=(g|0);do if(!(a[173893]|0))if((g|0)==0|((i|0)==0|h^1))k=9;else{if((a[j+159>>0]|0)==7?(a[j+156>>0]|0)==1:0){b=0;break}if((a[f+159>>0]|0)==7?(a[f+156>>0]|0)==1:0){b=0;break}b=1}else if(h)b=1;else k=9;while(0);if((k|0)==9){f=c[b+16>>2]|0;b=c[(c[f+196>>2]|0)+(c[j+232>>2]<<6)+56>>2]|0;if(!b)b=0;else{j=(c[f+116>>2]&1|0)==0;k=O(c[b+4>>2]|0,c[(c[(j?d:e)+16>>2]|0)+284>>2]|0)|0;b=a[(c[b+8>>2]|0)+((c[(c[(j?e:d)+16>>2]|0)+284>>2]|0)+k)>>0]|0}}return b|0}function di(a,d){a=a|0;d=d|0;var e=0,f=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0;l=a+16|0;j=c[(c[d+16>>2]|0)+172>>2]|0;d=0;while(1){a=c[j>>2]|0;if(!a)break;i=c[a+16>>2]|0;k=b[i+154>>1]|0;g=c[(c[(c[((c[a>>2]&3|0)==3?a:a+48|0)+40>>2]|0)+16>>2]|0)+236>>2]|0;i=i+16|0;f=c[(c[l>>2]|0)+172>>2]|0;a=d;while(1){d=c[f>>2]|0;if(!d)break;e=(c[(c[(c[((c[d>>2]&3|0)==3?d:d+48|0)+40>>2]|0)+16>>2]|0)+236>>2]|0)-g|0;if((e|0)<=0){if((e|0)==0?(m=c[d+16>>2]|0,+h[m+16>>3]>+h[i>>3]):0){d=m;n=9}}else{d=c[d+16>>2]|0;n=9}if((n|0)==9){n=0;a=(O(b[d+154>>1]|0,k)|0)+a|0}f=f+4|0}j=j+4|0;d=a}return d|0}function ei(a,d){a=a|0;d=d|0;var e=0,f=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0;l=a+16|0;j=c[(c[d+16>>2]|0)+180>>2]|0;d=0;while(1){a=c[j>>2]|0;if(!a)break;i=c[a+16>>2]|0;k=b[i+154>>1]|0;g=c[(c[(c[((c[a>>2]&3|0)==2?a:a+-48|0)+40>>2]|0)+16>>2]|0)+236>>2]|0;i=i+56|0;f=c[(c[l>>2]|0)+180>>2]|0;a=d;while(1){d=c[f>>2]|0;if(!d)break;e=(c[(c[(c[((c[d>>2]&3|0)==2?d:d+-48|0)+40>>2]|0)+16>>2]|0)+236>>2]|0)-g|0;if((e|0)<=0){if((e|0)==0?(m=c[d+16>>2]|0,+h[m+56>>3]>+h[i>>3]):0){d=m;n=9}}else{d=c[d+16>>2]|0;n=9}if((n|0)==9){n=0;a=(O(b[d+154>>1]|0,k)|0)+a|0}f=f+4|0}j=j+4|0;d=a}return d|0}function fi(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;i=a[(c[e+16>>2]|0)+156>>0]|0;if(i<<24>>24!=(a[(c[f+16>>2]|0)+156>>0]|0)){j=b+16|0;l=c[(c[j>>2]|0)+196>>2]|0;k=c[l+(d<<6)>>2]|0;l=l+(d<<6)+4|0;b=0;g=0;h=0;while(1){if((b|0)>=(k|0))break;o=(a[(c[(c[(c[l>>2]|0)+(b<<2)>>2]|0)+16>>2]|0)+156>>0]|0)==0;b=b+1|0;g=g+(o&1)|0;h=h+((o^1)&1)|0}i=i<<24>>24==0;h=(g|0)<(h|0)?(i?e:f):i?f:e;i=0;b=0;while(1){if((b|0)>=(k|0))break;i=(c[(c[l>>2]|0)+(b<<2)>>2]|0)==(h|0)?b:i;b=b+1|0}o=(a[(c[h+16>>2]|0)+156>>0]|0)==0&1;n=0;g=i;while(1){b=g+-1|0;if((g|0)<=0){m=0;b=i;break}if((a[(c[(c[(c[l>>2]|0)+(b<<2)>>2]|0)+16>>2]|0)+156>>0]|0)!=(o|0)){m=0;b=i;break}n=n+1|0;g=b}while(1){b=b+1|0;if((b|0)>=(k|0))break;if((a[(c[(c[(c[l>>2]|0)+(b<<2)>>2]|0)+16>>2]|0)+156>>0]|0)!=(o|0))break;m=m+1|0}gi(e,f);j=c[(c[j>>2]|0)+196>>2]|0;k=c[j+(d<<6)>>2]|0;j=j+(d<<6)+4|0;b=0;while(1){if((b|0)>=(k|0)){h=0;g=i;break}i=(c[(c[j>>2]|0)+(b<<2)>>2]|0)==(h|0)?b:i;b=b+1|0}while(1){b=g+-1|0;if((g|0)<=0){g=0;b=i;break}if((a[(c[(c[(c[j>>2]|0)+(b<<2)>>2]|0)+16>>2]|0)+156>>0]|0)!=(o|0)){g=0;b=i;break}h=h+1|0;g=b}while(1){b=b+1|0;if((b|0)>=(k|0))break;if((a[(c[(c[(c[j>>2]|0)+(b<<2)>>2]|0)+16>>2]|0)+156>>0]|0)!=(o|0))break;g=g+1|0}d=h-g|0;o=n-m|0;if((((d|0)>-1?d:0-d|0)|0)>(((o|0)>-1?o:0-o|0)|0))gi(e,f)}return}function gi(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;f=c[a+16>>2]|0;e=c[f+232>>2]|0;f=f+236|0;d=c[f>>2]|0;g=b+16|0;h=c[(c[g>>2]|0)+236>>2]|0;c[f>>2]=h;f=(c[41927]|0)+16|0;c[(c[(c[(c[f>>2]|0)+196>>2]|0)+(e<<6)+4>>2]|0)+(h<<2)>>2]=a;c[(c[g>>2]|0)+236>>2]=d;c[(c[(c[(c[f>>2]|0)+196>>2]|0)+(e<<6)+4>>2]|0)+(d<<2)>>2]=b;return}function hi(d,e,f){d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;q=d+16|0;n=c[(c[q>>2]|0)+196>>2]|0;a[n+(e<<6)+48>>0]=0;r=(e|0)>0;s=e+1|0;o=(f|0)!=0;p=e+-1|0;g=0;i=0;f=n;a:while(1){l=(c[f+(e<<6)>>2]|0)+-1|0;m=f+(e<<6)+4|0;h=f+(s<<6)|0;n=g;while(1){if((n|0)>=(l|0)){f=17;break a}k=c[m>>2]|0;j=c[k+(n<<2)>>2]|0;n=n+1|0;k=c[k+(n<<2)>>2]|0;if((c[(c[j+16>>2]|0)+236>>2]|0)>=(c[(c[k+16>>2]|0)+236>>2]|0)){f=5;break a}if(ci(d,j,k)|0)continue;if(r){f=di(j,k)|0;g=di(k,j)|0}else{f=0;g=0}if((c[h>>2]|0)>0){f=(ei(j,k)|0)+f|0;g=(ei(k,j)|0)+g|0}if((f|0)>(g|0))break;if((f|0)==(g|0)&(o&(f|0)>0)){f=g;break}}gi(j,k);i=f-g+i|0;g=c[(c[(c[41927]|0)+16>>2]|0)+196>>2]|0;a[g+(e<<6)+49>>0]=0;h=c[q>>2]|0;f=c[h+196>>2]|0;a[f+(e<<6)+48>>0]=1;if((b[h+236>>1]|0)<(e|0)){a[g+(p<<6)+49>>0]=0;a[f+(p<<6)+48>>0]=1}if((b[h+238>>1]|0)<=(e|0)){g=n;continue}a[g+(s<<6)+49>>0]=0;a[f+(s<<6)+48>>0]=1;g=n}if((f|0)==5)ma(79110,78628,770,79144);else if((f|0)==17)return i|0;return 0}function ii(a,e,f){a=a|0;e=e|0;f=f|0;var g=0,i=0.0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;p=c[41925]|0;q=a+16|0;a=c[(c[q>>2]|0)+196>>2]|0;r=c[a+(e<<6)+4>>2]|0;n=(f|0)>(e|0);o=p+4|0;m=0;while(1){f=c[a+(e<<6)>>2]|0;if((m|0)>=(f|0)){a=0;j=0;break}l=(c[r+(m<<2)>>2]|0)+16|0;a=c[l>>2]|0;a:do if(n){k=c[a+180>>2]|0;a=0;j=0;while(1){f=c[k+(j<<2)>>2]|0;if(!f)break a;g=c[f+16>>2]|0;if((b[g+154>>1]|0)>0){c[p+(a<<2)>>2]=c[(c[(c[((c[f>>2]&3|0)==2?f:f+-48|0)+40>>2]|0)+16>>2]|0)+236>>2]<<8|d[g+88>>0];a=a+1|0}j=j+1|0}}else{k=c[a+172>>2]|0;j=0;a=0;while(1){f=c[k+(j<<2)>>2]|0;if(!f)break a;g=c[f+16>>2]|0;if((b[g+154>>1]|0)>0){c[p+(a<<2)>>2]=c[(c[(c[((c[f>>2]&3|0)==3?f:f+48|0)+40>>2]|0)+16>>2]|0)+236>>2]<<8|d[g+48>>0];a=a+1|0}j=j+1|0}}while(0);b:do switch(a|0){case 0:{i=-1.0;break}case 1:{i=+(c[p>>2]|0);break}case 2:{i=+(((c[o>>2]|0)+(c[p>>2]|0)|0)/2|0|0);break}default:{rL(p,a,4,12);f=(a|0)/2|0;if(a&1|0){i=+(c[p+(f<<2)>>2]|0);break b}j=c[p+(f<<2)>>2]|0;g=(c[p+(a+-1<<2)>>2]|0)-j|0;a=c[p+(f+-1<<2)>>2]|0;f=a-(c[p>>2]|0)|0;if((f|0)==(g|0)){i=+((a+j|0)/2|0|0);break b}else{i=+(((O(f,j)|0)+(O(a,g)|0)|0)/(f+g|0)|0|0);break b}}}while(0);h[(c[l>>2]|0)+240>>3]=i;m=m+1|0;a=c[(c[q>>2]|0)+196>>2]|0}while(1){if((j|0)>=(f|0))break;g=c[r+(j<<2)>>2]|0;p=c[g+16>>2]|0;if((c[p+184>>2]|0)==0?(c[p+176>>2]|0)==0:0){a=(ki(g)|0|a&255)&255;f=c[(c[(c[q>>2]|0)+196>>2]|0)+(e<<6)>>2]|0}j=j+1|0}return a|0}function ji(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,i=0,j=0,k=0,l=0,m=0.0,n=0,o=0,p=0,q=0,r=0,s=0;o=c[(c[b+16>>2]|0)+196>>2]|0;s=c[o+(d<<6)+4>>2]|0;o=c[o+(d<<6)>>2]|0;q=(e|0)!=0;p=(f|e|0)==0;f=0;e=o;o=s+(o<<2)|0;while(1){n=e+-1|0;if((e|0)>0)e=s;else break;a:while(1){b:while(1){if(e>>>0>=o>>>0)break a;while(1){if(e>>>0>=o>>>0)break a;l=c[e>>2]|0;m=+h[(c[l+16>>2]|0)+240>>3];if(!(m<0.0))break;e=e+4|0}k=0;while(1){g=k<<24>>24==0;while(1){e=e+4|0;if(e>>>0>=o>>>0)break a;if(g){g=11;break}i=c[e>>2]|0;if(!(c[(c[i+16>>2]|0)+212>>2]|0)){g=13;break}}if((g|0)==11){i=c[e>>2]|0;j=i}else if((g|0)==13)j=i;if(ci(b,l,j)|0)continue b;g=c[i+16>>2]|0;if(+h[g+240>>3]>=0.0)break;k=(c[g+212>>2]|0)==0?k:1}g=~~m;k=~~+h[(c[i+16>>2]|0)+240>>3];if((g|0)>(k|0)|q&(g|0)==(k|0))break}gi(l,j);f=f+1|0}e=n;o=p?o+-4|0:o}if(f|0?(r=c[(c[(c[41927]|0)+16>>2]|0)+196>>2]|0,a[r+(d<<6)+49>>0]=0,(d|0)>0):0)a[r+(d+-1<<6)+49>>0]=0;return}function ki(a){a=a|0;var b=0.0,d=0,e=0,f=0,g=0;g=c[a+16>>2]|0;if((c[g+200>>2]|0)>0){f=c[g+196>>2]|0;a=c[f>>2]|0;a=c[((c[a>>2]&3|0)==3?a:a+48|0)+40>>2]|0;d=1;while(1){e=c[f+(d<<2)>>2]|0;if(!e)break;e=c[((c[e>>2]&3|0)==3?e:e+48|0)+40>>2]|0;a=(c[(c[e+16>>2]|0)+236>>2]|0)>(c[(c[a+16>>2]|0)+236>>2]|0)?e:a;d=d+1|0}b=+h[(c[a+16>>2]|0)+240>>3];if(!(b>=0.0))a=1;else{h[g+240>>3]=b+1.0;a=0}}else if((c[g+192>>2]|0)>0){e=c[g+188>>2]|0;d=c[e>>2]|0;a=1;d=c[((c[d>>2]&3|0)==2?d:d+-48|0)+40>>2]|0;while(1){f=c[e+(a<<2)>>2]|0;if(!f)break;f=c[((c[f>>2]&3|0)==2?f:f+-48|0)+40>>2]|0;a=a+1|0;d=(c[(c[f+16>>2]|0)+236>>2]|0)<(c[(c[d+16>>2]|0)+236>>2]|0)?f:d}b=+h[(c[d+16>>2]|0)+240>>3];if(b>0.0){h[g+240>>3]=b+-1.0;a=0}else a=1}else a=1;return a|0}function li(a,b){a=a|0;b=b|0;return (c[(c[(c[a>>2]|0)+16>>2]|0)+236>>2]|0)-(c[(c[(c[b>>2]|0)+16>>2]|0)+236>>2]|0)|0}function mi(a,d){a=a|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0;p=l;l=l+96|0;o=p+64|0;n=p+48|0;h=p+24|0;f=p;j=d+16|0;k=c[(c[j>>2]|0)+232>>2]|0;m=a+16|0;e=c[(c[m>>2]|0)+196>>2]|0;i=c[e+(k<<6)>>2]|0;do if((c[e+(k<<6)+8>>2]|0)>=1){c[(c[e+(k<<6)+4>>2]|0)+(i<<2)>>2]=d;c[(c[j>>2]|0)+236>>2]=i;a=c[m>>2]|0;f=c[a+196>>2]|0;e=f+(k<<6)|0;g=c[e>>2]|0;c[e>>2]=g+1;if((g|0)>=(c[f+(k<<6)+8>>2]|0))ma(79224,78628,1346,79260);g=c[(c[(c[(c[41927]|0)+16>>2]|0)+196>>2]|0)+(k<<6)+8>>2]|0;if((i|0)>(g|0)){m=Dn(d)|0;n=c[(c[j>>2]|0)+236>>2]|0;o=c[(c[(c[(c[41927]|0)+16>>2]|0)+196>>2]|0)+(k<<6)+8>>2]|0;c[h>>2]=1359;c[h+4>>2]=m;c[h+8>>2]=n;c[h+12>>2]=k;c[h+16>>2]=o;_l(1,79276,h)|0;break}e=b[a+236>>1]|0;a=b[a+238>>1]|0;if((k|0)<(e|0)|(k|0)>(a<<16>>16|0)){c[n>>2]=1364;c[n+4>>2]=k;c[n+8>>2]=e;c[n+12>>2]=a<<16>>16;_l(1,79349,n)|0;break}if(((c[f+(k<<6)+4>>2]|0)+(i<<2)|0)>>>0>((c[f+(k<<6)+12>>2]|0)+(g<<2)|0)>>>0){i=Dn(d)|0;n=c[(c[m>>2]|0)+196>>2]|0;m=(c[n+(k<<6)+4>>2]|0)+(c[(c[j>>2]|0)+236>>2]<<2)|0;n=(c[n+(k<<6)+12>>2]|0)+(c[(c[(c[(c[41927]|0)+16>>2]|0)+196>>2]|0)+(k<<6)+8>>2]<<2)|0;c[o>>2]=1370;c[o+4>>2]=k;c[o+8>>2]=i;c[o+12>>2]=m;c[o+16>>2]=k;c[o+20>>2]=k;c[o+24>>2]=n;_l(1,79410,o)|0}}else{n=Dn(a)|0;o=Dn(d)|0;c[f>>2]=1339;c[f+4>>2]=n;c[f+8>>2]=o;c[f+12>>2]=k;c[f+16>>2]=i;_l(1,79169,f)|0}while(0);l=p;return}function ni(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;h=d+16|0;a:do if(!e){g=0;while(1){d=c[h>>2]|0;if((g|0)>=(c[d+184>>2]|0))break a;d=c[(c[d+180>>2]|0)+(g<<2)>>2]|0;e=d+-48|0;f=(c[(c[((c[d>>2]&3|0)==2?d:e)+40>>2]|0)+16>>2]|0)+157|0;if(!(a[f>>0]|0)){a[f>>0]=1;BA(b,c[((c[d>>2]&3|0)==2?d:e)+40>>2]|0)}g=g+1|0}}else{g=0;while(1){d=c[h>>2]|0;if((g|0)>=(c[d+176>>2]|0))break a;d=c[(c[d+172>>2]|0)+(g<<2)>>2]|0;e=d+48|0;f=(c[(c[((c[d>>2]&3|0)==3?d:e)+40>>2]|0)+16>>2]|0)+157|0;if(!(a[f>>0]|0)){a[f>>0]=1;BA(b,c[((c[d>>2]&3|0)==3?d:e)+40>>2]|0)}g=g+1|0}}while(0);return}function oi(d,e){d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;v=l;l=l+16|0;u=v;g=d+16|0;f=c[(c[g>>2]|0)+196>>2]|0;s=c[f+(e<<6)+4>>2]|0;t=e+1|0;d=c[(c[(c[(c[41927]|0)+16>>2]|0)+196>>2]|0)+(t<<6)>>2]|0;if((c[41931]|0)>(d|0))q=c[41932]|0;else{d=d+1|0;c[41931]=d;f=c[41932]|0;if(!f)d=ww(d<<2)|0;else d=yw(f,d<<2)|0;c[41932]=d;f=c[(c[g>>2]|0)+196>>2]|0;q=d}r=f+(t<<6)|0;d=0;while(1){if((d|0)>=(c[r>>2]|0))break;c[q+(d<<2)>>2]=0;d=d+1|0}p=f+(e<<6)|0;o=0;h=0;d=0;j=q;while(1){k=c[p>>2]|0;if((o|0)>=(k|0))break;n=c[(c[(c[s+(o<<2)>>2]|0)+16>>2]|0)+180>>2]|0;a:do if((h|0)>0){m=0;while(1){g=c[n+(m<<2)>>2]|0;if(!g)break a;k=g+16|0;i=c[(c[(c[((c[g>>2]&3|0)==2?g:g+-48|0)+40>>2]|0)+16>>2]|0)+236>>2]|0;while(1){g=i+1|0;if((i|0)>=(h|0))break;i=g;d=(O(c[j+(g<<2)>>2]|0,b[(c[k>>2]|0)+154>>1]|0)|0)+d|0}m=m+1|0}}while(0);i=0;while(1){g=c[n+(i<<2)>>2]|0;if(!g)break;j=c[(c[(c[((c[g>>2]&3|0)==2?g:g+-48|0)+40>>2]|0)+16>>2]|0)+236>>2]|0;m=q+(j<<2)|0;c[m>>2]=(c[m>>2]|0)+(b[(c[g+16>>2]|0)+154>>1]|0);h=(j|0)>(h|0)?j:h;i=i+1|0;j=q}o=o+1|0}i=f+(e<<6)+4|0;h=0;while(1){if((h|0)>=(k|0))break;g=c[(c[(c[i>>2]|0)+(h<<2)>>2]|0)+16>>2]|0;if(a[g+145>>0]|0){e=g+180|0;c[u>>2]=c[e>>2];c[u+4>>2]=c[e+4>>2];d=(pi(u,1)|0)+d|0}h=h+1|0}i=c[r>>2]|0;h=f+(t<<6)+4|0;g=0;while(1){if((g|0)>=(i|0))break;f=c[(c[(c[h>>2]|0)+(g<<2)>>2]|0)+16>>2]|0;if(a[f+145>>0]|0){t=f+172|0;c[u>>2]=c[t>>2];c[u+4>>2]=c[t+4>>2];d=(pi(u,-1)|0)+d|0}g=g+1|0}l=v;return d|0}function pi(a,d){a=a|0;d=d|0;var e=0,f=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0;n=(d|0)<1;l=c[a>>2]|0;d=0;a=0;a:while(1){m=c[l+(d<<2)>>2]|0;if(!m)break;d=d+1|0;if(n){j=m+48|0;k=m+16|0;i=d;while(1){e=c[l+(i<<2)>>2]|0;if(!e)continue a;f=c[e+16>>2]|0;g=c[k>>2]|0;if((+h[f+56>>3]-+h[g+56>>3])*+((c[(c[(c[((c[e>>2]&3|0)==3?e:e+48|0)+40>>2]|0)+16>>2]|0)+236>>2]|0)-(c[(c[(c[((c[m>>2]&3|0)==3?m:j)+40>>2]|0)+16>>2]|0)+236>>2]|0)|0)<0.0)a=(O(b[f+154>>1]|0,b[g+154>>1]|0)|0)+a|0;i=i+1|0}}else{j=m+-48|0;k=m+16|0;i=d;while(1){e=c[l+(i<<2)>>2]|0;if(!e)continue a;f=c[e+16>>2]|0;g=c[k>>2]|0;if((+h[f+16>>3]-+h[g+16>>3])*+((c[(c[(c[((c[e>>2]&3|0)==2?e:e+-48|0)+40>>2]|0)+16>>2]|0)+236>>2]|0)-(c[(c[(c[((c[m>>2]&3|0)==2?m:j)+40>>2]|0)+16>>2]|0)+236>>2]|0)|0)<0.0)a=(O(b[f+154>>1]|0,b[g+154>>1]|0)|0)+a|0;i=i+1|0}}}return a|0}function qi(a){a=a|0;var b=0.0,d=0.0;c[41930]=8;c[42180]=24;h[20878]=.995;a=Im(a,79532)|0;if(a|0?(b=+sM(a),b>0.0):0){d=b*+(c[41930]|0);c[41930]=~~(d>1.0?d:1.0);b=b*+(c[42180]|0);c[42180]=~~(b>1.0?b:1.0)}return}function ri(a){a=a|0;var d=0,e=0;e=(b[(c[a+16>>2]|0)+238>>1]|0)+2|0;d=vw(e<<2)|0;ti(a,d,e,0)|0;_I(d);return} +function Uq(b){b=b|0;var d=0,e=0,f=0,g=0,h=0;g=(b|0)==2;d=(c[42039]|0)+24|0;while(1){d=c[d>>2]|0;if(!d)break;e=d+4|0;f=c[e>>2]|0;if(!((g?(a[f>>0]|0)==(a[83089]|0):0)?!(xJ(f,83089)|0):0)){h=ym(c[c[42039]>>2]|0,b,f,0)|0;c[e>>2]=h;if(!h)c[e>>2]=ym(c[c[42039]>>2]|0,b,f,174181)|0;c[d>>2]=266;bp(c[42038]|0,f)|0}d=d+12|0}return}function Vq(a){a=a|0;Wq(c[a>>2]|0);c[a+4>>2]=0;c[a>>2]=0;return}function Wq(a){a=a|0;var b=0;while(1){if(!a)break;b=c[a+12>>2]|0;switch(c[a>>2]|0){case 265:{Wq(c[a+4>>2]|0);break}case 266:case 267:{bp(c[42038]|0,c[a+8>>2]|0)|0;break}default:{}}Zn(c[42038]|0,a);a=b}return}function Xq(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;h=l;l=l+1040|0;f=h;g=h+8|0;d=rJ(a)|0;d=d+2+(rJ(b)|0)|0;if(d>>>0<1025)e=g;else e=ZI(d)|0;c[f>>2]=a;c[f+4>>2]=b;pL(e,83126,f)|0;d=$o(c[42038]|0,e)|0;bp(c[42038]|0,a)|0;bp(c[42038]|0,b)|0;if((e|0)!=(g|0))_I(e);l=h;return d|0}function Yq(a,b){a=a|0;b=b|0;return Sq(259,a,b)|0}function Zq(a){a=a|0;return Sq(265,a,0)|0}function _q(a){a=a|0;return Sq(262,a,0)|0}function $q(a){a=a|0;var b=0,d=0;b=(c[42039]|0)+24|0;while(1){b=c[b>>2]|0;if(!b)break;if((c[b>>2]|0)==266?(d=c[b+4>>2]|0,d|0):0)Cm(a,d,c[b+8>>2]|0)|0;b=b+12|0}return}function ar(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=d+4|0;a:do if((c[d>>2]|0)==262){d=c[f>>2]|0;f=co(d)|0;while(1){if(!f)break a;br(a,b,io(c[c[42039]>>2]|0,f,0)|0,0,e);f=eo(d,f)|0}}else while(1){f=c[f>>2]|0;if(!f)break a;d=io(c[c[42039]>>2]|0,c[f+4>>2]|0,0)|0;br(a,b,d,c[f+8>>2]|0,e);f=f+12|0}while(0);return}function br(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0;d=an(c[c[42039]>>2]|0,a,d,f,1)|0;if(d|0){g=c[d>>2]&3;f=c[((g|0)==2?d:d+-48|0)+40>>2]|0;a=(f|0)==(a|0)?(c[((g|0)==3?d:d+48|0)+40>>2]|0)!=(f|0):0;cr(d,96242,a?e:b);cr(d,96251,a?b:e);$q(d)}return}function cr(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;if(d|0){e=ym(c[c[42039]>>2]|0,2,b,0)|0;if(!e)e=ym(c[c[42039]>>2]|0,2,b,174181)|0;Cm(a,e,d)|0}return}function dr(a,b,d){a=a|0;b=b|0;d=d|0;c[42007]=b;c[42038]=a;c[41987]=0;a=d|0?d:17656;c[42041]=a;gp(a,b);Bq()|0;a=c[41987]|0;if(!a){Fp();a=c[41987]|0}return a|0}function er(a,b){a=a|0;b=b|0;return dr(0,a,b)|0}function fr(a,b){a=a|0;b=b|0;b=Jr(a,1,b)|0;if(!b)b=999;else{b=c[b+16>>2]|0;c[a+184>>2]=c[b+4>>2];c[a+172>>2]=c[b+12>>2];c[a+176>>2]=c[b>>2];c[a+180>>2]=c[b+16>>2];b=300}return b|0}function gr(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;i=l;l=l+16|0;f=i;No(b,122277,280,1)|0;g=b+16|0;c[(c[g>>2]|0)+144>>2]=a;if((so(b)|0)!=(b|0))c[(c[(so(b)|0)+16>>2]|0)+144>>2]=a;e=Im(b,83342)|0;d=a+172|0;if((e|0)!=0?(c[d>>2]=0,(fr(a,e)|0)==999):0){d=Kr(a,1,e)|0;c[f>>2]=e;c[f+4>>2]=d;_l(1,83869,f)|0;d=-1}else{e=c[d>>2]|0;if(!e)d=-1;else{Fv(1);dw(b,c[c[a+180>>2]>>2]&1);d=c[(c[g>>2]|0)+8>>2]|0;c[(c[(so(b)|0)+16>>2]|0)+8>>2]=d;Ez();d=c[e>>2]|0;if(d|0?(gb[d&127](b),h=c[e+4>>2]|0,h|0):0)c[(c[g>>2]|0)+148>>2]=h;Fv(0);d=0}}l=i;return d|0}function hr(a,b){a=a|0;b=b|0;var d=0,e=0;if(No(b,122277,0,1)|0){d=b+16|0;a=c[d>>2]|0;e=c[a+148>>2]|0;if(e){gb[e&127](b);a=c[d>>2]|0;c[a+148>>2]=0}if(c[a+8>>2]|0)iw(b)}return 0}function ir(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;k=l;l=l+16|0;j=k+8|0;i=k;d=c[b+76>>2]|0;f=c[b>>2]|0;if((d|0)!=0?(e=c[d>>2]|0,(e|0)!=0):0){gb[e&127](b);g=12}else g=4;do if((g|0)==4)if((c[b+40>>2]|0)==0?(h=b+36|0,(c[h>>2]|0)==0):0){if(a[f+13>>0]|0)jr(b);d=b+32|0;e=c[d>>2]|0;if(!e){c[h>>2]=c[13885];g=12;break}f=aM(e,91556)|0;c[h>>2]=f;if(!f){j=c[(c[b+12>>2]|0)+16>>2]|0;h=c[d>>2]|0;d=yJ(c[(jJ()|0)>>2]|0)|0;c[i>>2]=h;c[i+4>>2]=d;hb[j&31](83132,i);d=1}else g=12}else g=12;while(0);if((g|0)==12)if(!(c[b+152>>2]&1024))d=0;else{hb[c[(c[b+12>>2]|0)+16>>2]&31](83170,j);d=1}l=k;return d|0}function jr(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;h=l;l=l+112|0;e=h;g=h+4|0;d=c[b+24>>2]|0;if(!d)a[g>>0]=0;else{c[e>>2]=d+1;pL(g,83188,e)|0}e=c[b+20>>2]|0;e=e|0?e:83192;d=rJ(e)|0;i=rJ(g)|0;f=b+52|0;i=d+1+i+(rJ(c[f>>2]|0)|0)|0;d=i+11|0;if((c[42042]|0)>>>0<(i+1|0)>>>0){c[42042]=d;d=aJ(c[42043]|0,d)|0;c[42043]=d}else d=c[42043]|0;xK(d,e)|0;IL(c[42043]|0,g)|0;d=c[42043]|0;d=d+(rJ(d)|0)|0;a[d>>0]=46;a[d+1>>0]=0;d=GL(c[f>>2]|0)|0;f=c[42043]|0;while(1){e=HL(d,58)|0;if(!e)break;IL(f,e+1|0)|0;i=c[42043]|0;g=i+(rJ(i)|0)|0;a[g>>0]=46;a[g+1>>0]=0;a[e>>0]=0;f=i}IL(f,d)|0;_I(d);c[b+32>>2]=c[42043];l=h;return}function kr(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0;h=l;l=l+16|0;g=h+8|0;f=h;if((b|0)!=0&(d|0)!=0){if(c[a+152>>2]&1024|0){hb[c[(c[a+12>>2]|0)+16>>2]&31](83170,f);Ma(1)}if((lr(a,b,d)|0)==(d|0))e=d;else{f=c[(c[a+12>>2]|0)+16>>2]|0;c[g>>2]=d;hb[f&31](83202,g);Ma(1)}}else e=0;l=h;return e|0}function lr(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0;o=l;l=l+16|0;n=o;f=c[(c[b>>2]|0)+104>>2]|0;do if(!f){j=b+40|0;h=c[j>>2]|0;if(!h){e=XL(d,1,e,c[b+36>>2]|0)|0;break}f=b+44|0;i=b+48|0;g=c[i>>2]|0;do if(((c[f>>2]|0)+-1-g|0)>>>0>>0){g=e+4096+g&-4096;c[f>>2]=g;f=aJ(h,g)|0;c[j>>2]=f;if(!f){hb[c[(c[b+12>>2]|0)+16>>2]&31](83227,n);Ma(1)}else{k=f;m=c[i>>2]|0;break}}else{k=h;m=g}while(0);TN(k+m|0,d|0,e|0)|0;n=(c[i>>2]|0)+e|0;c[i>>2]=n;a[(c[j>>2]|0)+n>>0]=0}else e=bb[f&31](b,d,e)|0;while(0);l=o;return e|0}function mr(a,b){a=a|0;b=b|0;var c=0;c=rJ(b)|0;b=(kr(a,b,c)|0)==(c|0);return (b?1:-1)|0}function nr(b,c){b=b|0;c=c|0;var d=0,e=0;d=l;l=l+16|0;e=d;a[e>>0]=c;b=(kr(b,e,1)|0)==1;l=d;return (b?c:-1)|0}function or(b){b=b|0;var d=0;d=c[b+36>>2]|0;if(((d|0)!=0?(a[b+144>>0]|0)==0:0)?(c[(c[b>>2]|0)+104>>2]|0)==0:0)b=PL(d)|0;else b=0;return b|0}function pr(a){a=a|0;var b=0,d=0;b=c[a+76>>2]|0;if(b|0?(d=c[b+4>>2]|0,d|0):0)gb[d&127](a);or(a)|0;return}function qr(a){a=a|0;var b=0,d=0,e=0;e=l;l=l+16|0;d=c[a+76>>2]|0;if(c[a+152>>2]&1024|0){hb[c[(c[a+12>>2]|0)+16>>2]&31](83254,e);Ma(1)}if((d|0)!=0?(b=c[d+8>>2]|0,(b|0)!=0):0)gb[b&127](a);else{or(a)|0;rr(a)}l=e;return}function rr(b){b=b|0;var d=0,e=0,f=0;d=b+32|0;if((c[d>>2]|0?(e=b+36|0,f=c[e>>2]|0,(f|0)!=(c[13885]|0)):0)?(a[b+144>>0]|0)==0:0){if(f|0){LL(f)|0;c[e>>2]=0}c[d>>2]=0}return}function sr(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;i=l;l=l+1056|0;f=i;h=i+24|0;g=i+8|0;c[g>>2]=d;e=LK(h,1024,b,g)|0;if((e|0)>=0){if((e|0)>1023){e=ww(e+1|0)|0;c[g>>2]=d;f=e;e=qL(e,b,g)|0}else f=h;kr(a,f,e)|0;if((f|0)!=(h|0))_I(f)}else{c[f>>2]=yJ(c[(jJ()|0)>>2]|0)|0;_l(1,83271,f)|0}l=i;return}function tr(a,b){a=a|0;b=+b;var d=0,e=0,f=0;d=l;l=l+16|0;e=d;f=ur(e,b)|0;kr(a,f,c[e>>2]|0)|0;l=d;return}function ur(b,d){b=b|0;d=+d;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;if(!(d<-1.0e15))if(!(d>1.0e15)){d=d*1.0e4;f=~~((d<0.0?-.5:.5)+d);if(!f){f=123205;e=1}else{l=(f|0)<0;k=4;i=0;e=173948;f=l?0-f|0:f;while(1){if(!((f|0)!=0|(k|0)>0))break;g=(f|0)%10|0;j=(f|0)/10|0;h=e+-1|0;if((g|0)==0&i<<24>>24==0)f=0;else{a[h>>0]=g|48;f=1;e=h}if((k|0)==1)if(!(f<<24>>24))f=1;else{e=e+-1|0;a[e>>0]=46;f=1}k=k+-1|0;i=f;f=j}if(l){e=e+-1|0;a[e>>0]=45}f=e;e=173948-e|0}}else{f=83286;e=18}else{f=83285;e=19}c[b>>2]=e;return f|0}function vr(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=l;l=l+16|0;e=d;f=ur(e,+h[b>>3])|0;kr(a,f,c[e>>2]|0)|0;kr(a,87638,1)|0;b=ur(e,+h[b+8>>3])|0;kr(a,b,c[e>>2]|0)|0;l=d;return}function wr(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0;g=l;l=l+16|0;f=g;e=0;while(1){h=b+(e<<4)|0;c[f>>2]=c[h>>2];c[f+4>>2]=c[h+4>>2];c[f+8>>2]=c[h+8>>2];c[f+12>>2]=c[h+12>>2];vr(a,f);e=e+1|0;if((e|0)>=(d|0))break;kr(a,87638,1)|0}l=g;return}function xr(a,b){a=a|0;b=b|0;var d=0;d=vw(392)|0;if(d|0){c[d>>2]=19212;c[d+16>>2]=22;c[d+32>>2]=a;c[d+36>>2]=b}return d|0}function yr(a){a=a|0;var b=0,d=0,e=0,f=0;b=vw(392)|0;d=b;e=a;f=d+40|0;do{c[d>>2]=c[e>>2];d=d+4|0;e=e+4|0}while((d|0)<(f|0));f=b+60|0;e=a+60|0;c[f>>2]=c[e>>2];c[f+4>>2]=c[e+4>>2];c[f+8>>2]=c[e+8>>2];c[f+12>>2]=c[e+12>>2];c[f+16>>2]=c[e+16>>2];f=b+80|0;e=a+80|0;c[f>>2]=c[e>>2];c[f+4>>2]=c[e+4>>2];c[f+8>>2]=c[e+8>>2];c[f+12>>2]=c[e+12>>2];c[f+16>>2]=c[e+16>>2];return b|0}function zr(a){a=a|0;Gr(a);_I(a);return}function Ar(a,b){a=a|0;b=b|0;var d=0,e=0;e=a+160|0;d=c[e>>2]|0;if(d){e=c[42044]|0;if(e){d=c[e+4>>2]|0;if(!d){d=vw(632)|0;c[(c[42044]|0)+4>>2]=d}}}else{d=vw(632)|0;c[e>>2]=d;c[a+164>>2]=d}c[42044]=d;c[d+32>>2]=b;c[d>>2]=a;return}function Br(a,b){a=a|0;b=b|0;var d=0,e=0;e=a+160|0;d=c[e>>2]|0;if(d){e=c[42045]|0;if(e){d=c[e+4>>2]|0;if(!d){d=vw(632)|0;c[(c[42045]|0)+4>>2]=d}}}else{d=vw(632)|0;c[e>>2]=d;c[a+164>>2]=d}c[42045]=d;c[d+52>>2]=b;c[d>>2]=a;return (Jr(a,3,b)|0)!=0|0}function Cr(a){a=a|0;var b=0;b=c[a+160>>2]|0;c[a+164>>2]=b;return b|0}function Dr(a){a=a|0;var b=0,d=0,e=0;a=a+164|0;b=c[a>>2]|0;d=c[b+4>>2]|0;if(d|0?(e=d+52|0,(c[e>>2]|0)==0):0)c[e>>2]=c[b+52>>2];c[a>>2]=d;return d|0}function Er(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=a+8|0;f=b+10|0;if((c[e>>2]|0)>(b|0))a=c[a>>2]|0;else{c[e>>2]=f;f=yw(c[a>>2]|0,f<<2)|0;c[a>>2]=f;a=f}c[a+(b<<2)>>2]=d;return}function Fr(a){a=a|0;var b=0;b=c[a>>2]|0;if(b|0)_I(b);c[a>>2]=0;c[a+8>>2]=0;c[a+4>>2]=0;return}function Gr(a){a=a|0;var b=0,d=0,e=0;d=a+160|0;b=c[d>>2]|0;while(1){if(!b)break;e=c[b+4>>2]|0;Fr(b+604|0);Fr(b+592|0);_I(c[b+584>>2]|0);_I(c[b+588>>2]|0);_I(b);b=e}c[42045]=0;c[42044]=0;c[a+192>>2]=0;c[a+164>>2]=0;c[d>>2]=0;c[a+28>>2]=0;return}function Hr(b,d,e,f,g,h){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0,j=0,k=0,m=0,n=0;n=l;l=l+128|0;k=n+64|0;m=n;mL(k,e,63)|0;i=WJ(k,58)|0;if(i|0)a[i>>0]=0;b=b+60+(d<<2)|0;while(1){d=c[b>>2]|0;if(!d){d=b;b=0;break}mL(m,c[d+4>>2]|0,63)|0;d=WJ(m,58)|0;if(d|0)a[d>>0]=0;if((xJ(k,m)|0)<1){j=9;break}b=c[b>>2]|0}while(1){if((j|0)==9){d=b;b=c[b>>2]|0}if(!b)break;mL(m,c[b+4>>2]|0,63)|0;b=WJ(m,58)|0;if(b|0)a[b>>0]=0;if(xJ(k,m)|0)break;b=c[d>>2]|0;if((c[b+8>>2]|0)<=(f|0))break;j=9}m=ww(20)|0;c[m>>2]=c[d>>2];c[d>>2]=m;c[m+4>>2]=e;c[m+8>>2]=f;c[m+12>>2]=g;c[m+16>>2]=h;l=n;return 1}function Ir(a,b){a=a|0;b=b|0;b=l;l=l+16|0;_l(1,83366,b)|0;l=b;return 0}function Jr(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;s=l;l=l+144|0;r=s;o=s+80|0;p=s+16|0;n=(d+-3|0)>>>0<2?0:d;mL(o,e,63)|0;e=WJ(o,58)|0;if(e){f=e+1|0;a[e>>0]=0;e=WJ(f,58)|0;if(!e)m=0;else{a[e>>0]=0;m=e+1|0}}else{m=0;f=0}i=(f|0)!=0;j=(m|0)==0;k=(n|0)==(d|0);h=b+60+(d<<2)|0;a:while(1){e=c[h>>2]|0;if(!e){e=0;break}mL(p,c[e+4>>2]|0,63)|0;e=WJ(p,58)|0;if(!e)e=0;else{a[e>>0]=0;e=e+1|0}do if(!(xJ(p,o)|0)){g=(e|0)!=0;if(i&g?xJ(e,f)|0:0)break;if(!j?xJ(m,c[(c[(c[h>>2]|0)+12>>2]|0)+8>>2]|0)|0:0)break;if(k|g^1){q=16;break a}if(Jr(b,n,e)|0){q=16;break a}}while(0);h=c[h>>2]|0}do if((q|0)==16){e=c[h>>2]|0;if(e){f=e+16|0;if((c[f>>2]|0)==0?(Ir(0,0)|0,(c[f>>2]|0)==0):0){e=0;break}if((c[b+8>>2]|0)>0){q=c[13918]|0;o=c[e+4>>2]|0;p=c[(c[e+12>>2]|0)+8>>2]|0;c[r>>2]=c[19224+(d<<2)>>2];c[r+4>>2]=o;c[r+8>>2]=p;zL(q,83397,r)|0}}else e=0}while(0);c[b+80+(d<<2)>>2]=e;l=s;return e|0}function Kr(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;do if(!e)e=0;else{if(c[4811]|0){cm(168184,0,0);c[4811]=0}h=GL(e)|0;e=WJ(h,58)|0;if(e){a[e>>0]=0;f=b+60+(d<<2)|0;e=1;g=f;while(1){b=c[g>>2]|0;if(!b)break;d=GL(c[b+4>>2]|0)|0;b=WJ(d,58)|0;if(b|0)a[b>>0]=0;if(!((a[h>>0]|0)!=0?(iK(h,d)|0)!=0:0)){e=c[42047]|0;if(e>>>0>=(c[42048]|0)>>>0){dm(168184,1)|0;e=c[42047]|0}c[42047]=e+1;a[e>>0]=32;fm(168184,c[(c[g>>2]|0)+4>>2]|0)|0;e=c[42047]|0;if(e>>>0>=(c[42048]|0)>>>0){dm(168184,1)|0;e=c[42047]|0}c[42047]=e+1;a[e>>0]=58;fm(168184,c[(c[(c[g>>2]|0)+12>>2]|0)+8>>2]|0)|0;e=0}_I(d);g=c[g>>2]|0}_I(h);if(e<<24>>24){g=0;i=19}}else{_I(h);g=0;f=b+60+(d<<2)|0;e=1;i=19}if((i|0)==19){while(1){b=c[f>>2]|0;if(!b)break;d=GL(c[b+4>>2]|0)|0;b=WJ(d,58)|0;if(b|0)a[b>>0]=0;if(!((g|0)!=0?(iK(g,d)|0)==0:0)){e=c[42047]|0;if(e>>>0>=(c[42048]|0)>>>0){dm(168184,1)|0;e=c[42047]|0}c[42047]=e+1;a[e>>0]=32;fm(168184,d)|0;e=0}g=d;f=c[f>>2]|0;i=19}if(e<<24>>24){e=174181;break}}e=c[42047]|0;if(e>>>0>=(c[42048]|0)>>>0){dm(168184,1)|0;e=c[42047]|0}a[e>>0]=0;e=c[42046]|0;c[42047]=e}while(0);return e|0}function Lr(b){b=b|0;var d=0;if(!b)ma(96030,83414,573,83428);if(!(a[b>>0]|0))ma(96035,83414,574,83428);d=c[42050]|0;if(!d)b=0;else b=bb[c[d>>2]&31](d,b,512)|0;return b|0}function Mr(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;k=l;l=l+16|0;j=k+8|0;i=k;if(!b)ma(96091,83414,589,83445);g=b+8|0;e=c[g>>2]|0;if(!e)ma(96094,83414,590,83445);if(!(a[e>>0]|0))ma(96103,83414,591,83445);h=b+20|0;f=c[h>>2]|0;do if(!f){d=RA(e)|0;if(!d){c[i>>2]=c[g>>2];_l(0,83469,i)|0;d=0;break}i=aM(d,123632)|0;c[h>>2]=i;if(!i){c[j>>2]=yJ(c[(jJ()|0)>>2]|0)|0;c[j+4>>2]=d;_l(0,83494,j)|0;d=0;break}d=c[42051]|0;if((d|0)>49){a[b+17>>0]=1;d=1;break}else{c[42051]=d+1;d=1;break}}else{oM(f,0,0)|0;if(!(c[h>>2]|0))ma(83515,83414,614,83445);else d=1}while(0);l=k;return d|0}function Nr(b){b=b|0;var d=0,e=0;if(a[b+17>>0]|0?(d=b+20|0,e=c[d>>2]|0,e|0):0){LL(e)|0;c[d>>2]=0}return}function Or(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0.0,g=0.0;if(!b){e=-1;d=-1}else{e=c[b+48>>2]|0;f=+(e|0);if(!e){g=+h[d>>3];f=+h[d+8>>3]}else{h[d+8>>3]=f;h[d>>3]=f;g=f}e=~~(+((c[b+40>>2]|0)*72|0)/g);d=~~(+((c[b+44>>2]|0)*72|0)/f)}c[a>>2]=e;c[a+4>>2]=d;return}function Pr(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0,m=0,n=0.0;m=l;l=l+48|0;f=m+16|0;j=m;k=m+32|0;if((e|0)!=0?(a[e>>0]|0)!=0:0){if((0==0?(g=c[42178]|0,(c[42052]|0)!=(g|0)):0)?(c[42052]=g,i=c[42050]|0,i|0):0){Kl(i)|0;c[42050]=0}n=+h[(c[(c[d+16>>2]|0)+8>>2]|0)+24>>3];n=!(n>=1.0)?96.0:n;h[j+8>>3]=n;h[j>>3]=n;d=Qr(e)|0;c[f>>2]=c[j>>2];c[f+4>>2]=c[j+4>>2];c[f+8>>2]=c[j+8>>2];c[f+12>>2]=c[j+12>>2];Or(k,d,f);d=c[k>>2]|0;f=c[k+4>>2]|0}else{d=-1;f=-1}c[b>>2]=d;c[b+4>>2]=f;l=m;return}function Qr(a){a=a|0;var b=0,d=0,e=0,f=0;f=l;l=l+16|0;e=f;if(!a)ma(96030,83414,638,83521);if(!(c[42050]|0))c[42050]=Ql(19248,c[4353]|0)|0;b=Lr(a)|0;a:do if(!b){b=vw(64)|0;if(!b)b=0;else{d=b+8|0;c[d>>2]=$o(0,a)|0;if(!((Mr(b)|0)<<24>>24)){Rr(b);b=0;break}if(!(c[b+20>>2]|0))ma(83515,83414,653,83521);do switch(Sr(b)|0){case 0:{a=Py(c[d>>2]|0)|0;c[b+52>>2]=a;if(!a){c[e>>2]=c[d>>2];_l(0,83538,e)|0;Rr(b);b=0;break a}break}case 2:{Tr(b);break}case 3:{Ur(b);break}case 1:{Vr(b);break}case 4:{Wr(b);break}case 6:{Xr(b);break}case 11:{Yr(b);break}case 8:{Zr(b);break}case 5:{_r(b);break}case 12:{$r(b);break}default:{}}while(0);Nr(b);e=c[42050]|0;bb[c[e>>2]&31](e,b,1)|0}}else Nr(b);while(0);l=f;return b|0}function Rr(a){a=a|0;var b=0;b=c[a+8>>2]|0;if(b|0)bp(0,b)|0;_I(a);return}function Sr(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;j=l;l=l+224|0;f=j+200|0;g=j;h=a+20|0;b=c[h>>2]|0;a:do if((b|0)!=0?(wN(f,1,20,b)|0)==20:0){d=0;while(1){if(d>>>0>=10){i=13;break a}if(!(dL(f,c[19284+(d<<4)>>2]|0,c[19284+(d<<4)+4>>2]|0)|0))break;d=d+1|0}e=a+28|0;c[e>>2]=c[19284+(d<<4)+12>>2];b=c[19284+(d<<4)+8>>2]|0;a=a+24|0;c[a>>2]=b;switch(d|0){case 7:break;case 8:{if(dL(f+8|0,83754,4)|0)break a;c[e>>2]=83759;c[a>>2]=11;b=11;break a}default:break a}while(1){if(!(gL(g,200,c[h>>2]|0)|0)){i=11;break}if(!(dL(g,83749,4)|0)){i=8;break}}if((i|0)==8){c[e>>2]=86879;c[a>>2]=8;b=8;break}else if((i|0)==11){b=c[a>>2]|0;break}}else i=13;while(0);if((i|0)==13){c[a+28>>2]=83764;c[a+24>>2]=0;b=0}l=j;return b|0}function Tr(a){a=a|0;var b=0,d=0,e=0,f=0;f=l;l=l+16|0;b=f+4|0;d=f;c[a+48>>2]=0;e=a+20|0;oM(c[e>>2]|0,6,0)|0;if((is(c[e>>2]|0,2,b)|0)<<24>>24?(is(c[e>>2]|0,2,d)|0)<<24>>24:0){c[a+40>>2]=c[b>>2];c[a+44>>2]=c[d>>2]}l=f;return}function Ur(a){a=a|0;var b=0,d=0,e=0,f=0;f=l;l=l+16|0;b=f+4|0;d=f;c[a+48>>2]=0;e=a+20|0;oM(c[e>>2]|0,16,0)|0;if((as(c[e>>2]|0,4,b)|0)<<24>>24?(as(c[e>>2]|0,4,d)|0)<<24>>24:0){c[a+40>>2]=c[b>>2];c[a+44>>2]=c[d>>2]}l=f;return}function Vr(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0;h=l;l=l+16|0;b=h+12|0;d=h+8|0;e=h+4|0;f=h;c[a+48>>2]=0;g=a+20|0;oM(c[g>>2]|0,16,0)|0;if((((is(c[g>>2]|0,2,b)|0)<<24>>24?(is(c[g>>2]|0,2,d)|0)<<24>>24:0)?(is(c[g>>2]|0,2,e)|0)<<24>>24:0)?(is(c[g>>2]|0,2,f)|0)<<24>>24:0){c[a+40>>2]=c[b>>2]<<16|c[d>>2];c[a+44>>2]=c[e>>2]<<16|c[f>>2]}l=h;return}function Wr(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0;m=l;l=l+32|0;b=m+16|0;e=m+12|0;f=m+8|0;h=m+4|0;i=m;c[a+48>>2]=0;j=a+20|0;while(1){if(!((as(c[j>>2]|0,1,b)|0)<<24>>24))break;d=c[b>>2]|0;if((d|0)==255)continue;if(WJ(83737,d)|0)continue;if((d|0)==192){k=6;break}g=c[j>>2]|0;if((d|0)==194){k=11;break}if(!((as(g,2,e)|0)<<24>>24))break;oM(c[j>>2]|0,(c[e>>2]|0)+-2|0,1)|0}if((k|0)==6){if(((as(c[j>>2]|0,3,i)|0)<<24>>24?(as(c[j>>2]|0,2,f)|0)<<24>>24:0)?(as(c[j>>2]|0,2,h)|0)<<24>>24:0){c[a+44>>2]=c[f>>2];c[a+40>>2]=c[h>>2]}}else if((((k|0)==11?(as(g,3,i)|0)<<24>>24:0)?(as(c[j>>2]|0,2,f)|0)<<24>>24:0)?(as(c[j>>2]|0,2,h)|0)<<24>>24:0){c[a+44>>2]=c[f>>2];c[a+40>>2]=c[h>>2]}l=m;return}function Xr(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0;m=l;l=l+1056|0;j=m;b=m+32|0;e=m+28|0;f=m+24|0;g=m+20|0;h=m+16|0;c[a+48>>2]=72;i=a+20|0;oM(c[i>>2]|0,0,0)|0;while(1){if(!(gL(b,1024,c[i>>2]|0)|0))break;d=hL(b,83722)|0;if(!d)continue;c[j>>2]=e;c[j+4>>2]=f;c[j+8>>2]=g;c[j+12>>2]=h;if((cM(d,89345,j)|0)==4){k=5;break}}if((k|0)==5){j=c[e>>2]|0;c[a+32>>2]=j;k=c[f>>2]|0;c[a+36>>2]=k;c[a+40>>2]=(c[g>>2]|0)-j;c[a+44>>2]=(c[h>>2]|0)-k}l=m;return}function Yr(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0;g=l;l=l+16|0;b=g+4|0;d=g;c[a+48>>2]=0;e=a+20|0;oM(c[e>>2]|0,15,0)|0;h=(BN(c[e>>2]|0)|0)==88;f=c[e>>2]|0;if(h){oM(f,24,0)|0;if((is(c[e>>2]|0,4,b)|0)<<24>>24?(is(c[e>>2]|0,4,d)|0)<<24>>24:0){c[a+40>>2]=c[b>>2];c[a+44>>2]=c[d>>2]}}else{oM(f,26,0)|0;if((is(c[e>>2]|0,2,b)|0)<<24>>24?(is(c[e>>2]|0,2,d)|0)<<24>>24:0){c[a+40>>2]=c[b>>2];c[a+44>>2]=c[d>>2]}}l=g;return}function Zr(b){b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;F=l;l=l+352|0;C=F+80|0;B=F+72|0;E=F+64|0;D=F+56|0;A=F+48|0;d=F+40|0;s=F+32|0;t=F+24|0;u=F+16|0;v=F+8|0;w=F;x=F+328|0;y=F+128|0;z=F+96|0;if(!(c[42053]|0)){if(EM(168216,83607,1)|0){c[d>>2]=83607;_l(1,83634,d)|0}c[42053]=168216}m=b+20|0;oM(c[m>>2]|0,0,0)|0;n=z+12|0;o=z+20|0;p=z+8|0;q=z+16|0;r=z+4|0;d=0;g=0;f=0;e=0;a:while(1){if(!(gL(y,200,c[m>>2]|0)|0))break;if(g<<24>>24==0|d<<24>>24==0){i=y;k=e}else break;b:while(1){j=f;c:while(1){while(1){if(qN(168216,i,4,z,0)|0){f=j;e=k;continue a}a[i+(c[n>>2]|0)>>0]=0;a[i+(c[o>>2]|0)>>0]=0;e=i+(c[p>>2]|0)|0;f=i+(c[q>>2]|0)|0;i=i+((c[r>>2]|0)+1)|0;if(!(xJ(e,96043)|0))break;if(!(xJ(e,96049)|0))break c;if(xJ(e,83681)|0)continue;c[C>>2]=t;c[C+4>>2]=u;c[C+8>>2]=v;c[C+12>>2]=w;if((cM(f,83689,C)|0)==4)break b}c[A>>2]=s;c[A+4>>2]=x;if((cM(f,83671,A)|0)!=2){c[D>>2]=s;if((cM(f,86246,D)|0)==1){e=1;f=hs(+h[s>>3],83678)|0}else{e=g;f=j}}else{e=1;f=hs(+h[s>>3],x)|0}if(!(d<<24>>24)){d=0;g=e;j=f}else{g=e;e=k;continue a}}c[E>>2]=s;c[E+4>>2]=x;if((cM(f,83671,E)|0)!=2){c[B>>2]=s;if((cM(f,86246,B)|0)==1){d=1;e=hs(+h[s>>3],83678)|0}else e=k}else{d=1;e=hs(+h[s>>3],x)|0}if(!(g<<24>>24)){g=0;f=j;k=e}else{f=j;continue a}}d=1;g=1;f=~~(+h[v>>3]+1.0-+h[t>>3])>>>0;e=~~(+h[w>>3]+1.0-+h[u>>3])>>>0}c[b+48>>2]=0;c[b+40>>2]=f;c[b+44>>2]=e;l=F;return}function _r(a){a=a|0;var b=0,d=0,e=0,f=0.0,g=0.0;d=l;l=l+32|0;b=d;c[a+48>>2]=0;e=a+20|0;oM(c[e>>2]|0,0,0)|0;if(!(bs(c[e>>2]|0,b)|0)){g=+h[b>>3];c[a+32>>2]=~~g;f=+h[b+8>>3];c[a+36>>2]=~~f;c[a+40>>2]=~~(+h[b+16>>3]-g);c[a+44>>2]=~~(+h[b+24>>3]-f)}l=d;return}function $r(a){a=a|0;var b=0,d=0,e=0,f=0;f=l;l=l+16|0;b=f+4|0;d=f;c[a+48>>2]=0;e=a+20|0;oM(c[e>>2]|0,6,0)|0;if((as(c[e>>2]|0,1,b)|0)<<24>>24?(as(c[e>>2]|0,1,d)|0)<<24>>24:0){c[a+40>>2]=c[b>>2];c[a+44>>2]=c[d>>2]}l=f;return}function as(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;c[d>>2]=0;e=0;while(1){if(e>>>0>=b>>>0){e=1;break}f=BN(a)|0;if(KL(a)|0){e=0;break}c[d>>2]=c[d>>2]<<8|f;e=e+1|0}return e|0}function bs(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;h=l;l=l+1040|0;d=h;e=h+16|0;while(1){if(!(gL(e,1024,a)|0)){a=1;break}f=hL(e,83597)|0;if(f|0){g=4;break}}if((g|0)==4){c[d+4>>2]=e;c[d>>2]=f+9;c[d+8>>2]=a;a=cs(d,b)|0}l=h;return a|0}function cs(b,d){b=b|0;d=d|0;var e=0,f=0,g=0;g=l;l=l+1024|0;f=g;ds(b);e=a[c[b>>2]>>0]|0;if(!(e<<24>>24))e=(es(b)|0)&255;else e=e<<24>>24;if((((e|0)==91?(c[b>>2]=(c[b>>2]|0)+1,fs(b,f),(gs(f,d)|0)==0):0)?(fs(b,f),(gs(f,d+8|0)|0)==0):0)?(fs(b,f),(gs(f,d+16|0)|0)==0):0){fs(b,f);e=(gs(f,d+24|0)|0)!=0&1}else e=1;l=g;return e|0}function ds(b){b=b|0;var d=0;d=c[b>>2]|0;while(1){d=a[d>>0]|0;if(!(d<<24>>24))d=(es(b)|0)&255;else d=d<<24>>24;if(!((d&255)<<24>>24))break;if(!(XJ(d&255)|0))break;d=(c[b>>2]|0)+1|0;c[b>>2]=d}return}function es(b){b=b|0;var d=0;d=b+4|0;if(!(gL(c[d>>2]|0,1024,c[b+8>>2]|0)|0))b=0;else{d=c[d>>2]|0;c[b>>2]=d;b=a[d>>0]|0}return b|0}function fs(b,d){b=b|0;d=d|0;var e=0,f=0,g=0;ds(b);e=0;f=c[b>>2]|0;while(1){f=a[f>>0]|0;if(!(f<<24>>24))g=(es(b)|0)&255;else g=f<<24>>24;f=g<<24>>24;if(!f)break;if(!((f|0)==46|(f+-48|0)>>>0<10))break;a[d+e>>0]=g;e=e+1|0;f=(c[b>>2]|0)+1|0;c[b>>2]=f;if((e|0)==1023){e=1023;break}}a[d+e>>0]=0;return}function gs(a,b){a=a|0;b=b|0;var d=0.0,e=0,f=0;e=l;l=l+16|0;f=e;d=+tM(a,f);if((c[f>>2]|0)==(a|0))a=1;else{h[b>>3]=d;a=0}l=e;return a|0}function hs(a,b){a=+a;b=b|0;var c=0.0;do if(!(xJ(b,83705)|0)){a=a*72.0;c=a;a=a>=0.0?.5:-.5}else{if(!(xJ(b,83708)|0)){a=a*.75;c=a;a=a>=0.0?.5:-.5;break}if(!(xJ(b,83711)|0)){a=a*12.0;c=a;a=a>=0.0?.5:-.5;break}if(xJ(b,83678)|0?xJ(b,83714)|0:0)if(!(xJ(b,83716)|0)){a=a*28.346456664;c=a;a=a>=0.0?.5:-.5;break}else{b=(xJ(b,83719)|0)==0;c=a*2.8346456663999997;return (b?~~(c+(c>=0.0?.5:-.5)):0)|0}c=a>=0.0?.5:-.5}while(0);return ~~(a+c)|0}function is(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;c[d>>2]=0;e=0;while(1){if(e>>>0>=b>>>0){e=1;break}f=BN(a)|0;if(KL(a)|0){e=0;break}c[d>>2]=c[d>>2]|f<<(e<<3);e=e+1|0}return e|0}function js(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;a=c[b+20>>2]|0;if(a|0)LL(a)|0;if(c[b+52>>2]|0?(e=c[b+60>>2]|0,e|0):0)gb[e&127](b);_I(b);return}function ks(){var a=0;ym(0,1,86240,90527)|0;a=xr(0,1)|0;sE(a,0);return a|0}function ls(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0,m=0.0,n=0.0,o=0.0,p=0.0;k=l;l=l+304|0;j=k+24|0;i=k+8|0;f=k;g=k+40|0;if((fr(b,e)|0)!=999)if((gr(b,d)|0)==-1)b=-1;else{b=c[d+16>>2]|0;e=b+16|0;if(!(a[(c[b+8>>2]|0)+81>>0]|0)){p=+h[e>>3];o=+h[b+24>>3];n=+h[b+32>>3];m=+h[b+40>>3];c[j>>2]=~~(p+(p>=0.0?.5:-.5));c[j+4>>2]=~~(o+(o>=0.0?.5:-.5));c[j+8>>2]=~~(n+(n>=0.0?.5:-.5));c[j+12>>2]=~~(m+(m>=0.0?.5:-.5));pL(g,83918,j)|0}else{m=+h[b+24>>3];n=+h[e>>3];o=+h[b+40>>3];p=+h[b+32>>3];c[i>>2]=~~(m+(m>=0.0?.5:-.5));c[i+4>>2]=~~(n+(n>=0.0?.5:-.5));c[i+8>>2]=~~(o+(o>=0.0?.5:-.5));c[i+12>>2]=~~(p+(p>=0.0?.5:-.5));pL(g,83918,i)|0}Lm(d,87705,g,174181)|0;b=0}else{b=Kr(b,1,e)|0;c[f>>2]=e;c[f+4>>2]=b;_l(1,83869,f)|0;b=-1}l=k;return b|0}function ms(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;i=l;l=l+16|0;g=i;f=c[b+60>>2]|0;Br(a,d)|0;b=c[a+164>>2]|0;c[b+56>>2]=bD(b,c[b+52>>2]|0)|0;if((No(f,122277,0,1)|0)!=0?(c[(c[f+16>>2]|0)+8>>2]|0)!=0:0)h=5;else if(!(c[b+152>>2]&67108864)){bm(83930,g);b=-1}else h=5;if((h|0)==5){c[b+36>>2]=e;if(!e){h=b+152|0;c[h>>2]=c[h>>2]|134217728}h=Gv(a,f)|0;dD(b);Gr(a);b=h}l=i;return b|0}function ns(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;i=l;l=l+16|0;g=i;f=c[b+60>>2]|0;Br(a,d)|0;b=c[a+164>>2]|0;c[b+56>>2]=bD(b,c[b+52>>2]|0)|0;if((No(f,122277,0,1)|0)!=0?(c[(c[f+16>>2]|0)+8>>2]|0)!=0:0)h=5;else if(!(c[b+152>>2]&67108864)){bm(83930,g);b=-1}else h=5;if((h|0)==5){Ar(a,e);h=Gv(a,f)|0;dD(b);qr(b);Gr(a);b=h}l=i;return b|0}function os(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,m=0;m=l;l=l+16|0;h=m+8|0;g=m;b=c[b+60>>2]|0;Br(a,d)|0;j=c[a+164>>2]|0;c[j+56>>2]=bD(j,c[j+52>>2]|0)|0;if((No(b,122277,0,1)|0)!=0?(c[(c[b+16>>2]|0)+8>>2]|0)!=0:0)k=5;else if(!(c[j+152>>2]&67108864)){bm(83930,g);b=-1}else k=5;do if((k|0)==5){if(e|0?(i=ZI(4096)|0,c[e>>2]=i,i|0):0){g=j+40|0;c[g>>2]=i;c[j+44>>2]=4096;d=j+48|0;c[d>>2]=0;b=Gv(a,b)|0;dD(j);if(!b){c[e>>2]=c[g>>2];c[f>>2]=c[d>>2]}Gr(a);break}_l(1,83951,h)|0;b=-1}while(0);l=m;return b|0}function ps(a,b){a=a|0;b=b|0;qE(a,0,b);return}function qs(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;if(!((a|0)!=0?(ys(a)|0)!=0:0))a=84007;e=rJ(a)|0;if((e|0)>=104){d=ww(e+25|0)|0;if(!d)d=0;else f=6}else f=6;if((f|0)==6){xK(d,a)|0;c[b>>2]=e}return d|0}function rs(a,b){a=a|0;b=b|0;io(b,a,1)|0;return}function ss(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;c[b>>2]=d;c[b+4>>2]=d+4096;c[b+12>>2]=0;c[b+8>>2]=0;c[a>>2]=b;c[a+4>>2]=b;c[a+8>>2]=d;c[a+12>>2]=e;c[a+16>>2]=f;return}function ts(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0;ws(e,b);i=e+12|0;j=e+16|0;b=0;a:while(1){k=xs(e)|0;if(!k)break;b=b+1|0;f=c[i>>2]|0;if(f|0)hb[f&31](k,d);h=Um(a,k)|0;while(1){if(!h)continue a;g=c[h>>2]&3;f=c[((g|0)==3?h:h+48|0)+40>>2]|0;if((f|0)==(k|0))f=c[((g|0)==2?h:h+-48|0)+40>>2]|0;if(!(ab[c[j>>2]&63](f,-1)|0))ws(e,f);h=Vm(a,h,k)|0}}return b|0}function us(a){a=a|0;var b=0;a=c[(c[a>>2]|0)+12>>2]|0;while(1){if(!a)break;b=c[a+12>>2]|0;vs(a);a=b}return}function vs(a){a=a|0;_I(c[a>>2]|0);_I(a);return}function ws(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;k=l;l=l+16|0;j=k+8|0;f=k;g=a+8|0;i=a+4|0;d=c[i>>2]|0;if((c[g>>2]|0)==(c[d+4>>2]|0)){d=c[d+12>>2]|0;do if(!d){e=ww(16)|0;if(!e){_l(1,83988,f)|0;Ua(168248,1)}c[e+8>>2]=c[i>>2];c[e+12>>2]=0;d=ww(4e6)|0;c[e>>2]=d;if(!d){_l(1,83988,j)|0;Ua(168248,1)}else{c[e+4>>2]=d+4e6;c[(c[i>>2]|0)+12>>2]=e;h=e;break}}else h=d;while(0);c[i>>2]=h;c[g>>2]=c[h>>2]}ab[c[a+16>>2]&63](b,1)|0;j=c[g>>2]|0;c[g>>2]=j+4;c[j>>2]=b;l=k;return}function xs(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;f=a+8|0;b=c[f>>2]|0;d=a+4|0;e=c[d>>2]|0;if((b|0)==(c[e>>2]|0))if((e|0)==(c[a>>2]|0))b=0;else{b=c[e+8>>2]|0;c[d>>2]=b;b=c[b+4>>2]|0;c[f>>2]=b;g=4}else g=4;if((g|0)==4){b=b+-4|0;c[f>>2]=b;b=c[b>>2]|0}return b|0}function ys(b){b=b|0;var c=0;a:while(1){c=b;b=b+1|0;c=a[c>>0]|0;switch(c<<24>>24){case 95:continue a;case 0:{b=1;break a}default:{}}if(!(gK(c&255)|0)){b=0;break}}return b|0}function zs(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=0;f=co(a)|0;while(1){if(!f)break;e=Pm(b,f)|0;while(1){if(!e)break;if(io(a,c[((c[e>>2]&3|0)==2?e:e+-48|0)+40>>2]|0,0)|0){en(a,e,1)|0;d=d+1|0}e=Rm(b,e)|0}f=eo(a,f)|0}return d|0}function As(a){a=a|0;a=Lo(a,84012,0)|0;if(!a)ma(84017,84020,529,84029);else return c[a+8>>2]|0;return 0}function Bs(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;u=l;l=l+4320|0;s=u+24|0;r=u+8|0;q=u;t=u+4184|0;p=u+4160|0;f=u+40|0;if(mn(b)|0){So(b,0,84038,-12,0);So(b,1,84050,16,0);o=qs(e,f,t)|0;k=Cs(b)|0;m=ww((mn(k)|0)<<2)|0;ss(p,u+4144|0,u+48|0,23,22);h=co(k)|0;n=p+16|0;i=o+(c[f>>2]|0)|0;j=c[13918]|0;e=0;while(1){if(!h)break;if(!(ab[c[n>>2]&63](h,-1)|0)){c[q>>2]=e;pL(i,84952,q)|0;v=Ip(k,o,1)|0;w=Ip(b,o,1)|0;No(w,84038,12,0)|0;a[(Lo(w,84038,0)|0)+8>>0]=1;f=ts(k,h,v,p)|0;Es(v,w);g=Fs(w)|0;Gs(b,w);c[m+(e<<2)>>2]=w;qo(k,v)|0;if(0){c[r>>2]=e;c[r+4>>2]=f;c[r+8>>2]=g;zL(j,84062,r)|0}e=e+1|0}h=eo(k,h)|0}if(0){r=mn(b)|0;v=nn(b)|0;w=Dn(b)|0;c[s>>2]=r;c[s+4>>2]=v;c[s+8>>2]=e;c[s+12>>2]=w;zL(j,84092,s)|0}ln(k)|0;To(b,0,84038);To(b,1,84050);us(p);f=yw(m,e<<2)|0;if((o|0)!=(t|0))_I(o)}else{f=0;e=0}c[d>>2]=e;l=u;return f|0}function Cs(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;i=l;l=l+16|0;h=i;a[h>>0]=a[17652]|0;a[h+1>>0]=a[17653]|0;a[h+2>>0]=a[17654]|0;a[h+3>>0]=a[17655]|0;h=gn(84139,h,0)|0;Js(h,b);d=co(b)|0;while(1){if(!d)break;if(!(c[(Lo(d,84050,0)|0)+12>>2]|0)){g=no(h,Dn(d)|0,1)|0;No(g,84050,16,1)|0;c[(c[g+16>>2]|0)+12>>2]=d;c[(Lo(d,84050,0)|0)+12>>2]=g}d=eo(b,d)|0}e=co(b)|0;while(1){if(!e)break;f=c[(Lo(e,84050,0)|0)+12>>2]|0;d=Pm(b,e)|0;while(1){if(!d)break;g=c[(Lo(c[((c[d>>2]&3|0)==2?d:d+-48|0)+40>>2]|0,84050,0)|0)+12>>2]|0;do if((g|0)!=(f|0))if(g>>>0>f>>>0){an(h,f,g,0,1)|0;break}else{an(h,g,f,0,1)|0;break}while(0);d=Rm(b,d)|0}e=eo(b,e)|0}l=i;return h|0}function Ds(b,d){b=b|0;d=d|0;var e=0;b=(c[b+16>>2]|0)+8|0;e=a[b>>0]|0;if((d|0)>=0)a[b>>0]=d;return e|0}function Es(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;e=co(a)|0;while(1){if(!e)break;f=c[(c[e+16>>2]|0)+12>>2]|0;a:do if((c[f>>2]&3|0)==1)io(b,f,1)|0;else{d=co(f)|0;while(1){if(!d)break a;io(b,d,1)|0;d=eo(f,d)|0}}while(0);e=eo(a,e)|0}return}function Fs(a){a=a|0;return zs(a,c[a+60>>2]|0)|0}function Gs(a,b){a=a|0;b=b|0;Hs(a,b,0);return}function Hs(b,c,d){b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0;g=(d|0)==0;b=Jp(b)|0;while(1){if(!b)break;if((a[(Lo(b,84038,0)|0)+8>>0]|0)==0?(f=Is(b,c,d)|0,f|0):0){if(g)e=(VJ(Dn(b)|0,93039,7)|0)==0;else e=1;Hs(b,f,e&1)}b=Kp(b)|0}return}function Is(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;e=0;g=co(a)|0;while(1){if(!g)break;f=no(b,Dn(g)|0,0)|0;if(f){if(!e)e=Ip(b,Dn(a)|0,1)|0;io(e,f,1)|0}g=eo(a,g)|0}if((d|0)!=0&(e|0)==0)e=Ip(b,Dn(a)|0,1)|0;if(e|0?(zs(e,a)|0,Mm(a,e)|0,(VJ(Dn(e)|0,93039,7)|0)==0):0)c[(No(e,84012,12,0)|0)+8>>2]=a;return e|0}function Js(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;h=l;l=l+16|0;g=h;d=Jp(b)|0;e=c[13918]|0;while(1){if(!d)break;a:do if(!(VJ(Dn(d)|0,93039,7)|0)){f=no(a,Dn(d)|0,1)|0;No(f,84050,16,1)|0;c[(c[f+16>>2]|0)+12>>2]=d;b=co(d)|0;while(1){if(!b)break a;if(c[(Lo(b,84050,0)|0)+12>>2]|0){k=Dn(b)|0;j=Dn(d)|0;i=Dn(c[(Lo(b,84050,0)|0)+12>>2]|0)|0;c[g>>2]=k;c[g+4>>2]=j;c[g+8>>2]=i;zL(e,84142,g)|0}c[(Lo(b,84050,0)|0)+12>>2]=f;b=eo(d,b)|0}}else Js(a,d);while(0);d=Kp(d)|0}l=h;return}function Ks(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0.0;n=+h[a>>3];j=~~(n+(n>=0.0?.5:-.5));n=+h[a+8>>3];a=~~(n+(n>=0.0?.5:-.5));n=+h[b>>3];g=~~(n+(n>=0.0?.5:-.5));n=+h[b+8>>3];f=~~(n+(n>=0.0?.5:-.5));l=g-j|0;i=((l|0)>-1?l:0-l|0)<<1;l=l>>31|1;m=f-a|0;k=((m|0)>-1?m:0-m|0)<<1;m=m>>31|1;a:do if((i|0)>(k|0)){e=0-i|0;d=k-(i>>1)|0;b=j;while(1){Cx(c,b,a);if((b|0)==(g|0))break a;j=(d|0)>-1;d=d+k+(j?e:0)|0;b=b+l|0;a=(j?m:0)+a|0}}else{e=0-k|0;d=j;b=i-(k>>1)|0;while(1){Cx(c,d,a);if((a|0)==(f|0))break a;k=(b|0)>-1;d=(k?l:0)+d|0;b=b+i+(k?e:0)|0;a=a+m|0}}while(0);return}function Ls(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0;n=l;l=l+16|0;k=n;j=n+4|0;do if((a|0)<1)d=0;else{f=e+16|0;if((c[f>>2]|0)>>>0<4){d=Ms(a,b,d,e)|0;break}m=ww(a<<5)|0;d=0;while(1){if((d|0)==(a|0))break;g=c[b+(d<<2)>>2]|0;dB(g);h=m+(d<<5)|0;g=(c[g+16>>2]|0)+16|0;c[h>>2]=c[g>>2];c[h+4>>2]=c[g+4>>2];c[h+8>>2]=c[g+8>>2];c[h+12>>2]=c[g+12>>2];c[h+16>>2]=c[g+16>>2];c[h+20>>2]=c[g+20>>2];c[h+24>>2]=c[g+24>>2];c[h+28>>2]=c[g+28>>2];d=d+1|0}if((c[f>>2]|0)==4){h=e+28|0;a:do if(c[h>>2]&2|0){f=e+24|0;c[f>>2]=vw(a<<2)|0;d=0;while(1){if((d|0)==(a|0))break a;g=Im(c[b+(d<<2)>>2]|0,84209)|0;if(g|0?(c[k>>2]=j,g=(cM(g,122187,k)|0)>0,i=c[j>>2]|0,g&(i|0)>-1):0)c[(c[f>>2]|0)+(d<<2)>>2]=i;d=d+1|0}}while(0);d=Ns(a,m,e)|0;if(c[h>>2]&2)_I(c[e+24>>2]|0)}else d=0;_I(m)}while(0);l=n;return d|0}function Ms(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0.0,I=0.0,J=0.0,K=0.0;G=l;l=l+144|0;B=G+136|0;A=G+64|0;F=G+48|0;v=G+40|0;u=G;t=G+120|0;x=G+104|0;C=G+96|0;D=c[f+20>>2]|0;c[x>>2]=0;c[x+4>>2]=0;c[x+8>>2]=0;c[x+12>>2]=0;a:do if((b|0)>=1){o=(D|0)==0;E=c[13918]|0;p=t+4|0;q=t+8|0;r=t+12|0;y=x+4|0;w=x+8|0;z=x+12|0;n=0;g=0;while(1){if((n|0)==(b|0))break;s=c[d+(n<<2)>>2]|0;dB(s);if(!o?(a[D+n>>0]|0)!=0:0){m=c[s+16>>2]|0;H=+h[m+16>>3];i=~~(H+(H>=0.0?.5:-.5));c[t>>2]=i;H=+h[m+24>>3];j=~~(H+(H>=0.0?.5:-.5));c[p>>2]=j;H=+h[m+32>>3];k=~~(H+(H>=0.0?.5:-.5));c[q>>2]=k;H=+h[m+40>>3];m=~~(H+(H>=0.0?.5:-.5));c[r>>2]=m;if(!g){c[x>>2]=c[t>>2];c[x+4>>2]=c[t+4>>2];c[x+8>>2]=c[t+8>>2];c[x+12>>2]=c[t+12>>2]}else{c[x>>2]=c[((c[x>>2]|0)>(i|0)?t:x)>>2];c[y>>2]=c[((c[y>>2]|0)>(j|0)?t:x)+4>>2];c[w>>2]=c[((c[w>>2]|0)<(k|0)?t:x)+8>>2];c[z>>2]=c[((c[z>>2]|0)<(m|0)?t:x)+12>>2]}g=g+1|0}if(0>2){m=Dn(s)|0;s=c[s+16>>2]|0;K=+h[s+16>>3];J=+h[s+24>>3];I=+h[s+32>>3];H=+h[s+40>>3];c[u>>2]=m;h[u+8>>3]=K;h[u+16>>3]=J;h[u+24>>3]=I;h[u+32>>3]=H;zL(E,84276,u)|0}n=n+1|0}q=ww(b<<5)|0;g=0;while(1){if((g|0)==(b|0))break;u=q+(g<<5)|0;t=(c[(c[d+(g<<2)>>2]|0)+16>>2]|0)+16|0;c[u>>2]=c[t>>2];c[u+4>>2]=c[t+4>>2];c[u+8>>2]=c[t+8>>2];c[u+12>>2]=c[t+12>>2];c[u+16>>2]=c[t+16>>2];c[u+20>>2]=c[t+20>>2];c[u+24>>2]=c[t+24>>2];c[u+28>>2]=c[t+28>>2];g=g+1|0}o=f+8|0;p=Qs(b,q,c[o>>2]|0)|0;if(0){c[v>>2]=p;zL(E,84304,v)|0}if((p|0)>=1){n=(D|0)!=0;if(n){i=((c[w>>2]|0)+(c[x>>2]|0)|0)/2|0;g=((c[z>>2]|0)+(c[y>>2]|0)|0)/2|0}else{i=0;g=0}c[C+4>>2]=g;c[C>>2]=i;m=vw(b<<4)|0;k=f+16|0;g=0;while(1){if((g|0)>=(b|0))break;i=c[d+(g<<2)>>2]|0;j=m+(g<<4)|0;c[m+(g<<4)+12>>2]=g;if((c[k>>2]|0)==3){x=(c[i+16>>2]|0)+16|0;y=c[o>>2]|0;z=Dn(i)|0;c[A>>2]=c[x>>2];c[A+4>>2]=c[x+4>>2];c[A+8>>2]=c[x+8>>2];c[A+12>>2]=c[x+12>>2];c[A+16>>2]=c[x+16>>2];c[A+20>>2]=c[x+20>>2];c[A+24>>2]=c[x+24>>2];c[A+28>>2]=c[x+28>>2];c[B>>2]=c[C>>2];c[B+4>>2]=c[C+4>>2];Rs(A,j,p,y,B,z)}else{c[B>>2]=c[C>>2];c[B+4>>2]=c[C+4>>2];Ss(e,i,j,p,f,B)}g=g+1|0}j=vw(b<<2)|0;g=0;while(1){if((g|0)>=(b|0))break;c[j+(g<<2)>>2]=m+(g<<4);g=g+1|0}rL(j,b,4,23);k=wx()|0;g=vw(b<<3)|0;b:do if(n){i=0;while(1){if((i|0)>=(b|0)){i=0;break}if(a[D+i>>0]|0){e=c[j+(i<<2)>>2]|0;f=g+(c[e+12>>2]<<3)|0;c[B>>2]=c[C>>2];c[B+4>>2]=c[C+4>>2];Us(e,k,f,B)}i=i+1|0}while(1){if((i|0)>=(b|0))break b;if(!(a[D+i>>0]|0)){C=c[j+(i<<2)>>2]|0;Vs(i,C,k,g+(c[C+12>>2]<<3)|0,p,c[o>>2]|0,q)}i=i+1|0}}else{i=0;while(1){if((i|0)>=(b|0))break b;D=c[j+(i<<2)>>2]|0;Vs(i,D,k,g+(c[D+12>>2]<<3)|0,p,c[o>>2]|0,q);i=i+1|0}}while(0);_I(j);i=0;while(1){if((i|0)>=(b|0))break;_I(c[m+(i<<4)+4>>2]|0);i=i+1|0}_I(m);zx(k);_I(q);if(0>1){i=0;while(1){if((i|0)>=(b|0))break a;C=c[g+(i<<3)>>2]|0;D=c[g+(i<<3)+4>>2]|0;c[F>>2]=i;c[F+4>>2]=C;c[F+8>>2]=D;zL(E,84320,F)|0;i=i+1|0}}}else g=0}else g=0;while(0);l=G;return g|0}function Ns(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,i=0.0,j=0,k=0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;z=l;l=l+16|0;g=z;x=vw(a<<3)|0;f=c[d+4>>2]|0;y=d+28|0;e=(f|0)>0;do if(!(c[y>>2]&1))if(e){k=1;w=(a+-1+f|0)/(f|0)|0;break}else{f=~~+N(+(+C(+(+(a|0)))));k=1;w=(a+-1+f|0)/(f|0)|0;break}else if(e){k=0;w=f;f=(a+-1+f|0)/(f|0)|0;break}else{f=~~+N(+(+C(+(+(a|0)))));k=0;w=f;f=(a+-1+f|0)/(f|0)|0;break}while(0);if(0){v=c[13918]|0;c[g>>2]=k|0?84215:84225;c[g+4>>2]=w;c[g+8>>2]=f;zL(v,84238,g)|0}t=vw((f<<3)+8|0)|0;u=vw((w<<3)+8|0)|0;v=vw(a*24|0)|0;j=d+8|0;e=0;g=v;while(1){if((e|0)>=(a|0))break;p=+h[b+(e<<5)+8>>3];o=+h[b+(e<<5)+24>>3];q=+((c[j>>2]|0)>>>0);h[g>>3]=+h[b+(e<<5)+16>>3]-+h[b+(e<<5)>>3]+q;h[g+8>>3]=o-p+q;c[g+16>>2]=e;e=e+1|0;g=g+24|0}s=vw(a<<2)|0;e=0;while(1){if((e|0)>=(a|0))break;c[s+(e<<2)>>2]=v+(e*24|0);e=e+1|0}e=c[d+24>>2]|0;if(!e){if(!(c[y>>2]&64))rL(s,a,4,25)}else{c[42101]=e;rL(s,a,4,24)}r=(k|0)==0;e=0;g=0;j=0;while(1){if((j|0)>=(a|0)){i=0.0;e=0;break}k=c[s+(j<<2)>>2]|0;d=t+(g<<3)|0;q=+h[d>>3];p=+h[k>>3];h[d>>3]=q>p?q:p;d=u+(e<<3)|0;p=+h[d>>3];q=+h[k+8>>3];h[d>>3]=p>q?p:q;if(r){e=e+1|0;d=(e|0)==(w|0);e=d?0:e;g=g+(d&1)|0}else{g=g+1|0;d=(g|0)==(f|0);e=e+(d&1)|0;g=d?0:g}j=j+1|0}while(1){if((e|0)>(f|0)){i=0.0;e=w;break}d=t+(e<<3)|0;q=+h[d>>3];h[d>>3]=i;i=q+i;e=e+1|0}while(1){if((e|0)<=0)break;d=e+-1|0;q=+h[u+(d<<3)>>3];h[u+(e<<3)>>3]=i;i=q+i;e=d}h[u>>3]=i;e=0;g=0;d=0;while(1){if((d|0)>=(a|0))break;k=c[(c[s+(d<<2)>>2]|0)+16>>2]|0;i=+h[b+(k<<5)>>3];m=-i;p=+h[b+(k<<5)+8>>3];q=-p;n=+h[b+(k<<5)+16>>3];o=+h[b+(k<<5)+24>>3];j=c[y>>2]|0;do if(!(j&4))if(!(j&8)){i=(m-n+ +h[t+(g<<3)>>3]+ +h[t+(g+1<<3)>>3])*.5;break}else{i=i-n+ +h[t+(g+1<<3)>>3];break}else i=+h[t+(g<<3)>>3];while(0);c[x+(k<<3)>>2]=~~i;do if(!(j&16))if(!(j&32)){i=(q-o+ +h[u+(e<<3)>>3]+ +h[u+(e+1<<3)>>3])*.5;break}else{i=+h[u+(e+1<<3)>>3];break}else i=p-o+ +h[u+(e<<3)>>3];while(0);c[x+(k<<3)+4>>2]=~~i;if(r){e=e+1|0;k=(e|0)==(w|0);e=k?0:e;g=g+(k&1)|0}else{g=g+1|0;k=(g|0)==(f|0);e=e+(k&1)|0;g=k?0:g}d=d+1|0}_I(v);_I(s);_I(t);_I(u);l=z;return x|0}function Os(a,b){a=a|0;b=b|0;var d=0;d=c[42101]|0;a=c[d+(c[(c[a>>2]|0)+16>>2]<<2)>>2]|0;b=c[d+(c[(c[b>>2]|0)+16>>2]<<2)>>2]|0;return ((a|0)>(b|0)?1:((a|0)<(b|0))<<31>>31)|0}function Ps(a,b){a=a|0;b=b|0;var d=0.0,e=0.0;a=c[a>>2]|0;b=c[b>>2]|0;e=+h[a>>3]+ +h[a+8>>3];d=+h[b>>3]+ +h[b+8>>3];return (ed)<<31>>31)|0}function Qs(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0,g=0.0,i=0.0,j=0.0,k=0,m=0,n=0.0,o=0.0,p=0,q=0,r=0,s=0;s=l;l=l+96|0;q=s+80|0;r=s+48|0;p=s+8|0;m=s;k=(a*100|0)+-1|0;e=+(d<<1|0);n=0.0;o=0.0;d=0;while(1){if((d|0)>=(a|0))break;j=+h[b+(d<<5)+16>>3]-+h[b+(d<<5)>>3]+e;i=+h[b+(d<<5)+24>>3]-+h[b+(d<<5)+8>>3]+e;n=n-j-i;o=o-i*j;d=d+1|0}i=+(k|0);j=n*n-i*4.0*o;if(!(j<0.0)){e=+C(+j);g=i*2.0;f=(e-n)/g;g=(-n-e)/g;d=~~f;d=(d|0)==0?1:d;if(0>2){m=c[13918]|0;XL(84463,27,1,m)|0;h[p>>3]=i;h[p+8>>3]=n;h[p+16>>3]=o;h[p+24>>3]=j;h[p+32>>3]=e;zL(m,84491,p)|0;c[r>>2]=d;h[r+8>>3]=f;c[r+16>>2]=~~g;h[r+24>>3]=g;zL(m,84517,r)|0;h[q>>3]=(f*i+n)*f+o;h[q+8>>3]=(g*i+n)*g+o;zL(m,84539,q)|0}}else{h[m>>3]=j;_l(1,84436,m)|0;d=-1}l=s;return d|0}function Rs(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var i=0,j=0,k=0,m=0,n=0.0,o=0.0,p=0.0,q=0.0,r=0,s=0,t=0,u=0,v=0.0,w=0.0;u=l;l=l+32|0;t=u+16|0;s=u;p=+h[a>>3];q=+h[a+8>>3];n=+h[a+16>>3];o=+h[a+24>>3];r=wx()|0;j=c[f>>2]|0;a=j-e|0;k=c[f+4>>2]|0;i=k-e|0;j=e-~~(p+(p>=0.0?.5:-.5))+j+~~(n+(n>=0.0?.5:-.5))|0;k=e-~~(q+(q>=0.0?.5:-.5))+k+~~(o+(o>=0.0?.5:-.5))|0;if((a|0)>-1)f=(a|0)/(d|0)|0;else f=((a+1|0)/(d|0)|0)+-1|0;if((i|0)>-1)m=(i|0)/(d|0)|0;else m=((i+1|0)/(d|0)|0)+-1|0;if((j|0)>-1)j=(j|0)/(d|0)|0;else j=((j+1|0)/(d|0)|0)+-1|0;if((k|0)>-1)i=(k|0)/(d|0)|0;else i=((k+1|0)/(d|0)|0)+-1|0;while(1){if((f|0)>(j|0))break;else a=m;while(1){if((a|0)>(i|0))break;Cx(r,f,a);a=a+1|0}f=f+1|0}k=b+4|0;c[k>>2]=Gx(r)|0;j=Fx(r)|0;m=b+8|0;c[m>>2]=j;w=+(e<<1|0);v=+(d|0);i=~~+N(+((n+w-p)/v));a=~~+N(+((o+w-q)/v));c[b>>2]=a+i;a:do if(0>2){f=c[13918]|0;c[s>>2]=g;c[s+4>>2]=j;c[s+8>>2]=i;c[s+12>>2]=a;zL(f,84395,s)|0;a=0;while(1){if((a|0)>=(c[m>>2]|0))break a;g=c[k>>2]|0;s=c[g+(a<<3)+4>>2]|0;c[t>>2]=c[g+(a<<3)>>2];c[t+4>>2]=s;zL(f,84422,t)|0;a=a+1|0}}while(0);zx(r);l=u;return}function Ss(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0.0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,O=0,P=0,Q=0.0,R=0.0;P=l;l=l+128|0;F=P+112|0;E=P+104|0;O=P+16|0;M=P;H=P+64|0;I=P+56|0;z=P+40|0;A=P+96|0;y=P+88|0;v=P+24|0;w=P+80|0;x=P+72|0;K=c[f+8>>2]|0;G=c[f+12>>2]|0;C=(a|0)==0?b:a;L=wx()|0;J=b+16|0;B=c[J>>2]|0;t=+h[B+16>>3];D=(c[g>>2]|0)-~~(t+(t>=0.0?.5:-.5))|0;t=+h[B+24>>3];B=(c[g+4>>2]|0)-~~(t+(t>=0.0?.5:-.5))|0;a:do if((c[f+16>>2]|0)==1){v=ww((mn(b)|0)<<2)|0;a=0;g=co(b)|0;while(1){if(!g)break;x=g+16|0;c[v+(a<<2)>>2]=c[(c[x>>2]|0)+112>>2];c[(c[x>>2]|0)+112>>2]=0;a=a+1|0;g=eo(b,g)|0}o=D-K|0;p=B-K|0;q=D+K|0;r=B+K|0;n=1;while(1){a=c[J>>2]|0;if((n|0)>(c[a+180>>2]|0))break;m=c[(c[a+184>>2]|0)+(n<<2)>>2]|0;i=c[m+16>>2]|0;t=+h[i+16>>3];a=~~(t+(t>=0.0?.5:-.5));t=+h[i+24>>3];g=~~(t+(t>=0.0?.5:-.5));t=+h[i+32>>3];f=~~(t+(t>=0.0?.5:-.5));t=+h[i+40>>3];i=~~(t+(t>=0.0?.5:-.5));b:do if((f|0)>(a|0)&(i|0)>(g|0)){a=o+a|0;j=p+g|0;f=q+f|0;k=r+i|0;if((a|0)>-1)g=(a|0)/(e|0)|0;else g=((a+1|0)/(e|0)|0)+-1|0;if((j|0)>-1)j=(j|0)/(e|0)|0;else j=((j+1|0)/(e|0)|0)+-1|0;if((f|0)>-1)i=(f|0)/(e|0)|0;else i=((f+1|0)/(e|0)|0)+-1|0;if((k|0)>-1)f=(k|0)/(e|0)|0;else f=((k+1|0)/(e|0)|0)+-1|0;while(1){if((g|0)>(i|0))break;else a=j;while(1){if((a|0)>(f|0))break;Cx(L,g,a);a=a+1|0}g=g+1|0}a=co(m)|0;while(1){if(!a)break b;c[(c[a+16>>2]|0)+212>>2]=m;a=eo(m,a)|0}}while(0);n=n+1|0}r=z+8|0;s=H+4|0;t=+(K|0);u=I+4|0;q=A+4|0;p=y+4|0;o=co(b)|0;while(1){if(!o)break;OA(z,o);R=+h[z>>3];Q=+h[r>>3];m=D+~~(R+(R>=0.0?.5:-.5))|0;c[H>>2]=m;n=B+~~(Q+(Q>=0.0?.5:-.5))|0;c[s>>2]=n;g=o+16|0;a=c[g>>2]|0;c:do if(!(c[a+212>>2]|0)){c[I>>2]=~~((+h[a+96>>3]+ +h[a+88>>3])*.5+t);c[u>>2]=~~(+h[a+80>>3]*.5+t);c[E>>2]=c[H>>2];c[E+4>>2]=c[H+4>>2];c[F>>2]=c[I>>2];c[F+4>>2]=c[I+4>>2];Xs(A,E,F);a=c[A>>2]|0;f=c[q>>2]|0;c[E>>2]=c[H>>2];c[E+4>>2]=c[H+4>>2];c[F>>2]=c[I>>2];c[F+4>>2]=c[I+4>>2];Ys(y,E,F);i=c[y>>2]|0;j=c[p>>2]|0;if((a|0)>-1)g=(a|0)/(e|0)|0;else g=((a+1|0)/(e|0)|0)+-1|0;if((f|0)>-1)k=(f|0)/(e|0)|0;else k=((f+1|0)/(e|0)|0)+-1|0;if((i|0)>-1)i=(i|0)/(e|0)|0;else i=((i+1|0)/(e|0)|0)+-1|0;if((j|0)>-1)f=(j|0)/(e|0)|0;else f=((j+1|0)/(e|0)|0)+-1|0;while(1){if((g|0)>(i|0))break;else a=k;while(1){if((a|0)>(f|0))break;Cx(L,g,a);a=a+1|0}g=g+1|0}if((m|0)>-1)a=(m|0)/(e|0)|0;else a=((m+1|0)/(e|0)|0)+-1|0;c[H>>2]=a;if((n|0)>-1)a=(n|0)/(e|0)|0;else a=((n+1|0)/(e|0)|0)+-1|0;c[s>>2]=a;a=Pm(C,o)|0;while(1){if(!a)break c;c[F>>2]=c[H>>2];c[F+4>>2]=c[H+4>>2];Zs(a,F,L,D,B,e,G);a=Rm(C,a)|0}}else{if((m|0)>-1)a=(m|0)/(e|0)|0;else a=((m+1|0)/(e|0)|0)+-1|0;c[H>>2]=a;if((n|0)>-1)a=(n|0)/(e|0)|0;else a=((n+1|0)/(e|0)|0)+-1|0;c[s>>2]=a;a=Pm(C,o)|0;while(1){if(!a)break c;if((c[(c[g>>2]|0)+212>>2]|0)!=(c[(c[(c[((c[a>>2]&3|0)==2?a:a+-48|0)+40>>2]|0)+16>>2]|0)+212>>2]|0)){c[F>>2]=c[H>>2];c[F+4>>2]=c[H+4>>2];Zs(a,F,L,D,B,e,G)}a=Rm(C,a)|0}}while(0);o=eo(b,o)|0}a=0;g=co(b)|0;while(1){if(!g)break;c[(c[g+16>>2]|0)+112>>2]=c[v+(a<<2)>>2];a=a+1|0;g=eo(b,g)|0}_I(v)}else{r=v+8|0;s=H+4|0;t=+(K|0);u=I+4|0;q=w+4|0;p=x+4|0;o=co(b)|0;while(1){if(!o)break a;OA(v,o);Q=+h[v>>3];R=+h[r>>3];m=D+~~(Q+(Q>=0.0?.5:-.5))|0;c[H>>2]=m;n=B+~~(R+(R>=0.0?.5:-.5))|0;c[s>>2]=n;a=c[o+16>>2]|0;c[I>>2]=~~((+h[a+96>>3]+ +h[a+88>>3])*.5+t);c[u>>2]=~~(+h[a+80>>3]*.5+t);c[E>>2]=c[H>>2];c[E+4>>2]=c[H+4>>2];c[F>>2]=c[I>>2];c[F+4>>2]=c[I+4>>2];Xs(w,E,F);a=c[w>>2]|0;f=c[q>>2]|0;c[E>>2]=c[H>>2];c[E+4>>2]=c[H+4>>2];c[F>>2]=c[I>>2];c[F+4>>2]=c[I+4>>2];Ys(x,E,F);i=c[x>>2]|0;j=c[p>>2]|0;if((a|0)>-1)g=(a|0)/(e|0)|0;else g=((a+1|0)/(e|0)|0)+-1|0;if((f|0)>-1)k=(f|0)/(e|0)|0;else k=((f+1|0)/(e|0)|0)+-1|0;if((i|0)>-1)i=(i|0)/(e|0)|0;else i=((i+1|0)/(e|0)|0)+-1|0;if((j|0)>-1)f=(j|0)/(e|0)|0;else f=((j+1|0)/(e|0)|0)+-1|0;while(1){if((g|0)>(i|0))break;else a=k;while(1){if((a|0)>(f|0))break;Cx(L,g,a);a=a+1|0}g=g+1|0}if((m|0)>-1)a=(m|0)/(e|0)|0;else a=((m+1|0)/(e|0)|0)+-1|0;c[H>>2]=a;if((n|0)>-1)a=(n|0)/(e|0)|0;else a=((n+1|0)/(e|0)|0)+-1|0;c[s>>2]=a;a=Pm(C,o)|0;while(1){if(!a)break;c[F>>2]=c[H>>2];c[F+4>>2]=c[H+4>>2];Zs(a,F,L,D,B,e,G);a=Rm(C,a)|0}o=eo(b,o)|0}}while(0);i=d+4|0;c[i>>2]=Gx(L)|0;j=d+8|0;c[j>>2]=Fx(L)|0;g=c[J>>2]|0;Q=+(K<<1|0);R=+(e|0);a=~~+N(+((+h[g+32>>3]+Q-+h[g+16>>3])/R));g=~~+N(+((+h[g+40>>3]+Q-+h[g+24>>3])/R));c[d>>2]=g+a;d:do if(0>2){f=c[13918]|0;d=Dn(b)|0;b=c[j>>2]|0;c[M>>2]=d;c[M+4>>2]=b;c[M+8>>2]=a;c[M+12>>2]=g;zL(f,84395,M)|0;a=0;while(1){if((a|0)>=(c[j>>2]|0))break d;b=c[i>>2]|0;M=c[b+(a<<3)+4>>2]|0;c[O>>2]=c[b+(a<<3)>>2];c[O+4>>2]=M;zL(f,84422,O)|0;a=a+1|0}}while(0);zx(L);l=P;return}function Ts(a,b){a=a|0;b=b|0;return (c[c[b>>2]>>2]|0)-(c[c[a>>2]>>2]|0)|0}function Us(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0;j=l;l=l+32|0;h=j+16|0;i=j;k=c[a+4>>2]|0;g=c[a+8>>2]|0;c[d>>2]=0-(c[e>>2]|0);f=d+4|0;c[f>>2]=0-(c[e+4>>2]|0);a=0;e=k;while(1){if((a|0)>=(g|0))break;c[h>>2]=c[e>>2];c[h+4>>2]=c[e+4>>2];Ax(b,h);a=a+1|0;e=e+8|0}if(0>1){k=c[13918]|0;b=c[d>>2]|0;d=c[f>>2]|0;c[i>>2]=g;c[i+4>>2]=b;c[i+8>>2]=d;zL(k,84369,i)|0}l=j;return}function Vs(a,b,d,e,f,g,i){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;i=i|0;var j=0,k=0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0;k=c[b+12>>2]|0;l=+h[i+(k<<5)>>3];m=+h[i+(k<<5)+8>>3];n=+h[i+(k<<5)+16>>3];o=+h[i+(k<<5)+24>>3];if(!((a|0)==0?(q=+(g<<1|0),p=+(f|0),(Ws((~~+N(+((q-l+n)/p))|0)/-2|0,(~~+N(+((q-m+o)/p))|0)/-2|0,b,d,e,f,i)|0)!=0):0))j=3;a:do if((j|0)==3?(Ws(0,0,b,d,e,f,i)|0)==0:0)if((~~+N(+(n-l))|0)<(~~+N(+(o-m))|0)){k=1;while(1){j=0-k|0;a=0;while(1){if((a|0)<=(j|0)){g=j;break}if(Ws(j,a,b,d,e,f,i)|0)break a;a=a+-1|0}while(1){if((g|0)>=(k|0))break;if(Ws(g,a,b,d,e,f,i)|0)break a;g=g+1|0}while(1){if((a|0)>=(k|0))break;if(Ws(g,a,b,d,e,f,i)|0)break a;a=a+1|0}while(1){if((g|0)<=(j|0))break;if(Ws(g,a,b,d,e,f,i)|0)break a;g=g+-1|0}while(1){if((a|0)<=0)break;if(!(Ws(g,a,b,d,e,f,i)|0))a=a+-1|0;else break a}k=k+1|0}}else{k=1;while(1){j=0-k|0;a=0;while(1){if((a|0)>=(k|0)){g=j;break}if(Ws(a,j,b,d,e,f,i)|0)break a;a=a+1|0}while(1){if((g|0)>=(k|0))break;if(Ws(a,g,b,d,e,f,i)|0)break a;g=g+1|0}while(1){if((a|0)<=(j|0))break;if(Ws(a,g,b,d,e,f,i)|0)break a;a=a+-1|0}while(1){if((g|0)<=(j|0))break;if(Ws(a,g,b,d,e,f,i)|0)break a;g=g+-1|0}while(1){if((a|0)>=0)break;if(!(Ws(a,g,b,d,e,f,i)|0))a=a+1|0;else break a}k=k+1|0}}while(0);return}function Ws(a,b,d,e,f,g,i){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;i=i|0;var j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0.0,x=0.0;t=l;l=l+48|0;r=t+32|0;s=t+8|0;q=t;m=d+4|0;o=c[d+8>>2]|0;p=q+4|0;j=c[m>>2]|0;k=0;while(1){if((k|0)>=(o|0)){n=5;break}v=j;u=c[v+4>>2]|0;c[q>>2]=(c[v>>2]|0)+a;c[p>>2]=u+b;c[r>>2]=c[q>>2];c[r+4>>2]=c[q+4>>2];if(Dx(e,r)|0){j=0;break}j=j+8|0;k=k+1|0}if((n|0)==5){d=c[d+12>>2]|0;x=+h[i+(d<<5)>>3];w=+h[i+(d<<5)+8>>3];c[f>>2]=(O(g,a)|0)-~~(x+(x>=0.0?.5:-.5));d=f+4|0;c[d>>2]=(O(g,b)|0)-~~(w+(w>=0.0?.5:-.5));j=c[m>>2]|0;k=0;while(1){if((k|0)>=(o|0))break;u=j;v=c[u+4>>2]|0;c[q>>2]=(c[u>>2]|0)+a;c[p>>2]=v+b;c[r>>2]=c[q>>2];c[r+4>>2]=c[q+4>>2];Ax(e,r);j=j+8|0;k=k+1|0}if(0>1){j=c[13918]|0;u=c[f>>2]|0;v=c[d>>2]|0;c[s>>2]=o;c[s+4>>2]=a;c[s+8>>2]=b;c[s+12>>2]=u;c[s+16>>2]=v;zL(j,84335,s)|0;j=1}else j=1}l=t;return j|0}function Xs(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=(c[b+4>>2]|0)-(c[d+4>>2]|0)|0;c[a>>2]=(c[b>>2]|0)-(c[d>>2]|0);c[a+4>>2]=e;return}function Ys(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=(c[d+4>>2]|0)+(c[b+4>>2]|0)|0;c[a>>2]=(c[d>>2]|0)+(c[b>>2]|0);c[a+4>>2]=e;return}function Zs(a,b,d,e,f,g,i){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;i=i|0;var j=0.0,k=0.0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0;A=l;l=l+112|0;x=A+96|0;w=A+80|0;r=A+48|0;s=A+32|0;y=A+16|0;z=A;n=A+64|0;h[y>>3]=+(c[b>>2]|0);t=y+8|0;h[t>>3]=+(c[b+4>>2]|0);a:do if((i|0)!=0?(u=a+16|0,m=c[(c[u>>2]|0)+8>>2]|0,(m|0)!=0):0){q=+(e|0);p=+(f|0);o=1.0/+(g|0);n=z+8|0;i=0;while(1){if((i|0)>=(c[m+4>>2]|0))break a;f=c[m>>2]|0;a=c[f+(i*48|0)>>2]|0;b=c[f+(i*48|0)+4>>2]|0;g=c[f+(i*48|0)+8>>2]|0;e=c[f+(i*48|0)+12>>2]|0;m=f+(i*48|0)+16|0;c[r>>2]=c[m>>2];c[r+4>>2]=c[m+4>>2];c[r+8>>2]=c[m+8>>2];c[r+12>>2]=c[m+12>>2];f=f+(i*48|0)+32|0;c[s>>2]=c[f>>2];c[s+4>>2]=c[f+4>>2];c[s+8>>2]=c[f+8>>2];c[s+12>>2]=c[f+12>>2];if(!g){c[y>>2]=c[a>>2];c[y+4>>2]=c[a+4>>2];c[y+8>>2]=c[a+8>>2];c[y+12>>2]=c[a+12>>2];m=a+16|0;c[z>>2]=c[m>>2];c[z+4>>2]=c[m+4>>2];c[z+8>>2]=c[m+8>>2];c[z+12>>2]=c[m+12>>2];m=2}else{c[y>>2]=c[r>>2];c[y+4>>2]=c[r+4>>2];c[y+8>>2]=c[r+8>>2];c[y+12>>2]=c[r+12>>2];c[z>>2]=c[a>>2];c[z+4>>2]=c[a+4>>2];c[z+8>>2]=c[a+8>>2];c[z+12>>2]=c[a+12>>2];m=1}j=+h[y>>3]+q;h[y>>3]=j;k=+h[t>>3]+p;h[t>>3]=k;if(!(j>=0.0))j=(j+1.0)*o+-1.0;else j=j*o;h[y>>3]=j;if(!(k>=0.0))j=(k+1.0)*o+-1.0;else j=k*o;h[t>>3]=j;j=+h[z>>3]+q;h[z>>3]=j;k=+h[n>>3]+p;h[n>>3]=k;if(!(j>=0.0))j=(j+1.0)*o+-1.0;else j=j*o;h[z>>3]=j;if(!(k>=0.0))j=(k+1.0)*o+-1.0;else j=k*o;h[n>>3]=j;c[w>>2]=c[y>>2];c[w+4>>2]=c[y+4>>2];c[w+8>>2]=c[y+8>>2];c[w+12>>2]=c[y+12>>2];c[x>>2]=c[z>>2];c[x+4>>2]=c[z+4>>2];c[x+8>>2]=c[z+8>>2];c[x+12>>2]=c[z+12>>2];Ks(w,x,d);while(1){if((m|0)>=(b|0))break;c[y>>2]=c[z>>2];c[y+4>>2]=c[z+4>>2];c[y+8>>2]=c[z+8>>2];c[y+12>>2]=c[z+12>>2];g=a+(m<<4)|0;c[z>>2]=c[g>>2];c[z+4>>2]=c[g+4>>2];c[z+8>>2]=c[g+8>>2];c[z+12>>2]=c[g+12>>2];j=+h[z>>3]+q;h[z>>3]=j;k=+h[n>>3]+p;h[n>>3]=k;if(!(j>=0.0))j=(j+1.0)*o+-1.0;else j=j*o;h[z>>3]=j;if(!(k>=0.0))j=(k+1.0)*o+-1.0;else j=k*o;h[n>>3]=j;c[w>>2]=c[y>>2];c[w+4>>2]=c[y+4>>2];c[w+8>>2]=c[y+8>>2];c[w+12>>2]=c[y+12>>2];c[x>>2]=c[z>>2];c[x+4>>2]=c[z+4>>2];c[x+8>>2]=c[z+8>>2];c[x+12>>2]=c[z+12>>2];Ks(w,x,d);m=m+1|0}if(e|0){c[y>>2]=c[z>>2];c[y+4>>2]=c[z+4>>2];c[y+8>>2]=c[z+8>>2];c[y+12>>2]=c[z+12>>2];c[z>>2]=c[s>>2];c[z+4>>2]=c[s+4>>2];c[z+8>>2]=c[s+8>>2];c[z+12>>2]=c[s+12>>2];j=+h[z>>3]+q;h[z>>3]=j;k=+h[n>>3]+p;h[n>>3]=k;if(!(j>=0.0))j=(j+1.0)*o+-1.0;else j=j*o;h[z>>3]=j;if(!(k>=0.0))j=(k+1.0)*o+-1.0;else j=k*o;h[n>>3]=j;c[w>>2]=c[y>>2];c[w+4>>2]=c[y+4>>2];c[w+8>>2]=c[y+8>>2];c[w+12>>2]=c[y+12>>2];c[x>>2]=c[z>>2];c[x+4>>2]=c[z+4>>2];c[x+8>>2]=c[z+8>>2];c[x+12>>2]=c[z+12>>2];Ks(w,x,d)}i=i+1|0;m=c[(c[u>>2]|0)+8>>2]|0}}else v=4;while(0);if((v|0)==4){OA(n,c[((c[a>>2]&3|0)==2?a:a+-48|0)+40>>2]|0);c[z>>2]=c[n>>2];c[z+4>>2]=c[n+4>>2];c[z+8>>2]=c[n+8>>2];c[z+12>>2]=c[n+12>>2];j=+h[z>>3]+ +(e|0);h[z>>3]=j;m=z+8|0;k=+h[m>>3]+ +(f|0);h[m>>3]=k;if(!(j>=0.0))j=(j+1.0)/+(g|0)+-1.0;else j=j/+(g|0);h[z>>3]=j;if(!(k>=0.0))j=(k+1.0)/+(g|0)+-1.0;else j=k/+(g|0);h[m>>3]=j;c[w>>2]=c[y>>2];c[w+4>>2]=c[y+4>>2];c[w+8>>2]=c[y+8>>2];c[w+12>>2]=c[y+12>>2];c[x>>2]=c[z>>2];c[x+4>>2]=c[z+4>>2];c[x+8>>2]=c[z+8>>2];c[x+12>>2]=c[z+12>>2];Ks(w,x,d)}l=A;return}function _s(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,i=0,j=0,k=0,l=0,m=0.0,n=0.0,o=0.0,p=0.0,q=0,r=0,s=0,t=0;a:do if((a|0)<1)f=0-a|0;else{s=(e|0)==0;q=(f|0)==0;j=0;while(1){if((j|0)==(a|0)){f=0;break a}r=c[b+(j<<2)>>2]|0;g=s?r:e;k=c[d+(j<<3)>>2]|0;l=c[d+(j<<3)+4>>2]|0;m=+(k|0);n=m*.013888888888888888;o=+(l|0);p=o*.013888888888888888;i=co(r)|0;while(1){if(!i)break;f=c[i+16>>2]|0;t=c[f+132>>2]|0;h[t>>3]=+h[t>>3]+n;t=t+8|0;h[t>>3]=+h[t>>3]+p;t=f+16|0;h[t>>3]=+h[t>>3]+m;t=f+24|0;h[t>>3]=+h[t>>3]+o;f=c[f+108>>2]|0;if(f|0){t=f+56|0;h[t>>3]=+h[t>>3]+m;t=f+64|0;h[t>>3]=+h[t>>3]+o}b:do if(!q){f=Pm(g,i)|0;while(1){if(!f)break b;$s(f,k,l);f=Rm(g,f)|0}}while(0);i=eo(r,i)|0}at(r,k,l);j=j+1|0}}while(0);return f|0}function $s(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,i=0,j=0.0,k=0,l=0.0,m=0,n=0;e=c[a+16>>2]|0;a=c[e+96>>2]|0;if(a|0){m=a+56|0;h[m>>3]=+h[m>>3]+ +(b|0);m=a+64|0;h[m>>3]=+h[m>>3]+ +(d|0)}a=c[e+108>>2]|0;if(a|0){m=a+56|0;h[m>>3]=+h[m>>3]+ +(b|0);m=a+64|0;h[m>>3]=+h[m>>3]+ +(d|0)}a=c[e+100>>2]|0;if(a|0){m=a+56|0;h[m>>3]=+h[m>>3]+ +(b|0);m=a+64|0;h[m>>3]=+h[m>>3]+ +(d|0)}a=c[e+104>>2]|0;if(a|0){m=a+56|0;h[m>>3]=+h[m>>3]+ +(b|0);m=a+64|0;h[m>>3]=+h[m>>3]+ +(d|0)}m=c[e+8>>2]|0;a:do if(m|0){l=+(b|0);j=+(d|0);b=c[m+4>>2]|0;a=0;while(1){if((a|0)>=(b|0))break a;k=c[m>>2]|0;d=c[k+(a*48|0)>>2]|0;f=c[k+(a*48|0)+4>>2]|0;g=c[k+(a*48|0)+8>>2]|0;i=c[k+(a*48|0)+12>>2]|0;e=0;while(1){if((e|0)>=(f|0))break;n=d+(e<<4)|0;h[n>>3]=+h[n>>3]+l;n=d+(e<<4)+8|0;h[n>>3]=+h[n>>3]+j;e=e+1|0}if(g|0){n=k+(a*48|0)+16|0;h[n>>3]=+h[n>>3]+l;n=k+(a*48|0)+24|0;h[n>>3]=+h[n>>3]+j}if(i|0){n=k+(a*48|0)+32|0;h[n>>3]=+h[n>>3]+l;n=k+(a*48|0)+40|0;h[n>>3]=+h[n>>3]+j}a=a+1|0}}while(0);return}function at(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0.0,i=0.0,j=0,k=0.0,l=0.0,m=0,n=0.0,o=0;j=b+16|0;b=c[j>>2]|0;o=b+16|0;m=b+24|0;f=b+32|0;b=b+40|0;g=+(d|0);l=+h[f>>3]+g;i=+(e|0);n=+h[m>>3]+i;k=+h[b>>3]+i;h[o>>3]=+h[o>>3]+g;h[m>>3]=n;h[f>>3]=l;h[b>>3]=k;b=c[j>>2]|0;f=c[b+12>>2]|0;if((f|0)!=0?(a[f+81>>0]|0)!=0:0){o=f+56|0;h[o>>3]=+h[o>>3]+g;f=f+64|0;h[f>>3]=+h[f>>3]+i;f=1}else f=1;while(1){if((f|0)>(c[b+180>>2]|0))break;at(c[(c[b+184>>2]|0)+(f<<2)>>2]|0,d,e);f=f+1|0;b=c[j>>2]|0}return}function bt(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=Ls(a,b,d,e)|0;if(!f)a=1;else{a=_s(a,b,f,d,c[e+12>>2]|0)|0;_I(f)}return a|0}function ct(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0;p=l;l=l+32|0;o=p;n=bt(a,b,d,e)|0;if(!n){dB(d);m=(c[d+16>>2]|0)+16|0;c[o>>2]=c[m>>2];c[o+4>>2]=c[m+4>>2];c[o+8>>2]=c[m+8>>2];c[o+12>>2]=c[m+12>>2];c[o+16>>2]=c[m+16>>2];c[o+20>>2]=c[m+20>>2];c[o+24>>2]=c[m+24>>2];c[o+28>>2]=c[m+28>>2];f=o+8|0;g=o+16|0;i=o+24|0;e=0;while(1){if((e|0)>=(a|0))break;k=c[(c[b+(e<<2)>>2]|0)+16>>2]|0;j=c[k+180>>2]|0;k=k+184|0;d=1;while(1){if((d|0)>(j|0))break;r=(c[(c[(c[k>>2]|0)+(d<<2)>>2]|0)+16>>2]|0)+16|0;h[o>>3]=+h[(+h[o>>3]<+h[r>>3]?o:r)>>3];r=c[(c[(c[k>>2]|0)+(d<<2)>>2]|0)+16>>2]|0;q=r+16|0;h[f>>3]=+h[(+h[f>>3]<+h[r+24>>3]?o:q)+8>>3];h[g>>3]=+h[(+h[g>>3]>+h[r+32>>3]?o:q)+16>>3];h[i>>3]=+h[(+h[i>>3]>+h[r+40>>3]?o:q)+24>>3];d=d+1|0}e=e+1|0}c[m>>2]=c[o>>2];c[m+4>>2]=c[o+4>>2];c[m+8>>2]=c[o+8>>2];c[m+12>>2]=c[o+12>>2];c[m+16>>2]=c[o+16>>2];c[m+20>>2]=c[o+20>>2];c[m+24>>2]=c[o+24>>2];c[m+28>>2]=c[o+28>>2]}l=p;return n|0}function dt(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;g=l;l=l+16|0;f=g;if(!e)ma(84553,84559,1400,84566);d=et(a,d,d)|0;c[e+8>>2]=d;if(0){h=c[13918]|0;c[f>>2]=d;zL(h,84578,f)|0}c[e+12>>2]=0;c[e+20>>2]=0;ft(a,b,e)|0;l=g;return c[e+16>>2]|0}function et(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;i=l;l=l+16|0;h=i;f=i+4|0;g=Im(b,84708)|0;a:do if(g){c[h>>2]=f;h=(cM(g,122187,h)|0)==1;b=c[f>>2]|0;if(h&(b|0)>-1)d=b;else{switch(a[g>>0]|0){case 84:case 116:break;default:break a}d=e}}while(0);l=i;return d|0}function ft(a,b,c){a=a|0;b=b|0;c=c|0;return gt(Im(a,84591)|0,b,c)|0}function gt(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0.0;u=l;l=l+64|0;r=u+40|0;q=u+32|0;t=u+24|0;s=u+16|0;m=u+8|0;k=u;i=u+48|0;j=u+44|0;if(!e)ma(84553,84559,1292,84600);o=e+28|0;c[o>>2]=0;p=e+16|0;c[p>>2]=d;n=e+4|0;c[n>>2]=0;c[e+24>>2]=0;a:do if(b|0?(f=a[b>>0]|0,f<<24>>24):0)switch(f<<24>>24|0){case 97:if(!(VJ(b,84618,5)|0)){c[p>>2]=4;m=ht(b+5|0,e)|0;c[k>>2]=j;m=(cM(m,122187,k)|0)>0;d=c[j>>2]|0;if(!(m&(d|0)>0))break a;c[n>>2]=d;break a}else{if(VJ(b,84624,6)|0)break a;c[p>>2]=5;c[m>>2]=i;m=(cM(b+5|0,84631,m)|0)>0;v=+g[i>>2];g[e>>2]=m&v>0.0?v:1.0;break a}case 99:{if(f<<24>>24!=99)break a;if(xJ(b,93039)|0)break a;c[p>>2]=1;break a}case 103:{if(f<<24>>24!=103)break a;if(xJ(b,96286)|0)break a;c[p>>2]=3;break a}case 110:{if(f<<24>>24!=110)break a;if(xJ(b,96273)|0)break a;c[p>>2]=2;break a}default:break a}while(0);if(0){d=c[13918]|0;XL(84634,11,1,d)|0;c[s>>2]=it(c[p>>2]|0)|0;zL(d,84646,s)|0;if((c[p>>2]|0)==5){h[t>>3]=+g[e>>2];zL(d,84659,t)|0}c[q>>2]=c[n>>2];zL(d,84672,q)|0;c[r>>2]=c[o>>2];zL(d,84685,r)|0}l=u;return c[p>>2]|0}function ht(b,d){b=b|0;d=d|0;var e=0,f=0,g=0;a:do if((a[b>>0]|0)==95){f=d+28|0;e=1;while(1){b=b+1|0;b:while(1){if(!e)break a;d=a[b>>0]|0;if(!(d<<24>>24))break a;switch(d<<24>>24|0){case 99:{g=10;break b}case 105:{g=9;break b}case 117:{g=11;break b}case 116:{g=12;break b}case 98:{d=32;break b}case 108:{g=7;break b}case 114:{g=8;break b}default:e=0}}if((g|0)==7){g=0;d=4}else if((g|0)==8){g=0;d=8}else if((g|0)==9){g=0;d=64}else if((g|0)==10){g=0;d=1}else if((g|0)==11){g=0;d=2}else if((g|0)==12){g=0;d=16}c[f>>2]=c[f>>2]|d}}while(0);return b|0}function it(a){a=a|0;switch(a|0){case 1:{a=93039;break}case 2:{a=96273;break}case 3:{a=96286;break}case 4:{a=84618;break}case 5:{a=84624;break}default:a=84698}return a|0}function jt(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0;n=l;l=l+96|0;k=n;m=n+80|0;do if(a){if(!e){e=$I(1,20)|0;c[e+4>>2]=d>>>0>80?d:80}d=c[e>>2]|0;j=c[e+4>>2]|0;if(!d){h=100;d=a;i=$I(100,j)|0}else{h=d+100|0;i=aJ(c[e+8>>2]|0,O(h,j)|0)|0;VN(i+(O(j,d)|0)|0,0,j*100|0)|0;d=a}while(1){d=kt(k,d,b,m)|0;if(!d)break;a=c[e>>2]|0;f=h<<1;g=O(h,j)|0;if((a|0)==(h|0)){i=aJ(i,O(f,j)|0)|0;VN(i+g|0,0,g|0)|0;a=c[e>>2]|0}else f=h;a=i+(O(a,j)|0)|0;g=k;h=a+80|0;do{c[a>>2]=c[g>>2];a=a+4|0;g=g+4|0}while((a|0)<(h|0));c[e>>2]=(c[e>>2]|0)+1;h=f}if(c[m>>2]|0){m=e+16|0;c[m>>2]=c[m>>2]|1}d=c[e>>2]|0;if(!d){_I(i);_I(e);e=0;break}else{c[e+8>>2]=aJ(i,O(d,j)|0)|0;break}}while(0);l=n;return e|0}function kt(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0;j=l;l=l+80|0;h=j+64|0;i=j;c[f>>2]=0;do{g=a[d>>0]|0;d=d+1|0}while((XJ(g)|0)!=0);a:do switch(g|0){case 69:{c[b>>2]=0;d=lt(d,b+8|0)|0;if(!d){c[f>>2]=1;d=0;break a}if(e)c[b+72>>2]=c[e>>2];break}case 101:{c[b>>2]=1;d=lt(d,b+8|0)|0;if(!d){c[f>>2]=1;d=0;break a}if(e)c[b+72>>2]=c[e>>2];break}case 80:{c[b>>2]=2;d=mt(d,b+8|0)|0;if(!d){c[f>>2]=1;d=0;break a}if(e)c[b+72>>2]=c[e+4>>2];break}case 112:{c[b>>2]=3;d=mt(d,b+8|0)|0;if(!d){c[f>>2]=1;d=0;break a}if(e)c[b+72>>2]=c[e+4>>2];break}case 98:{c[b>>2]=4;d=mt(d,b+8|0)|0;if(!d){c[f>>2]=1;d=0;break a}if(e)c[b+72>>2]=c[e+8>>2];break}case 66:{c[b>>2]=5;d=mt(d,b+8|0)|0;if(!d){c[f>>2]=1;d=0;break a}if(e)c[b+72>>2]=c[e+8>>2];break}case 99:{d=nt(d,h)|0;if(!d){c[f>>2]=1;d=0;break a}g=ot(c[h>>2]|0,i)|0;c[h>>2]=g;if(!g){c[f>>2]=1;d=0;break a}if(!(c[i>>2]|0)){c[b>>2]=9;c[b+8>>2]=c[i+8>>2];if(!e)break a;c[b+72>>2]=c[e+24>>2];break a}else{c[b>>2]=14;f=b+8|0;g=i;h=f+64|0;do{c[f>>2]=c[g>>2];f=f+4|0;g=g+4|0}while((f|0)<(h|0));if(!e)break a;c[b+72>>2]=c[e+40>>2];break a}}case 67:{d=nt(d,h)|0;if(!d){c[f>>2]=1;d=0;break a}g=ot(c[h>>2]|0,i)|0;c[h>>2]=g;if(!g){c[f>>2]=1;d=0;break a}if(!(c[i>>2]|0)){c[b>>2]=8;c[b+8>>2]=c[i+8>>2];if(!e)break a;c[b+72>>2]=c[e+20>>2];break a}else{c[b>>2]=13;f=b+8|0;g=i;h=f+64|0;do{c[f>>2]=c[g>>2];f=f+4|0;g=g+4|0}while((f|0)<(h|0));if(!e)break a;c[b+72>>2]=c[e+40>>2];break a}}case 76:{c[b>>2]=6;d=mt(d,b+8|0)|0;if(!d){c[f>>2]=1;d=0;break a}if(e)c[b+72>>2]=c[e+12>>2];break}case 84:{c[b>>2]=7;d=pt(d,b+8|0)|0;if(!d){c[f>>2]=1;d=0;break a}d=pt(d,b+16|0)|0;if(!d){c[f>>2]=1;d=0;break a}d=qt(d,b+24|0)|0;if(!d){c[f>>2]=1;d=0;break a}d=pt(d,b+32|0)|0;if(!d){c[f>>2]=1;d=0;break a}d=nt(d,b+40|0)|0;if(!d){c[f>>2]=1;d=0;break a}if(e)c[b+72>>2]=c[e+16>>2];break}case 70:{c[b>>2]=10;d=pt(d,b+8|0)|0;if(!d){c[f>>2]=1;d=0;break a}d=nt(d,b+16|0)|0;if(!d){c[f>>2]=1;d=0;break a}if(e)c[b+72>>2]=c[e+28>>2];break}case 83:{c[b>>2]=11;d=nt(d,b+8|0)|0;if(!d){c[f>>2]=1;d=0;break a}if(e)c[b+72>>2]=c[e+32>>2];break}case 73:{c[b>>2]=12;d=lt(d,b+8|0)|0;if(!d){c[f>>2]=1;d=0;break a}d=nt(d,b+40|0)|0;if(!d){c[f>>2]=1;d=0;break a}if(e)c[b+72>>2]=c[e+36>>2];break}case 116:{c[b>>2]=15;d=rt(d,b+8|0)|0;if(!d){c[f>>2]=1;d=0;break a}if(e)c[b+72>>2]=c[e+44>>2];break}case 0:{d=0;break}default:{c[f>>2]=1;d=0}}while(0);l=j;return d|0}function lt(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,i=0;i=l;l=l+16|0;e=i;h[b>>3]=+tM(a,e);f=c[e>>2]|0;if(((f|0)!=(a|0)?(h[b+8>>3]=+tM(f,e),g=c[e>>2]|0,(f|0)!=(g|0)):0)?(h[b+16>>3]=+tM(g,e),d=c[e>>2]|0,(g|0)!=(d|0)):0){h[b+24>>3]=+tM(d,e);a=c[e>>2]|0;a=(d|0)==(a|0)?0:a}else a=0;l=i;return a|0}function mt(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0,k=0;k=l;l=l+16|0;j=k+4|0;g=k;a=st(a,j)|0;do if(a){d=c[j>>2]|0;i=$I(d,24)|0;c[b>>2]=d;e=i;f=0;while(1){if((f|0)>=(d|0)){d=9;break}h[e>>3]=+tM(a,g);d=c[g>>2]|0;if((a|0)==(d|0)){d=5;break}h[e+8>>3]=+tM(d,g);a=c[g>>2]|0;if((d|0)==(a|0)){d=7;break}h[e+16>>3]=0.0;e=e+24|0;d=c[b>>2]|0;f=f+1|0}if((d|0)==5){c[j>>2]=f;_I(i);a=0;break}else if((d|0)==7){c[j>>2]=f;_I(i);a=0;break}else if((d|0)==9){c[j>>2]=f;c[b+4>>2]=i;break}}else a=0;while(0);l=k;return a|0}function nt(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;j=l;l=l+16|0;i=j;b=st(b,i)|0;f=c[i>>2]|0;do if(!((b|0)==0|(f|0)<1)){while(1){h=a[b>>0]|0;e=h<<24>>24==0;if(e^h<<24>>24!=45)b=b+1|0;else break}if(!e){h=$I(f+1|0,1)|0;g=h;e=f;while(1){b=b+1|0;if((e|0)<=0){e=9;break}e=a[b>>0]|0;if(!(e<<24>>24)){e=8;break}a[g>>0]=e;e=(c[i>>2]|0)+-1|0;c[i>>2]=e;g=g+1|0}if((e|0)==8){_I(h);b=0;break}else if((e|0)==9){a[g>>0]=0;c[d>>2]=h;break}}else b=0}else b=0;while(0);l=j;return b|0}function ot(b,d){b=b|0;d=d|0;var e=0;e=a[b>>0]|0;switch(e|0){case 91:{b=tt(b+1|0,d)|0;break}case 40:{b=ut(b+1|0,d)|0;break}case 47:case 35:{c[d>>2]=0;c[d+8>>2]=b;break}default:if(!(gK(e)|0))b=0;else{c[d>>2]=0;c[d+8>>2]=b}}return b|0}function pt(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0;f=l;l=l+16|0;d=f;e=+tM(a,d);d=c[d>>2]|0;if((d|0)==(a|0))d=0;else h[b>>3]=e;l=f;return d|0}function qt(a,b){a=a|0;b=b|0;var d=0,e=0;d=l;l=l+16|0;e=d;a=st(a,e)|0;e=c[e>>2]|0;c[b>>2]=(e|0)<0?0:e|0?2:1;l=d;return a|0}function rt(a,b){a=a|0;b=b|0;var d=0,e=0;d=l;l=l+16|0;e=d;c[b>>2]=YJ(a,e,10)|0;b=c[e>>2]|0;l=d;return ((b|0)==(a|0)?0:b)|0}function st(a,b){a=a|0;b=b|0;var d=0,e=0;d=l;l=l+16|0;e=d;c[b>>2]=BL(a,e,10)|0;b=c[e>>2]|0;l=d;return ((b|0)==(a|0)?0:b)|0}function tt(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,i=0,j=0,k=0,m=0,n=0,o=0;o=l;l=l+16|0;m=o;c[b>>2]=1;n=b+8|0;i=pt(a,n)|0;do if(((((i|0)!=0?(j=pt(i,b+16|0)|0,(j|0)!=0):0)?(e=pt(j,b+24|0)|0,(e|0)!=0):0)?(f=pt(e,b+32|0)|0,(f|0)!=0):0)?(k=b+40|0,d=st(f,k)|0,(d|0)!=0):0){b=c[k>>2]|0;f=$I(b,8)|0;e=0;while(1){if((e|0)>=(b|0)){d=13;break}d=pt(d,m)|0;if(!d){d=9;break}g[f+(e<<3)>>2]=+h[m>>3];d=nt(d,f+(e<<3)+4|0)|0;if(!d){d=12;break}e=e+1|0;b=c[k>>2]|0}if((d|0)==9){_I(f);a=0;break}else if((d|0)==12){_I(f);a=0;break}else if((d|0)==13){c[n+36>>2]=f;break}}else a=0;while(0);l=o;return a|0}function ut(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0;p=l;l=l+16|0;n=p;c[b>>2]=2;k=pt(a,b+8|0)|0;do if(((((((k|0)!=0?(m=pt(k,b+16|0)|0,(m|0)!=0):0)?(e=pt(m,b+24|0)|0,(e|0)!=0):0)?(f=pt(e,b+32|0)|0,(f|0)!=0):0)?(i=pt(f,b+40|0)|0,(i|0)!=0):0)?(j=pt(i,b+48|0)|0,(j|0)!=0):0)?(o=b+56|0,d=st(j,o)|0,(d|0)!=0):0){e=c[o>>2]|0;i=$I(e,8)|0;f=0;while(1){if((f|0)>=(e|0)){d=15;break}d=pt(d,n)|0;if(!d){d=11;break}g[i+(f<<3)>>2]=+h[n>>3];d=nt(d,i+(f<<3)+4|0)|0;if(!d){d=14;break}f=f+1|0;e=c[o>>2]|0}if((d|0)==11){_I(i);a=0;break}else if((d|0)==14){_I(i);a=0;break}else if((d|0)==15){c[b+60>>2]=i;break}}else a=0;while(0);l=p;return a|0}function vt(a,b,c){a=a|0;b=b|0;c=c|0;return jt(a,b,c,0)|0}function wt(a){a=a|0;return vt(a,0,0)|0}function xt(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0;e=c[a+12>>2]|0;if(a|0){f=c[a+8>>2]|0;g=a+4|0;h=(e|0)==0;b=0;while(1){if((b|0)>=(c[a>>2]|0))break;d=f+(O(c[g>>2]|0,b)|0)|0;if(!h)gb[e&127](d);yt(d);b=b+1|0}_I(f);_I(a)}return}function yt(a){a=a|0;switch(c[a>>2]|0){case 3:case 2:{_I(c[a+8+4>>2]|0);break}case 5:case 4:{_I(c[a+8+4>>2]|0);break}case 6:{_I(c[a+8+4>>2]|0);break}case 7:{_I(c[a+40>>2]|0);break}case 9:case 8:{_I(c[a+8>>2]|0);break}case 14:case 13:{zt(a+8|0);break}case 10:{_I(c[a+16>>2]|0);break}case 11:{_I(c[a+8>>2]|0);break}case 12:{_I(c[a+40>>2]|0);break}default:{}}return}function zt(a){a=a|0;var b=0,d=0,e=0;switch(c[a>>2]|0){case 1:{e=a+40|0;b=a+8+36|0;a=0;while(1){d=c[b>>2]|0;if((a|0)>=(c[e>>2]|0))break;_I(c[d+(a<<3)+4>>2]|0);a=a+1|0}_I(d);break}case 2:{e=a+56|0;d=a+60|0;a=0;while(1){b=c[d>>2]|0;if((a|0)>=(c[e>>2]|0))break;_I(c[b+(a<<3)+4>>2]|0);a=a+1|0}_I(b);break}default:{}}return}function At(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0;o=l;l=l+16|0;k=o+4|0;n=o;c[d>>2]=0;c[e>>2]=(qn(ro(b)|0)|0)!=0&1;f=c[42228]|0;a:do if(f|0?(h=Jm(b,f)|0,i=a[h>>0]|0,i<<24>>24):0){f=19444;while(1){g=c[f>>2]|0;if(!g)break a;if(i<<24>>24==(a[g>>0]|0)?(xJ(h,g)|0)==0:0)break;f=f+12|0}c[d>>2]=c[f+4>>2];c[e>>2]=c[f+8>>2]}while(0);f=c[42239]|0;if((f|0?(c[e>>2]|0)==1:0)?(j=Jm(b,f)|0,a[j>>0]|0):0)Bt(j,e);f=c[42240]|0;if((f|0?(c[d>>2]|0)==1:0)?(m=Jm(b,f)|0,a[m>>0]|0):0)Bt(m,d);if(a[(c[b+16>>2]|0)+153>>0]|0){j=b+-48|0;i=ro(c[((c[b>>2]&3|0)==2?b:j)+40>>2]|0)|0;m=c[b>>2]&3;At(an(i,c[((m|0)==2?b:j)+40>>2]|0,c[((m|0)==3?b:b+48|0)+40>>2]|0,0,0)|0,k,n);c[e>>2]=c[k>>2]|c[e>>2];c[d>>2]=c[n>>2]|c[d>>2]}l=o;return}function Bt(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0;o=l;l=l+16|0;m=o;k=o+4|0;j=0;e=0;a:while(1){c[d>>2]=e;g=(j|0)<4;h=(j|0)==3;i=(j|0)==0;while(1){if(!(g&(a[b>>0]|0)!=0))break a;c[k>>2]=0;f=Ct(b,k)|0;e=c[k>>2]|0;if(!e){n=5;break a}b=(e|0)==8;if(!(h&b)){if(!(i&b))break;if(a[f>>0]|0)break}c[k>>2]=0;b=f}e=c[d>>2]|e<<(j<<3);j=j+1|0;b=f}if((n|0)==5){c[m>>2]=b;_l(0,84713,m)|0}l=o;return}function Ct(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;f=l;l=l+16|0;e=f;c[e>>2]=0;d=Dt(a,19504,e)|0;if((d|0)==(a|0)){while(1){d=Dt(a,19520,e)|0;if((a|0)==(d|0))break;else a=d}d=Dt(a,19568,e)|0}a=c[e>>2]|0;if((a|0)!=0&(a&15|0)==0){a=a|1;c[e>>2]=a}c[b>>2]=c[b>>2]|a;l=f;return d|0}function Dt(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;while(1){e=c[b>>2]|0;if(!e)break;f=rJ(e)|0;if(!(VJ(a,e,f)|0)){g=4;break}b=b+8|0}if((g|0)==4){c[d>>2]=c[d>>2]|c[b+4>>2];a=a+f|0}return a|0}function Et(a,b){a=a|0;b=b|0;var d=0.0,e=0,f=0,g=0,i=0;g=0;d=0.0;while(1){if((g|0)==4)break;f=b>>(g<<3)&15;e=1336;while(1){if(!(c[e+16>>2]|0))break;if((f|0)==(c[e>>2]|0)){i=6;break}e=e+24|0}if((i|0)==6){i=0;d=+h[e+8>>3]+d}g=g+1|0}return +(d*10.0*+EA(a,c[42232]|0,1.0,0.0))}function Ft(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=+e;f=+f;g=g|0;var i=0.0,j=0.0,k=0.0,m=0,n=0.0,o=0,p=0;p=l;l=l+96|0;m=p+80|0;o=p;k=f>4.0?f*.0875:.35;i=+h[d+8>>3];n=i*k;j=+h[d>>3];k=j*k;e=+h[b>>3];j=e+j;h[m>>3]=j;f=+h[b+8>>3];i=i+f;h[m+8>>3]=i;d=o+64|0;if(!(g&32)){c[d>>2]=c[m>>2];c[d+4>>2]=c[m+4>>2];c[d+8>>2]=c[m+8>>2];c[d+12>>2]=c[m+12>>2];c[o>>2]=c[m>>2];c[o+4>>2]=c[m+4>>2];c[o+8>>2]=c[m+8>>2];c[o+12>>2]=c[m+12>>2];m=o+32|0;c[m>>2]=c[b>>2];c[m+4>>2]=c[b+4>>2];c[m+8>>2]=c[b+8>>2];c[m+12>>2]=c[b+12>>2];f=i;e=j}else{c[d>>2]=c[b>>2];c[d+4>>2]=c[b+4>>2];c[d+8>>2]=c[b+8>>2];c[d+12>>2]=c[b+12>>2];c[o>>2]=c[b>>2];c[o+4>>2]=c[b+4>>2];c[o+8>>2]=c[b+8>>2];c[o+12>>2]=c[b+12>>2];b=o+32|0;c[b>>2]=c[m>>2];c[b+4>>2]=c[m+4>>2];c[b+8>>2]=c[m+8>>2];c[b+12>>2]=c[m+12>>2]}h[o+16>>3]=e+n;h[o+24>>3]=f-k;h[o+48>>3]=e-n;h[o+56>>3]=f+k;do if(!(g&64))if(!(g&128)){HD(a,o+16|0,3,g>>>4&1^1);break}else{HD(a,o+32|0,3,g>>>4&1^1);break}else HD(a,o,3,g>>>4&1^1);while(0);l=p;return}function Gt(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=+e;f=+f;g=g|0;var i=0.0,j=0.0,k=0.0,m=0.0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0,x=0,y=0;x=l;l=l+160|0;n=x+144|0;w=x;q=e*4.0;y=(g&32|0)==0;q=!(q1.0)|y?0.0:(f+-1.0)*.05/e;u=+h[d+8>>3];r=-u;v=q*r;t=+h[d>>3];q=t*q;r=s*r;s=t*s;p=+h[b>>3];e=p+t;h[n>>3]=e;o=+h[b+8>>3];f=u+o;h[n+8>>3]=f;t=t*.5+p;u=u*.5+o;d=w+128|0;if(y){c[d>>2]=c[n>>2];c[d+4>>2]=c[n+4>>2];c[d+8>>2]=c[n+8>>2];c[d+12>>2]=c[n+12>>2];c[w>>2]=c[n>>2];c[w+4>>2]=c[n+4>>2];c[w+8>>2]=c[n+8>>2];c[w+12>>2]=c[n+12>>2];y=w+64|0;c[y>>2]=c[b>>2];c[y+4>>2]=c[b+4>>2];c[y+8>>2]=c[b+8>>2];c[y+12>>2]=c[b+12>>2];i=o;j=p;k=o;m=p;f=o;e=p}else{c[d>>2]=c[b>>2];c[d+4>>2]=c[b+4>>2];c[d+8>>2]=c[b+8>>2];c[d+12>>2]=c[b+12>>2];c[w>>2]=c[b>>2];c[w+4>>2]=c[b+4>>2];c[w+8>>2]=c[b+8>>2];c[w+12>>2]=c[b+12>>2];y=w+64|0;c[y>>2]=c[n>>2];c[y+4>>2]=c[n+4>>2];c[y+8>>2]=c[n+8>>2];c[y+12>>2]=c[n+12>>2];i=f+s;j=e+r;k=f-s;m=e-r}h[w+16>>3]=e-v;h[w+24>>3]=f-q;h[w+32>>3]=t-r;h[w+40>>3]=u-s;h[w+48>>3]=m;h[w+56>>3]=k;h[w+80>>3]=j;h[w+88>>3]=i;h[w+96>>3]=t+r;h[w+104>>3]=u+s;h[w+112>>3]=e+v;h[w+120>>3]=f+q;do if(!(g&64))if(!(g&128)){HD(a,w,9,1);break}else{HD(a,w+48|0,6,1);break}else HD(a,w,6,1);while(0);l=x;return}function Ht(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=+e;f=+f;g=g|0;var i=0.0,j=0.0,k=0.0,m=0.0,n=0,o=0,p=0,q=0,r=0,s=0.0,t=0.0;q=l;l=l+64|0;p=q;t=+h[d+8>>3];s=+h[d>>3];k=+h[b>>3];e=k+s;m=+h[b+8>>3];f=m+t;i=k+s*.2;j=m+t*.2;k=k+s*.6;m=m+t*.6;h[p>>3]=i-t;h[p+8>>3]=j+s;n=p+16|0;h[n>>3]=i+t;o=p+24|0;h[o>>3]=j-s;h[p+32>>3]=k+t;h[p+40>>3]=m-s;h[p+48>>3]=k-t;h[p+56>>3]=m+s;if(!(g&64)){if(g&128|0){d=2;g=1;r=3}}else{d=3;g=0;r=3}if((r|0)==3){h[p+(g<<4)>>3]=i;h[p+(g<<4)+8>>3]=j;h[p+(d<<4)>>3]=k;h[p+(d<<4)+8>>3]=m}HD(a,p,4,1);c[p>>2]=c[b>>2];c[p+4>>2]=c[b+4>>2];c[p+8>>2]=c[b+8>>2];c[p+12>>2]=c[b+12>>2];h[n>>3]=e;h[o>>3]=f;KD(a,p,2);l=q;return}function It(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=+e;f=+f;g=g|0;var i=0.0,j=0.0,k=0,m=0,n=0,o=0,p=0,q=0.0,r=0.0,s=0.0,t=0.0;o=l;l=l+64|0;n=o;j=+h[d+8>>3];r=j*-.4;i=+h[d>>3];q=i*.4;t=+h[b>>3];e=t+i*.8;s=+h[b+8>>3];f=s+j*.8;i=t+i;j=s+j;h[n>>3]=t+r;k=n+8|0;h[k>>3]=s+q;d=n+16|0;h[d>>3]=t-r;m=n+24|0;h[m>>3]=s-q;h[n+32>>3]=e-r;h[n+40>>3]=f-q;h[n+48>>3]=e+r;h[n+56>>3]=f+q;if(!(g&64)){if(g&128|0){c[d>>2]=c[b>>2];c[d+4>>2]=c[b+4>>2];c[d+8>>2]=c[b+8>>2];c[d+12>>2]=c[b+12>>2];d=2;p=5}}else{c[n>>2]=c[b>>2];c[n+4>>2]=c[b+4>>2];c[n+8>>2]=c[b+8>>2];c[n+12>>2]=c[b+12>>2];d=3;p=5}if((p|0)==5){h[n+(d<<4)>>3]=e;h[n+(d<<4)+8>>3]=f}HD(a,n,4,g>>>4&1^1);h[n>>3]=e;h[k>>3]=f;h[n+16>>3]=i;h[m>>3]=j;KD(a,n,2);l=o;return}function Jt(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=+e;f=+f;g=g|0;var i=0,j=0,k=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0;j=l;l=l+80|0;i=j;n=+h[d+8>>3];k=n*-.3333333333333333;p=+h[d>>3];f=p*.3333333333333333;q=+h[b>>3];m=q+p*.5;o=+h[b+8>>3];e=o+n*.5;d=i+64|0;h[i+64>>3]=q+p;h[i+72>>3]=o+n;c[i>>2]=c[d>>2];c[i+4>>2]=c[d+4>>2];c[i+8>>2]=c[d+8>>2];c[i+12>>2]=c[d+12>>2];h[i+16>>3]=m+k;h[i+24>>3]=e+f;d=i+32|0;c[d>>2]=c[b>>2];c[d+4>>2]=c[b+4>>2];c[d+8>>2]=c[b+8>>2];c[d+12>>2]=c[b+12>>2];h[i+48>>3]=m-k;h[i+56>>3]=e-f;do if(!(g&64)){d=g>>>4&1^1;if(!(g&128)){HD(a,i,4,d);break}else{HD(a,i,3,d);break}}else HD(a,d,3,g>>>4&1^1);while(0);l=j;return}function Kt(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=+d;e=+e;f=f|0;var g=0,i=0,j=0.0,k=0.0,m=0.0;g=l;l=l+32|0;i=g;k=+h[c>>3];e=+h[c+8>>3];d=+C(+(e*e+k*k))*.5;m=+h[b>>3];k=k*.5;h[i>>3]=m+k-d;j=+h[b+8>>3];e=e*.5;h[i+8>>3]=j-d+e;h[i+16>>3]=m+d+k;h[i+24>>3]=j+d+e;GD(a,i,2,f>>>4&1^1);l=g;return}function Lt(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=+e;f=+f;g=g|0;var i=0.0,j=0.0,k=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0,r=0,s=0,t=0;t=l;l=l+112|0;q=t+48|0;r=t+16|0;s=t;n=f>4.0?f*.125:.5;p=+h[b>>3];o=+h[d>>3];i=+h[b+8>>3];m=+h[d+8>>3];e=m*n;f=o*n;c[r>>2]=c[b>>2];c[r+4>>2]=c[b+4>>2];c[r+8>>2]=c[b+8>>2];c[r+12>>2]=c[b+12>>2];h[r+16>>3]=o+p;h[r+24>>3]=m+i;h[q>>3]=n*(o-m)+p;j=n*(m+o);k=j+i;h[q+8>>3]=k;h[q+48>>3]=j+p;i=n*(m-o)+i;h[q+56>>3]=i;o=e*-.95;m=o+f+p;n=f*1.3333333333333333;if(!(g&32)){e=e*1.3333333333333333;j=f*-.33333333333333326;i=i-e;f=k-e;e=m-n}else{e=e*1.3333333333333333;j=f*2.333333333333333;i=i+e;f=k+e;e=m+n}h[q+16>>3]=e;h[q+24>>3]=f;h[q+32>>3]=j-o+p;h[q+40>>3]=i;KD(a,r,2);if(!(g&64)){if(g&128|0)PA(s,q,3,.5,q,0)}else PA(s,q,3,.5,0,q);JD(a,q,4,0,0,0);l=t;return}function Mt(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=+e;f=+f;g=g|0;var i=0;g=l;l=l+32|0;i=g;e=+h[d>>3]+ +h[b>>3];f=+h[d+8>>3]+ +h[b+8>>3];c[i>>2]=c[b>>2];c[i+4>>2]=c[b+4>>2];c[i+8>>2]=c[b+8>>2];c[i+12>>2]=c[b+12>>2];h[i+16>>3]=e;h[i+24>>3]=f;KD(a,i,2);l=g;return}function Nt(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var i=0.0,j=0,k=0,m=0,n=0,o=0.0,p=0.0,q=0,r=0,s=0;n=l;l=l+80|0;j=n+72|0;k=n+8|0;m=n;i=+Et(a,g);i=i*i;h[m>>3]=i;c[f+12>>2]=g;g=f+32|0;a=e+3|0;f=b+(a<<4)|0;c[g>>2]=c[f>>2];c[g+4>>2]=c[f+4>>2];c[g+8>>2]=c[f+8>>2];c[g+12>>2]=c[f+12>>2];if((e|0)>(d|0)?(o=+h[b+(e<<4)>>3]-+h[f>>3],p=+h[b+(e<<4)+8>>3]-+h[b+(a<<4)+8>>3],p*p+o*o>2]=c[r>>2];c[s+4>>2]=c[r+4>>2];c[s+8>>2]=c[r+8>>2];c[s+12>>2]=c[r+12>>2];q=k+32|0;a=b+(e+1<<4)|0;c[q>>2]=c[a>>2];c[q+4>>2]=c[a+4>>2];c[q+8>>2]=c[a+8>>2];c[q+12>>2]=c[a+12>>2];f=k+16|0;d=b+(e+2<<4)|0;c[f>>2]=c[d>>2];c[f+4>>2]=c[d+4>>2];c[f+8>>2]=c[d+8>>2];c[f+12>>2]=c[d+12>>2];c[k>>2]=c[g>>2];c[k+4>>2]=c[g+4>>2];c[k+8>>2]=c[g+8>>2];c[k+12>>2]=c[g+12>>2];c[j>>2]=k;c[j+4>>2]=m;Fz(j,26,k,1);c[r>>2]=c[s>>2];c[r+4>>2]=c[s+4>>2];c[r+8>>2]=c[s+8>>2];c[r+12>>2]=c[s+12>>2];c[a>>2]=c[q>>2];c[a+4>>2]=c[q+4>>2];c[a+8>>2]=c[q+8>>2];c[a+12>>2]=c[q+12>>2];c[d>>2]=c[f>>2];c[d+4>>2]=c[f+4>>2];c[d+8>>2]=c[f+8>>2];c[d+12>>2]=c[f+12>>2];m=b+(e+3<<4)|0;c[m>>2]=c[k>>2];c[m+4>>2]=c[k+4>>2];c[m+8>>2]=c[k+8>>2];c[m+12>>2]=c[k+12>>2];l=n;return e|0}function Ot(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0;f=c[a>>2]|0;d=+h[b>>3]-+h[f>>3];e=+h[b+8>>3]-+h[f+8>>3];return e*e+d*d<=+h[c[a+4>>2]>>3]|0}function Pt(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var i=0,j=0.0,k=0,m=0,n=0,o=0,p=0.0,q=0.0,r=0,s=0;o=l;l=l+80|0;k=o+72|0;m=o+8|0;n=o;j=+Et(a,g);j=j*j;h[n>>3]=j;c[f+8>>2]=g;f=f+16|0;a=b+(d<<4)|0;c[f>>2]=c[a>>2];c[f+4>>2]=c[a+4>>2];c[f+8>>2]=c[a+8>>2];c[f+12>>2]=c[a+12>>2];if(!((e|0)>(d|0)?(i=d+3|0,p=+h[a>>3]-+h[b+(i<<4)>>3],q=+h[b+(d<<4)+8>>3]-+h[b+(i<<4)+8>>3],q*q+p*p>2]=c[e>>2];c[m+4>>2]=c[e+4>>2];c[m+8>>2]=c[e+8>>2];c[m+12>>2]=c[e+12>>2];g=m+16|0;d=b+(i+2<<4)|0;c[g>>2]=c[d>>2];c[g+4>>2]=c[d+4>>2];c[g+8>>2]=c[d+8>>2];c[g+12>>2]=c[d+12>>2];r=m+32|0;a=b+(i+1<<4)|0;c[r>>2]=c[a>>2];c[r+4>>2]=c[a+4>>2];c[r+8>>2]=c[a+8>>2];c[r+12>>2]=c[a+12>>2];s=m+48|0;c[s>>2]=c[f>>2];c[s+4>>2]=c[f+4>>2];c[s+8>>2]=c[f+8>>2];c[s+12>>2]=c[f+12>>2];c[k>>2]=s;c[k+4>>2]=n;Fz(k,26,m,0);n=b+(i<<4)|0;c[n>>2]=c[s>>2];c[n+4>>2]=c[s+4>>2];c[n+8>>2]=c[s+8>>2];c[n+12>>2]=c[s+12>>2];c[a>>2]=c[r>>2];c[a+4>>2]=c[r+4>>2];c[a+8>>2]=c[r+8>>2];c[a+12>>2]=c[r+12>>2];c[d>>2]=c[g>>2];c[d+4>>2]=c[g+4>>2];c[d+8>>2]=c[g+8>>2];c[d+12>>2]=c[g+12>>2];c[e>>2]=c[m>>2];c[e+4>>2]=c[m+4>>2];c[e+8>>2]=c[m+8>>2];c[e+12>>2]=c[m+12>>2];l=o;return i|0}function Qt(a,b,d,e,f,g,i){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;i=i|0;var j=0.0,k=0.0,l=0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0,s=0.0,t=0.0,u=0,v=0,w=0;u=(g|0)!=0;l=(i|0)!=0;if(!((e|0)==(d|0)&(u&l))){if(l){j=+Et(a,i);k=+h[b+(e<<4)>>3];p=+h[b+(e<<4)+8>>3];l=e+3|0;r=b+(l<<4)|0;n=+h[r>>3];l=b+(l<<4)+8|0;o=+h[l>>3];t=k-n;s=p-o;t=+C(+(s*s+t*t))*.9;j=j>=t?t:j;if(p==o){m=(k>3]=k;h[b+(w<<4)+8>>3]=p;e=b+(e+2<<4)|0;h[r>>3]=m;h[l>>3]=j;c[e>>2]=c[r>>2];c[e+4>>2]=c[r+4>>2];c[e+8>>2]=c[r+8>>2];c[e+12>>2]=c[r+12>>2];c[f+12>>2]=i;h[f+32>>3]=n;h[f+40>>3]=o}if(u){m=+Et(a,g);l=b+(d<<4)|0;k=+h[l>>3];j=+h[b+(d<<4)+8>>3];w=d+3|0;o=+h[b+(w<<4)>>3];p=+h[b+(w<<4)+8>>3];t=k-o;s=j-p;t=+C(+(s*s+t*t))*.9;m=m>=t?t:m;if(j==p){n=(k>3]=n;h[b+(w<<4)+8>>3]=m;c[l>>2]=c[v>>2];c[l+4>>2]=c[v+4>>2];c[l+8>>2]=c[v+8>>2];c[l+12>>2]=c[v+12>>2];v=d+2|0;h[b+(v<<4)>>3]=o;h[b+(v<<4)+8>>3]=p;v=16}}else{r=b+(e<<4)|0;s=+h[r>>3];t=+h[b+(e<<4)+8>>3];l=e+3|0;u=b+(l<<4)|0;k=+h[u>>3];l=b+(l<<4)+8|0;j=+h[l>>3];m=+Et(a,g);q=+Et(a,i);n=s-k;p=t-j;n=+C(+(p*p+n*n));w=!(q+m>=n);n=n*.3333333333333333;m=w?m:n;n=w?q:n;if(t==j){w=s>3]=q;h[b+(w<<4)+8>>3]=o;c[r>>2]=c[v>>2];c[r+4>>2]=c[v+4>>2];c[r+8>>2]=c[v+8>>2];c[r+12>>2]=c[v+12>>2];v=b+(e+2<<4)|0;h[u>>3]=p;h[l>>3]=m;c[v>>2]=c[u>>2];c[v+4>>2]=c[u+4>>2];c[v+8>>2]=c[u+8>>2];c[v+12>>2]=c[u+12>>2];c[f+12>>2]=i;h[f+32>>3]=s;h[f+40>>3]=t;v=16}if((v|0)==16){c[f+8>>2]=g;h[f+16>>3]=k;h[f+24>>3]=j}return}function Rt(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=+d;e=e|0;var f=0.0,g=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0;n=+h[b>>3];k=+h[c>>3]-n;o=+h[b+8>>3];l=+h[c+8>>3]-o;j=d*10.0/(+C(+(k*k+l*l))+.0001);k=j*((k>=0.0?.0001:-.0001)+k);j=((l>=0.0?.0001:-.0001)+l)*j;l=k*.5;m=j*.5;i=n-m;f=o-l;n=m+n;l=o+l;o=i+k;m=f+j;k=n+k;j=l+j;g=o>k?o:k;g=n>g?n:g;d=m>j?m:j;d=l>d?l:d;k=o>3]=i>3]=f>3]=i>g?i:g;h[a+24>>3]=f>d?f:d;return}function St(a,b,d,e,f,g,i){a=a|0;b=b|0;d=d|0;e=e|0;f=+f;g=+g;i=i|0;var j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0.0,s=0.0,t=0.0;q=l;l=l+48|0;m=q+32|0;k=q+16|0;p=q;n=(c[a+16>>2]|0)+12|0;o=c[n>>2]|0;c[n>>2]=b;FD(a,c[(c[a>>2]|0)+336>>2]|0);OD(a,g);t=+h[e>>3]-+h[d>>3];b=e+8|0;s=+h[b>>3]-+h[d+8>>3];r=10.0/(+C(+(t*t+s*s))+.0001);h[e>>3]=r*((t>=0.0?.0001:-.0001)+t);h[b>>3]=((s>=0.0?.0001:-.0001)+s)*r;b=0;while(1){if((b|0)>=4)break;j=i>>(b<<3)&255;if(!j)break;c[k>>2]=c[d>>2];c[k+4>>2]=c[d+4>>2];c[k+8>>2]=c[d+8>>2];c[k+12>>2]=c[d+12>>2];c[m>>2]=c[e>>2];c[m+4>>2]=c[e+4>>2];c[m+8>>2]=c[e+8>>2];c[m+12>>2]=c[e+12>>2];Tt(p,a,k,m,f,g,j);c[d>>2]=c[p>>2];c[d+4>>2]=c[p+4>>2];c[d+8>>2]=c[p+8>>2];c[d+12>>2]=c[p+12>>2];b=b+1|0}c[n>>2]=o;l=q;return}function Tt(a,b,d,e,f,g,i){a=a|0;b=b|0;d=d|0;e=e|0;f=+f;g=+g;i=i|0;var j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0.0;q=l;l=l+32|0;m=q+16|0;k=q;n=i&15;j=1336;while(1){o=c[j>>2]|0;if(!o)break;if((n|0)==(o|0)){p=4;break}j=j+24|0}if((p|0)==4){r=+h[j+8>>3]*f;h[e>>3]=r*+h[e>>3];o=e+8|0;h[o>>3]=r*+h[o>>3];p=c[j+16>>2]|0;c[k>>2]=c[d>>2];c[k+4>>2]=c[d+4>>2];c[k+8>>2]=c[d+8>>2];c[k+12>>2]=c[d+12>>2];c[m>>2]=c[e>>2];c[m+4>>2]=c[e+4>>2];c[m+8>>2]=c[e+8>>2];c[m+12>>2]=c[e+12>>2];jb[p&15](b,k,m,f,g,i);h[d>>3]=+h[e>>3]+ +h[d>>3];p=d+8|0;h[p>>3]=+h[o>>3]+ +h[p>>3]};c[a>>2]=c[d>>2];c[a+4>>2]=c[d+4>>2];c[a+8>>2]=c[d+8>>2];c[a+12>>2]=c[d+12>>2];l=q;return}function Ut(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;i=l;l=l+16|0;g=i+8|0;f=i;d=Im(b,84815)|0;if((d|0)!=0?(a[d>>0]|0)!=0:0){e=d;h=5}else{d=Im(b,84827)|0;if((d|0)!=0?(a[d>>0]|0)!=0:0){e=d;h=5}else d=0}if((h|0)==5){d=vt(e,0,120)|0;if(!d){c[f>>2]=Dn(b)|0;_l(0,84834,f)|0;c[g>>2]=e;_l(3,84887,g)|0}}l=i;return d|0}function Vt(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;g=l;l=l+16|0;f=vw(304)|0;if(!f)_l(1,84895,g)|0;e=a+16|0;a=c[e>>2]|0;c[f>>2]=a;c[e>>2]=f;if(!a){c[f+144>>2]=3;c[f+148>>2]=0;h[f+152>>3]=1.0}else{b=f+16|0;d=a+16|0;e=b+40|0;do{c[b>>2]=c[d>>2];b=b+4|0;d=d+4|0}while((b|0)<(e|0));b=f+56|0;d=a+56|0;e=b+40|0;do{c[b>>2]=c[d>>2];b=b+4|0;d=d+4|0}while((b|0)<(e|0));c[f+144>>2]=c[a+144>>2];c[f+148>>2]=c[a+148>>2];h[f+152>>3]=+h[a+152>>3];c[f+136>>2]=c[a+136>>2];b=f+96|0;d=a+96|0;e=b+40|0;do{c[b>>2]=c[d>>2];b=b+4|0;d=d+4|0}while((b|0)<(e|0))}l=g;return f|0}function Wt(a){a=a|0;var b=0;a=a+16|0;b=c[a>>2]|0;if(!b)ma(84921,84925,117,84932);else{_I(c[b+212>>2]|0);_I(c[b+208>>2]|0);_I(c[b+216>>2]|0);_I(c[b+220>>2]|0);_I(c[b+224>>2]|0);_I(c[b+228>>2]|0);_I(c[b+232>>2]|0);_I(c[b+236>>2]|0);_I(c[b+240>>2]|0);_I(c[b+244>>2]|0);_I(c[b+248>>2]|0);_I(c[b+252>>2]|0);_I(c[b+256>>2]|0);_I(c[b+272>>2]|0);_I(c[b+284>>2]|0);_I(c[b+280>>2]|0);c[a>>2]=c[b>>2];_I(b);return}}function Xt(d,e,f,g,h,i,j){d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;var k=0,l=0;l=c[d+16>>2]|0;k=c[d+152>>2]|0;if((e|0)!=0&(k&32768|0)!=0)c[l+192>>2]=e;if(((k&65536|0)!=0?(c[l+212>>2]=qw(i,j)|0,(f|0)!=0):0)?(a[f>>0]|0)!=0:0){c[l+208>>2]=qw(f,j)|0;d=1}else d=0;do if(k&4194304){if(g|0?a[g>>0]|0:0){c[l+228>>2]=qw(g,j)|0;d=l+260|0;b[d>>1]=b[d>>1]|1;d=1;break}e=c[l+192>>2]|0;if(e){c[l+228>>2]=GL(e)|0;d=1}}while(0);if((h|0)!=0&(k&8388608|0)!=0?(a[h>>0]|0)!=0:0){c[l+244>>2]=qw(h,j)|0;d=1}return d|0}function Yt(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;j=l;l=l+80|0;i=j;h=j+8|0;g=c[(c[b>>2]|0)+168>>2]|0;f=c[(c[(c[g+16>>2]|0)+8>>2]|0)+92>>2]|0;Zt(b,e);b=Im(d,86799)|0;if((b|0)!=0?(a[b>>0]|0)!=0:0){fm(e,b)|0;f=e+4|0;b=c[f>>2]|0;if(b>>>0>=(c[e+8>>2]|0)>>>0){dm(e,1)|0;b=c[f>>2]|0}a[b>>0]=0;b=c[e>>2]|0;c[f>>2]=b}else{if((g|0)!=(d|0)&(f|0)!=0){fm(e,f)|0;f=e+4|0;b=c[f>>2]|0;if(b>>>0>=(c[e+8>>2]|0)>>>0){dm(e,1)|0;b=c[f>>2]|0}c[f>>2]=b+1;a[b>>0]=95}switch(Co(d)|0){case 0:{f=(g|0)==(d|0)?96286:84946;b=(c[d>>2]|0)>>>4;break}case 1:{f=96273;b=(c[d>>2]|0)>>>4;break}case 2:{f=96237;b=(c[d>>2]|0)>>>4;break}default:{f=0;b=0}}fm(e,f)|0;c[i>>2]=b;pL(h,84952,i)|0;fm(e,h)|0;f=e+4|0;b=c[f>>2]|0;if(b>>>0>=(c[e+8>>2]|0)>>>0){dm(e,1)|0;b=c[f>>2]|0}a[b>>0]=0;b=c[e>>2]|0;c[f>>2]=b}l=j;return b|0}function Zt(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;i=l;l=l+144|0;h=i;g=i+8|0;e=c[b+160>>2]|0;if((e|0)>1?c[b+152>>2]&64|0:0){fm(d,c[(c[(c[b>>2]|0)+308>>2]|0)+(e<<2)>>2]|0)|0;f=d+4|0;e=c[f>>2]|0;if(e>>>0>=(c[d+8>>2]|0)>>>0){dm(d,1)|0;e=c[f>>2]|0}c[f>>2]=e+1;a[e>>0]=95}f=c[b+196>>2]|0;e=c[b+200>>2]|0;if((f|0)>0|(e|0)>0){c[h>>2]=f;c[h+4>>2]=e;pL(g,84956,h)|0;fm(d,g)|0}l=i;return}function _t(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0,i=0.0,j=0,k=0.0,m=0.0,n=0,o=0,p=0,q=0,r=0.0,s=0;s=l;l=l+48|0;p=s+16|0;f=s+32|0;q=s;r=+h[(c[a+16>>2]|0)+152>>3];o=$t(d,0,f)|0;if((o+-1|0)>>>0>=2){e=+h[b+16>>3];k=(e+ +h[b>>3])*.5;h[q>>3]=k;i=+h[b+24>>3];m=(i+ +h[b+8>>3])*.5;h[q+8>>3]=m;k=e-k;m=i-m;n=r>.5;if(n)OD(a,.5);j=c[f>>2]|0;i=0.0;f=c[j+8>>2]|0;while(1){d=c[f>>2]|0;if(!d)break;b=f+4|0;if(+g[b>>2]==0.0)e=i;else{DD(a,d);if(!(c[f+12>>2]|0))e=6.283185307179586;else e=+g[b>>2]*6.283185307179586+i;c[p>>2]=c[q>>2];c[p+4>>2]=c[q+4>>2];c[p+8>>2]=c[q+8>>2];c[p+12>>2]=c[q+12>>2];b=_E(p,k,m,i,e)|0;JD(a,c[b>>2]|0,c[b+4>>2]|0,0,0,1);XI(b)}i=e;f=f+12|0}if(n)OD(a,r);au(j)}l=s;return o|0}function $t(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,h=0,i=0,j=0.0,k=0.0,m=0.0,n=0,o=0,p=0,q=0,r=0;r=l;l=l+16|0;o=r+8|0;n=r;q=vw(12)|0;i=GL(b)|0;a:do if(!d){d=1;f=i;while(1){switch(a[f>>0]|0){case 0:break a;case 58:{d=d+1|0;break}default:{}}f=f+1|0}}while(0);c[q+4>>2]=i;p=vw((d*12|0)+12|0)|0;c[q+8>>2]=p;m=1.0;h=0;d=0;f=i;while(1){f=DL(f,93017)|0;if(!f){f=20;break}j=+bu(f);if(!(j>=0.0)){f=17;break}k=j-m;if(k>0.0)if((c[4920]|0)!=0?!(k<1.0e-05&k>-1.0e-05):0){c[n>>2]=b;_l(0,84967,n)|0;c[4920]=0;j=m;d=3}else j=m;k=m-j;if(j>0.0)a[p+(h*12|0)+8>>0]=1;if(a[f>>0]|0)c[p+(h*12|0)>>2]=f;f=h+1|0;g[p+(h*12|0)+4>>2]=j;if(k<1.0e-05&k>-1.0e-05){h=f;f=30;break}else{m=k;h=f;f=0}}b:do if((f|0)==17){if(!(c[4920]|0))d=1;else{c[o>>2]=b;_l(1,85002,o)|0;c[4920]=0;d=2}au(q)}else if((f|0)==20)if(m>0.0){f=0;i=0;while(1){if((f|0)>=(h|0))break;o=i+(+g[p+(f*12|0)+4>>2]==0.0&1)|0;f=f+1|0;i=o}if((i|0)<=0){f=p+((h+-1|0)*12|0)+4|0;g[f>>2]=m+ +g[f>>2];f=30;break}j=m/+(i|0);f=0;while(1){if((f|0)>=(h|0)){f=30;break b}i=p+(f*12|0)+4|0;if(+g[i>>2]==0.0)g[i>>2]=j;f=f+1|0}}else f=30;while(0);if((f|0)==30){while(1){f=h+-1|0;if((h|0)<=0)break;if(+g[p+(f*12|0)+4>>2]>0.0)break;else h=f}c[p+(h*12|0)>>2]=0;c[q>>2]=h;c[e>>2]=q}l=r;return d|0}function au(a){a=a|0;_I(c[a+4>>2]|0);_I(c[a+8>>2]|0);_I(a);return}function bu(b){b=b|0;var d=0.0,e=0,f=0,g=0;f=l;l=l+16|0;e=f;b=WJ(b,59)|0;if(!b)d=0.0;else{g=b+1|0;a[b>>0]=0;d=+tM(g,e);d=(d>=0.0?(c[e>>2]|0)!=(g|0):0)?d:-1.0}l=f;return +d}function cu(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,i=0,j=0,k=0,m=0.0,n=0.0,o=0,p=0,q=0,r=0,s=0.0,t=0;t=l;l=l+80|0;i=t+64|0;r=t;s=+h[(c[a+16>>2]|0)+152>>3];q=$t(d,0,i)|0;if((q+-1|0)>>>0>=2){if(!e){c[r>>2]=c[b>>2];c[r+4>>2]=c[b+4>>2];c[r+8>>2]=c[b+8>>2];c[r+12>>2]=c[b+12>>2];p=r+16|0;o=b+16|0;c[p>>2]=c[o>>2];c[p+4>>2]=c[o+4>>2];c[p+8>>2]=c[o+8>>2];c[p+12>>2]=c[o+12>>2];p=r+32|0;o=b+32|0;c[p>>2]=c[o>>2];c[p+4>>2]=c[o+4>>2];c[p+8>>2]=c[o+8>>2];c[p+12>>2]=c[o+12>>2];p=r+48|0;o=b+48|0;c[p>>2]=c[o>>2];c[p+4>>2]=c[o+4>>2];c[p+8>>2]=c[o+8>>2];c[p+12>>2]=c[o+12>>2]}else{p=b+32|0;c[r>>2]=c[p>>2];c[r+4>>2]=c[p+4>>2];c[r+8>>2]=c[p+8>>2];c[r+12>>2]=c[p+12>>2];p=r+16|0;o=b+48|0;c[p>>2]=c[o>>2];c[p+4>>2]=c[o+4>>2];c[p+8>>2]=c[o+8>>2];c[p+12>>2]=c[o+12>>2];p=r+32|0;c[p>>2]=c[b>>2];c[p+4>>2]=c[b+4>>2];c[p+8>>2]=c[b+8>>2];c[p+12>>2]=c[b+12>>2];p=r+48|0;o=b+16|0;c[p>>2]=c[o>>2];c[p+4>>2]=c[o+4>>2];c[p+8>>2]=c[o+8>>2];c[p+12>>2]=c[o+12>>2]}k=r+16|0;m=+h[k>>3];f=+h[r>>3];n=m-f;o=r+32|0;h[o>>3]=f;h[k>>3]=f;p=s>.5;if(p)OD(a,.5);i=c[i>>2]|0;j=r+48|0;e=c[i+8>>2]|0;while(1){d=c[e>>2]|0;if(!d)break;b=e+4|0;if(!(+g[b>>2]==0.0)){DD(a,d);if(!(c[e+12>>2]|0))f=m;else f=n*+g[b>>2]+ +h[r>>3];h[o>>3]=f;h[k>>3]=f;HD(a,r,4,1);f=+h[k>>3];h[j>>3]=f;h[r>>3]=f}e=e+12|0}if(p)OD(a,s);au(i)}l=t;return q|0}function du(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;d=c[a+16>>2]|0;e=c[a+152>>2]|0;if(e&4259840|0){f=e&131072;g=f>>>16^2;c[d+264>>2]=g;h=d+268|0;c[h>>2]=g+2;g=d+272|0;_I(c[g>>2]|0);d=vw(c[h>>2]<<4)|0;c[g>>2]=d;c[d>>2]=c[b>>2];c[d+4>>2]=c[b+4>>2];c[d+8>>2]=c[b+8>>2];c[d+12>>2]=c[b+12>>2];g=d+16|0;b=b+16|0;c[g>>2]=c[b>>2];c[g+4>>2]=c[b+4>>2];c[g+8>>2]=c[b+8>>2];c[g+12>>2]=c[b+12>>2];if(!(e&8192))fD(a,d,d,2)|0;if(!f)Zv(d)}return}function eu(a,b){a=a|0;b=b|0;var c=0,d=0.0,e=0,f=0,g=0,i=0.0,j=0.0,k=0.0,m=0.0,n=0.0,o=0,p=0,q=0;q=l;l=l+144|0;c=q+80|0;e=q+16|0;f=q;k=+h[b>>3];o=a+16|0;m=+h[o>>3];if(!(((((((((!(k>m)?(n=+h[a>>3],!(k>3],i=+h[a+24>>3],!(d>i)):0)?(j=+h[a+8>>3],!(d>3],!(k>m|k>3],!(k>i|k>3],!(k>m|k>3],!(k>i|k>3],!(k>m|k>3],!(n>i|n>3];if(!(d>+h[o>>3])){if(d<+h[a>>3]){c=a;p=16}}else{c=o;p=16}if((p|0)==16){p=0;h[c>>3]=d}d=+h[b+(e<<4)+8>>3];if(!(d>+h[f>>3])){if(d<+h[g>>3]){c=a;p=19}}else{c=o;p=19}if((p|0)==19){p=0;h[c+8>>3]=d}e=e+1|0}}while(0);l=q;return}function fu(a){a=a|0;var b=0,d=0,e=0,f=0,g=0.0,h=0,i=0;b=l;l=l+48|0;d=b+32|0;e=b+16|0;f=b;i=a+48|0;h=a+16|0;c[f>>2]=c[a>>2];c[f+4>>2]=c[a+4>>2];c[f+8>>2]=c[a+8>>2];c[f+12>>2]=c[a+12>>2];c[e>>2]=c[i>>2];c[e+4>>2]=c[i+4>>2];c[e+8>>2]=c[i+8>>2];c[e+12>>2]=c[i+12>>2];c[d>>2]=c[h>>2];c[d+4>>2]=c[h+4>>2];c[d+8>>2]=c[h+8>>2];c[d+12>>2]=c[h+12>>2];g=+cw(f,e,d);h=a+32|0;c[f>>2]=c[a>>2];c[f+4>>2]=c[a+4>>2];c[f+8>>2]=c[a+8>>2];c[f+12>>2]=c[a+12>>2];c[e>>2]=c[i>>2];c[e+4>>2]=c[i+4>>2];c[e+8>>2]=c[i+8>>2];c[e+12>>2]=c[i+12>>2];c[d>>2]=c[h>>2];c[d+4>>2]=c[h+4>>2];c[d+8>>2]=c[h+8>>2];c[d+12>>2]=c[h+12>>2];a=g<4.0&+cw(f,e,d)<4.0&1;l=b;return a|0}function gu(b,d){b=b|0;d=d|0;var e=0,f=0.0,g=0.0,i=0.0,j=0,k=0,m=0,n=0.0;m=l;l=l+16|0;k=m;j=c[b+152>>2]|0;n=+h[b+432>>3];i=+h[b+352>>3]*.013888888888888888;f=i*n;h[b+488>>3]=f;g=+h[b+440>>3];i=i*g;h[b+496>>3]=i;h[b+520>>3]=n*.013888888888888888;e=b+528|0;h[e>>3]=g*.013888888888888888;if(j&4096|c[42183]|0)h[e>>3]=g*-.013888888888888888;e=(c[b+360>>2]|0)==0;n=+((c[b+448>>2]|0)>>>0);g=+((c[b+452>>2]|0)>>>0);h[b+368>>3]=(e?n:g)/f;h[b+376>>3]=(e?g:n)/i;LD(b,FA(d,ym(d,0,86595,0)|0,174181)|0);c[b+160>>2]=0;hu(b,d);if(j&2|0)iu(b,d);e=co(d)|0;while(1){if(!e)break;a[(c[e+16>>2]|0)+116>>0]=0;e=eo(d,e)|0}ju(b,k);while(1){if(!((ku(b)|0)<<24>>24))break;if((lu(b)|0)>1)kD(b);mu(b);while(1){if(!((nu(b)|0)<<24>>24))break;ou(b,d);pu(b)}if((lu(b)|0)>1)lD(b);qu(b,k)}ru(b);l=m;return}function hu(a,b){a=a|0;b=b|0;var d=0;d=Vt(a)|0;c[d+4>>2]=0;c[d+8>>2]=b;c[d+12>>2]=0;qv(a,c[(c[b+16>>2]|0)+12>>2]|0,b);gD(a,b);return}function iu(b,c){b=b|0;c=c|0;var d=0,e=0,f=0,g=0;DD(b,119592);d=Im(c,85423)|0;if(d|0?a[d>>0]|0:0)DD(b,d);d=Im(c,86503)|0;if(d|0?a[d>>0]|0:0)BD(b,d);Cv(b,c);g=co(c)|0;while(1){if(!g)break;d=Im(g,122540)|0;if(d|0?a[d>>0]|0:0)BD(b,d);d=Im(g,122531)|0;if(d|0?a[d>>0]|0:0)DD(b,d);d=Im(g,86469)|0;do if(d|0?a[d>>0]|0:0){if(!(WJ(d,58)|0)){BD(b,d);break}e=GL(d)|0;d=e;while(1){d=DL(d,93017)|0;if(!d)break;if(!(a[d>>0]|0)){d=0;continue}BD(b,d);d=0}_I(e)}while(0);d=Im(g,86503)|0;if(d|0?a[d>>0]|0:0)BD(b,d);f=Pm(c,g)|0;while(1){if(!f)break;d=Im(f,122540)|0;do if(d|0?a[d>>0]|0:0){if(!(WJ(d,58)|0)){BD(b,d);break}e=GL(d)|0;d=e;while(1){d=DL(d,93017)|0;if(!d)break;if(!(a[d>>0]|0)){d=0;continue}BD(b,d);d=0}_I(e)}while(0);d=Im(f,86503)|0;if(d|0?a[d>>0]|0:0)BD(b,d);f=Rm(c,f)|0}g=eo(c,g)|0}return}function ju(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;i=l;l=l+16|0;e=i+8|0;g=i;h=c[a>>2]|0;d=c[h+312>>2]|0;f=a+156|0;c[f>>2]=d;h=c[h+316>>2]|0;if(!h)if((d|0)>1?(c[a+152>>2]&64|0)==0:0){c[e>>2]=c[a+52>>2];_l(0,85598,e)|0;c[f>>2]=1;e=1;d=0}else{e=1;d=0}else{d=h+4|0;if((c[h>>2]|0)>1?(c[a+152>>2]&64|0)==0:0){c[g>>2]=c[a+52>>2];_l(0,85598,g)|0;c[h+8>>2]=(c[f>>2]|0)+1}e=c[d>>2]|0;d=h+8|0}c[a+160>>2]=e;c[b>>2]=d;l=i;return}function ku(a){a=a|0;return (c[a+160>>2]|0)<=(c[a+156>>2]|0)|0}function lu(a){a=a|0;var b=0;b=c[(c[a>>2]|0)+316>>2]|0;return c[((b|0)==0?a+156|0:b)>>2]|0}function mu(a){a=a|0;var b=0,d=0;d=a+172|0;b=c[d+4>>2]|0;a=a+196|0;c[a>>2]=c[d>>2];c[a+4>>2]=b;return}function nu(a){a=a|0;var b=0,d=0;d=c[a+196>>2]|0;if(((d|0)>-1?(d|0)<(c[a+164>>2]|0):0)?(b=c[a+200>>2]|0,(b|0)>-1):0)a=(b|0)<(c[a+168>>2]|0)&1;else a=0;return a|0}function ou(d,e){d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0;p=l;l=l+176|0;k=p;f=p+48|0;m=p+32|0;n=c[d+16>>2]|0;o=c[d+152>>2]|0;if((c[d+160>>2]|0)<=1?(c[d+196>>2]|0)<=0:0)h=0;else{cm(m,128,f);g=n+212|0;h=c[g>>2]|0;Zt(d,m);fm(m,h)|0;i=m+4|0;f=c[i>>2]|0;if(f>>>0>=(c[m+8>>2]|0)>>>0){dm(m,1)|0;f=c[i>>2]|0}a[f>>0]=0;f=c[m>>2]|0;c[i>>2]=f;c[g>>2]=f}ZE(Im(e,85048)|0);tu(d);iD(d);BD(d,122106);DD(d,119592);do if(o&4259840|0){if((c[n+208>>2]|0)==0?(b[n+260>>1]&1)==0:0)break;if(o&655360){i=o&131072;c[n+264>>2]=i>>>16^2;f=vw((i>>>12^32)+32|0)|0;g=d+288|0;c[f>>2]=c[g>>2];c[f+4>>2]=c[g+4>>2];c[f+8>>2]=c[g+8>>2];c[f+12>>2]=c[g+12>>2];g=f+16|0;q=d+304|0;c[g>>2]=c[q>>2];c[g+4>>2]=c[q+4>>2];c[g+8>>2]=c[q+8>>2];c[g+12>>2]=c[q+12>>2];if(!i){Zv(f);g=4}else g=2}else{f=0;g=0}if(!(o&8192))fD(d,f,f,g)|0;c[n+272>>2]=f;c[n+268>>2]=g}while(0);if(o&32768|0?(j=c[(c[e+16>>2]|0)+12>>2]|0,j|0):0)c[n+192>>2]=c[j>>2];g=(o&4|0)!=0;do if(!g){f=n+208|0;if((c[f>>2]|0)==0?(b[n+260>>1]&1)==0:0)break;q=d+256|0;c[k>>2]=c[q>>2];c[k+4>>2]=c[q+4>>2];c[k+8>>2]=c[q+8>>2];c[k+12>>2]=c[q+12>>2];c[k+16>>2]=c[q+16>>2];c[k+20>>2]=c[q+20>>2];c[k+24>>2]=c[q+24>>2];c[k+28>>2]=c[q+28>>2];du(d,k);wD(d,c[f>>2]|0,c[n+228>>2]|0,c[n+244>>2]|0,c[n+212>>2]|0)}while(0);uu(d,e);f=c[(c[e+16>>2]|0)+12>>2]|0;if(f|0)pw(d,4,f);do if(!g){if((c[n+208>>2]|0)==0?(b[n+260>>1]&1)==0:0)break;xD(d)}while(0);vu(d,e,o);jD(d);if(h|0){gm(m);c[n+212>>2]=h}l=p;return}function pu(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;h=l;l=l+32|0;d=h+24|0;b=h+16|0;j=h+8|0;f=h;g=a+196|0;i=a+188|0;c[b>>2]=c[g>>2];c[b+4>>2]=c[g+4>>2];c[d>>2]=c[i>>2];c[d+4>>2]=c[i+4>>2];su(j,b,d);i=c[j+4>>2]|0;e=g;c[e>>2]=c[j>>2];c[e+4>>2]=i;if(!((nu(a)|0)<<24>>24)){e=a+180|0;if(!(c[a+184>>2]|0))c[a+200>>2]=c[a+176>>2];else c[g>>2]=c[a+172>>2];c[b>>2]=c[g>>2];c[b+4>>2]=c[g+4>>2];c[d>>2]=c[e>>2];c[d+4>>2]=c[e+4>>2];su(f,b,d);i=c[f+4>>2]|0;j=g;c[j>>2]=c[f>>2];c[j+4>>2]=i}l=h;return}function qu(a,b){a=a|0;b=b|0;var d=0;d=c[b>>2]|0;if(!d){d=a+160|0;c[d>>2]=(c[d>>2]|0)+1}else{c[a+160>>2]=c[d>>2];c[b>>2]=d+4}return}function ru(a){a=a|0;hD(a);Wt(a);return}function su(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=(c[d+4>>2]|0)+(c[b+4>>2]|0)|0;c[a>>2]=(c[d>>2]|0)+(c[b>>2]|0);c[a+4>>2]=e;return}function tu(a){a=a|0;var b=0.0,d=0.0,e=0.0,f=0,g=0.0,i=0,j=0,k=0,m=0,n=0,o=0.0,p=0,q=0,r=0,s=0,t=0,u=0.0;t=l;l=l+48|0;n=t+32|0;f=t+24|0;j=t+8|0;k=t+16|0;m=t;r=a+196|0;q=c[r>>2]|0;r=c[r+4>>2]|0;p=f;c[p>>2]=q;c[p+4>>2]=r;p=a+164|0;i=c[p>>2]|0;p=c[p+4>>2]|0;s=j;c[s>>2]=i;c[s+4>>2]=p;s=a+360|0;if(!(c[s>>2]|0)){k=q;j=r}else{c[n>>2]=c[f>>2];c[n+4>>2]=c[f+4>>2];Bv(k,n);r=k;k=c[r>>2]|0;r=c[r+4>>2]|0;p=f;c[p>>2]=k;c[p+4>>2]=r;c[n>>2]=c[j>>2];c[n+4>>2]=c[j+4>>2];Bv(m,n);p=m;i=c[p>>2]|0;p=c[p+4>>2]|0;c[j>>2]=i;c[j+4>>2]=p;j=r}d=+h[a+320>>3];g=d*+(k|0)-+h[a+240>>3];h[a+288>>3]=g;e=+h[a+328>>3];o=e*+(j|0)-+h[a+248>>3];h[a+296>>3]=o;h[a+304>>3]=d+g;h[a+312>>3]=e+o;f=a+472|0;if(!(c[(c[a+12>>2]|0)+28>>2]|0)){r=a+456|0;c[f>>2]=c[r>>2];c[f+4>>2]=c[r+4>>2];c[f+8>>2]=c[r+8>>2];c[f+12>>2]=c[r+12>>2]}else{q=a+456|0;c[f>>2]=c[((c[f>>2]|0)<(c[q>>2]|0)?f:q)>>2];r=a+476|0;c[r>>2]=c[((c[r>>2]|0)<(c[a+460>>2]|0)?f:q)+4>>2];r=a+480|0;c[r>>2]=c[((c[r>>2]|0)>(c[a+464>>2]|0)?f:q)+8>>2];r=a+484|0;c[r>>2]=c[((c[r>>2]|0)>(c[a+468>>2]|0)?f:q)+12>>2]}m=c[a+152>>2]|0;b=+h[a+336>>3];if(!(m&128)){b=(+(k|0)-+(i|0)*.5)*d+b;h[a+256>>3]=b;g=(+(j|0)-+(p|0)*.5)*e+ +h[a+344>>3];o=g;d=d+b;g=g+e}else{d=+h[a+368>>3]*.5;e=b-d;h[a+256>>3]=e;g=+h[a+344>>3];u=+h[a+376>>3]*.5;o=g-u;d=d+b;g=u+g;b=e}h[a+264>>3]=o;h[a+272>>3]=d;h[a+280>>3]=g;if(!(c[s>>2]|0)){e=+h[a+352>>3];h[a+504>>3]=+h[a+384>>3]/e-b;if(!(m&4096|c[42183])){d=+h[a+392>>3]/e;b=o}else{d=-g;b=+h[a+392>>3]/e}h[a+512>>3]=d-b}else{f=a+384|0;e=+h[a+352>>3];h[a+512>>3]=-g-+h[a+392>>3]/e;if(!(m&4096|c[42183]))d=+h[f>>3]/e;else{d=-d;b=+h[f>>3]/e}h[a+504>>3]=d-b}l=t;return}function uu(b,d){b=b|0;d=d|0;var e=0,f=0.0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;s=l;l=l+48|0;q=s;o=s+40|0;p=s+36|0;r=s+32|0;e=Im(d,85423)|0;if(!e){j=1;e=121990}else{i=(a[e>>0]|0)==0;j=i&1;e=i?121990:e}h=c[b+152>>2]|0;i=(a[e>>0]|0)==116;if(!(h&256))if(i){m=(xJ(e,122171)|0)==0;k=m?121990:e;m=m?1:j;n=8}else{k=e;m=j;n=8}else if(!(i?!(xJ(e,122171)|0):0)){k=e;m=j;n=8}if((n|0)==8?!((m|0)!=0&(h&33554432|0)!=0):0)if(!((xv(k,o,p)|0)<<24>>24)){DD(b,k);BD(b,122171);r=b+256|0;c[q>>2]=c[r>>2];c[q+4>>2]=c[r+4>>2];c[q+8>>2]=c[r+8>>2];c[q+12>>2]=c[r+12>>2];c[q+16>>2]=c[r+16>>2];c[q+20>>2]=c[r+20>>2];c[q+24>>2]=c[r+24>>2];c[q+28>>2]=c[r+28>>2];ID(b,q,1)}else{c[r>>2]=0;i=c[o>>2]|0;DD(b,i);BD(b,122171);wv(d,r)|0;e=c[o+4>>2]|0;h=DA(d,c[42187]|0,0,0)|0;f=+g[p>>2];if(!e)ED(b,122106,h,f);else ED(b,e,h,f);r=(c[r>>2]|0)>>>1&1|2;p=b+256|0;c[q>>2]=c[p>>2];c[q+4>>2]=c[p+4>>2];c[q+8>>2]=c[p+8>>2];c[q+12>>2]=c[p+12>>2];c[q+16>>2]=c[p+16>>2];c[q+20>>2]=c[p+20>>2];c[q+24>>2]=c[p+24>>2];c[q+28>>2]=c[p+28>>2];ID(b,q,r);_I(i)}e=c[(c[(c[d+16>>2]|0)+8>>2]|0)+88>>2]|0;if(e|0)zv(b,e);l=s;return}function vu(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;g=(c[a>>2]|0)+28|0;c[g>>2]=(c[g>>2]|0)+1;g=(d&4|0)!=0;if(!g)wu(a,b,d);a:do if(!(d&1)){if(d&16|0){qD(a);f=co(b)|0;while(1){if(!f)break;e=Pm(b,f)|0;while(1){if(!e)break;yu(a,e);e=Rm(b,e)|0}f=eo(b,f)|0}rD(a);oD(a);e=co(b)|0;while(1){if(!e)break;xu(a,e);e=eo(b,e)|0}pD(a);break}if(!(d&8)){f=co(b)|0;while(1){if(!f)break a;xu(a,f);e=Pm(b,f)|0;while(1){if(!e)break;xu(a,c[((c[e>>2]&3|0)==2?e:e+-48|0)+40>>2]|0);yu(a,e);e=Rm(b,e)|0}f=eo(b,f)|0}}oD(a);e=co(b)|0;while(1){if(!e)break;if((zu(b,e)|0)<<24>>24)xu(a,e);e=eo(b,e)|0}pD(a);qD(a);f=co(b)|0;while(1){if(!f)break;e=Pm(b,f)|0;while(1){if(!e)break;if((Au(b,e)|0)<<24>>24)yu(a,e);e=Rm(b,e)|0}f=eo(b,f)|0}rD(a)}else{oD(a);e=co(b)|0;while(1){if(!e)break;xu(a,e);e=eo(b,e)|0}pD(a);qD(a);f=co(b)|0;while(1){if(!f)break;e=Pm(b,f)|0;while(1){if(!e)break;yu(a,e);e=Rm(b,e)|0}f=eo(b,f)|0}rD(a)}while(0);if(g)wu(a,b,d);return}function wu(e,f,i){e=e|0;f=f|0;i=i|0;var j=0,k=0,m=0,n=0,o=0.0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0;P=l;l=l+128|0;w=P+72|0;N=P+64|0;H=P+112|0;I=P;J=P+104|0;K=f+16|0;L=(i&4|0)!=0;M=e+16|0;x=I+32|0;y=I+16|0;A=I+8|0;B=I+24|0;C=I+48|0;D=I+40|0;E=I+56|0;F=(i&8|0)==0;G=J+4|0;v=1;while(1){j=c[K>>2]|0;if((v|0)>(c[j+180>>2]|0))break;u=c[(c[j+184>>2]|0)+(v<<2)>>2]|0;if((uv(e,u)|0)<<24>>24){if(L)wu(e,u,i);vv(e,u);r=c[M>>2]|0;s=r+208|0;if(!(c[s>>2]|0))t=(b[r+260>>1]&1)!=0;else t=1;ZE(Im(u,85048)|0);if(!(L|t^1)){q=(c[u+16>>2]|0)+16|0;c[w>>2]=c[q>>2];c[w+4>>2]=c[q+4>>2];c[w+8>>2]=c[q+8>>2];c[w+12>>2]=c[q+12>>2];c[w+16>>2]=c[q+16>>2];c[w+20>>2]=c[q+20>>2];c[w+24>>2]=c[q+24>>2];c[w+28>>2]=c[q+28>>2];du(e,w);wD(e,c[s>>2]|0,c[r+228>>2]|0,c[r+244>>2]|0,c[r+212>>2]|0)}c[H>>2]=0;j=wv(u,H)|0;if(!j)p=0;else{FD(e,j);p=c[H>>2]&1}q=u+16|0;j=d[(c[q>>2]|0)+112>>0]|0;do if(!(j&1)){if(j&2|0){j=GA(u,0,91300)|0;k=GA(u,0,91308)|0;O=29;break}if(j&8|0){j=GA(u,0,91316)|0;k=GA(u,0,91324)|0;O=29;break}if(j&4|0){j=GA(u,0,91332)|0;k=GA(u,0,91340)|0;O=29;break}j=Im(u,122540)|0;if(!j)k=0;else k=(a[j>>0]|0)==0?0:j;j=Im(u,122531)|0;if(!j)j=k;else j=(a[j>>0]|0)==0?k:j;m=Im(u,86469)|0;if(m)k=(a[m>>0]|0)==0?k:m;if(!((p|0)!=0&(k|0)!=0)){m=Im(u,85423)|0;if(m|0?a[m>>0]|0:0){k=m;O=29;break}j=(j|0)==0?122106:j;n=(k|0)==0?119592:k;c[J>>2]=0;if(!p)k=0;else O=31}else O=29}else{j=GA(u,0,91284)|0;k=GA(u,0,91292)|0;O=29}while(0);if((O|0)==29){c[J>>2]=0;j=(j|0)==0?122106:j;n=(k|0)==0?119592:k;O=31}if((O|0)==31){O=0;if(!((xv(n,J,w)|0)<<24>>24)){DD(e,n);k=1}else{DD(e,c[J>>2]|0);k=c[G>>2]|0;m=DA(u,c[42187]|0,0,0)|0;o=+g[w>>2];if(!k)ED(e,122106,m,o);else ED(e,k,m,o);k=(c[H>>2]|0)>>>1&1|2}}m=c[42186]|0;if((m|0?(z=Jm(u,m)|0,z|0):0)?a[z>>0]|0:0)OD(e,+EA(u,c[42186]|0,1.0,0.0));p=c[H>>2]|0;do if(p&4){m=DA(u,c[42185]|0,1,0)|0;if(m|k|0){n=c[q>>2]|0;Q=n+16|0;c[I>>2]=c[Q>>2];c[I+4>>2]=c[Q+4>>2];c[I+8>>2]=c[Q+8>>2];c[I+12>>2]=c[Q+12>>2];n=n+32|0;c[x>>2]=c[n>>2];c[x+4>>2]=c[n+4>>2];c[x+8>>2]=c[n+8>>2];c[x+12>>2]=c[n+12>>2];h[y>>3]=+h[x>>3];h[B>>3]=+h[A>>3];h[C>>3]=+h[I>>3];h[E>>3]=+h[D>>3];if(!m)BD(e,122171);else BD(e,j);yy(e,I,4,p,k)}}else{if(!(p&64)){if(DA(u,c[42185]|0,1,0)|0){BD(e,j);Q=(c[q>>2]|0)+16|0;c[w>>2]=c[Q>>2];c[w+4>>2]=c[Q+4>>2];c[w+8>>2]=c[Q+8>>2];c[w+12>>2]=c[Q+12>>2];c[w+16>>2]=c[Q+16>>2];c[w+20>>2]=c[Q+20>>2];c[w+24>>2]=c[Q+24>>2];c[w+28>>2]=c[Q+28>>2];ID(e,w,k);break}if(!k)break;BD(e,122171);Q=(c[q>>2]|0)+16|0;c[w>>2]=c[Q>>2];c[w+4>>2]=c[Q+4>>2];c[w+8>>2]=c[Q+8>>2];c[w+12>>2]=c[Q+12>>2];c[w+16>>2]=c[Q+16>>2];c[w+20>>2]=c[Q+20>>2];c[w+24>>2]=c[Q+24>>2];c[w+28>>2]=c[Q+28>>2];ID(e,w,k);break}Q=c[q>>2]|0;p=Q+16|0;c[I>>2]=c[p>>2];c[I+4>>2]=c[p+4>>2];c[I+8>>2]=c[p+8>>2];c[I+12>>2]=c[p+12>>2];Q=Q+32|0;c[x>>2]=c[Q>>2];c[x+4>>2]=c[Q+4>>2];c[x+8>>2]=c[Q+8>>2];c[x+12>>2]=c[Q+12>>2];h[y>>3]=+h[x>>3];h[B>>3]=+h[A>>3];h[C>>3]=+h[I>>3];h[E>>3]=+h[D>>3];if(!(DA(u,c[42185]|0,1,0)|0))BD(e,122171);else BD(e,j);if((cu(e,I,n,0)|0)>1){c[N>>2]=Dn(u)|0;_l(3,85431,N)|0}Q=(c[q>>2]|0)+16|0;c[w>>2]=c[Q>>2];c[w+4>>2]=c[Q+4>>2];c[w+8>>2]=c[Q+8>>2];c[w+12>>2]=c[Q+12>>2];c[w+16>>2]=c[Q+16>>2];c[w+20>>2]=c[Q+20>>2];c[w+24>>2]=c[Q+24>>2];c[w+28>>2]=c[Q+28>>2];ID(e,w,0)}while(0);_I(c[J>>2]|0);j=c[(c[q>>2]|0)+12>>2]|0;if(j|0)pw(e,5,j);if(t){if(L){Q=(c[q>>2]|0)+16|0;c[w>>2]=c[Q>>2];c[w+4>>2]=c[Q+4>>2];c[w+8>>2]=c[Q+8>>2];c[w+12>>2]=c[Q+12>>2];c[w+16>>2]=c[Q+16>>2];c[w+20>>2]=c[Q+20>>2];c[w+24>>2]=c[Q+24>>2];c[w+28>>2]=c[Q+28>>2];du(e,w);wD(e,c[s>>2]|0,c[r+228>>2]|0,c[r+244>>2]|0,c[r+212>>2]|0)}xD(e)}a:do if(!F){k=co(u)|0;while(1){if(!k)break a;xu(e,k);j=Pm(u,k)|0;while(1){if(!j)break;yu(e,j);j=Rm(u,j)|0}k=eo(u,k)|0}}while(0);yv(e,f);if(!L)wu(e,u,i)}v=v+1|0}l=P;return}function xu(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0;j=l;l=l+32|0;e=j;h=c[b>>2]|0;i=d+16|0;a:do if(((c[(c[i>>2]|0)+8>>2]|0?(mv(b,ro(d)|0,d)|0)<<24>>24:0)?(k=b+256|0,c[e>>2]=c[k>>2],c[e+4>>2]=c[k+4>>2],c[e+8>>2]=c[k+8>>2],c[e+12>>2]=c[k+12>>2],c[e+16>>2]=c[k+16>>2],c[e+20>>2]=c[k+20>>2],c[e+24>>2]=c[k+24>>2],c[e+28>>2]=c[k+28>>2],(nv(d,e)|0)<<24>>24):0)?(f=(c[i>>2]|0)+116|0,g=c[h+28>>2]|0,(g|0)!=(a[f>>0]|0)):0){a[f>>0]=g;LD(b,Dn(d)|0);e=FA(d,c[42213]|0,174181)|0;if(a[e>>0]|0)LD(b,e);e=FA(d,c[42201]|0,174181)|0;b:do if(a[e>>0]|0){Du(e)|0;e=168408;while(1){f=e;e=e+4|0;f=c[f>>2]|0;if(!f)break b;if((a[f>>0]|0)!=105)continue;if(!(xJ(f,119127)|0))break a}}while(0);ov(b,d);hb[c[(c[(c[(c[i>>2]|0)+8>>2]|0)+4>>2]|0)+20>>2]&31](b,d);e=c[(c[i>>2]|0)+108>>2]|0;if(e|0?a[e+81>>0]|0:0)pw(b,10,e);pv(b)}while(0);l=j;return}function yu(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;h=l;l=l+32|0;g=h;e=b+256|0;c[g>>2]=c[e>>2];c[g+4>>2]=c[e+4>>2];c[g+8>>2]=c[e+8>>2];c[g+12>>2]=c[e+12>>2];c[g+16>>2]=c[e+16>>2];c[g+20>>2]=c[e+20>>2];c[g+24>>2]=c[e+24>>2];c[g+28>>2]=c[e+28>>2];a:do if((Bu(d,g)|0)<<24>>24?(f=d+-48|0,(Cu(b,d)|0)<<24>>24):0){i=d+48|0;e=rJ(Dn(c[((c[d>>2]&3|0)==3?d:i)+40>>2]|0)|0)|0;e=ZI(e+3+(rJ(Dn(c[((c[d>>2]&3|0)==2?d:f)+40>>2]|0)|0)|0)|0)|0;xK(e,Dn(c[((c[d>>2]&3|0)==3?d:i)+40>>2]|0)|0)|0;i=(qn(ro(c[((c[d>>2]&3|0)==2?d:f)+40>>2]|0)|0)|0)==0;g=e+(rJ(e)|0)|0;if(i){a[g>>0]=a[122549]|0;a[g+1>>0]=a[122550]|0;a[g+2>>0]=a[122551]|0}else{a[g>>0]=a[122546]|0;a[g+1>>0]=a[122547]|0;a[g+2>>0]=a[122548]|0}IL(e,Dn(c[((c[d>>2]&3|0)==2?d:f)+40>>2]|0)|0)|0;LD(b,e);_I(e);e=FA(d,c[42235]|0,174181)|0;if(a[e>>0]|0)LD(b,e);e=FA(d,c[42229]|0,174181)|0;b:do if(!(a[e>>0]|0))e=0;else{Du(e)|0;e=168408;while(1){f=e;e=e+4|0;f=c[f>>2]|0;if(!f){e=168408;break b}if((a[f>>0]|0)!=105)continue;if(!(xJ(f,119127)|0))break a}}while(0);Eu(b,d,e);Fu(b,d,e);Gu(b)}while(0);l=h;return}function zu(a,b){a=a|0;b=b|0;var d=0,e=0;d=a+16|0;a=1;while(1){e=c[d>>2]|0;if((a|0)>(c[e+180>>2]|0)){a=1;break}if(!(Bo(c[(c[e+184>>2]|0)+(a<<2)>>2]|0,b)|0))a=a+1|0;else{a=0;break}}return a|0}function Au(a,b){a=a|0;b=b|0;var d=0,e=0;d=a+16|0;a=1;while(1){e=c[d>>2]|0;if((a|0)>(c[e+180>>2]|0)){a=1;break}if(!(Bo(c[(c[e+184>>2]|0)+(a<<2)>>2]|0,b)|0))a=a+1|0;else{a=0;break}}return a|0}function Bu(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;j=l;l=l+64|0;i=j+32|0;f=j;g=b+16|0;b=c[g>>2]|0;e=c[b+8>>2]|0;if((e|0)!=0?(e=e+8|0,c[f>>2]=c[e>>2],c[f+4>>2]=c[e+4>>2],c[f+8>>2]=c[e+8>>2],c[f+12>>2]=c[e+12>>2],c[f+16>>2]=c[e+16>>2],c[f+20>>2]=c[e+20>>2],c[f+24>>2]=c[e+24>>2],c[f+28>>2]=c[e+28>>2],c[i>>2]=c[d>>2],c[i+4>>2]=c[d+4>>2],c[i+8>>2]=c[d+8>>2],c[i+12>>2]=c[d+12>>2],c[i+16>>2]=c[d+16>>2],c[i+20>>2]=c[d+20>>2],c[i+24>>2]=c[d+24>>2],c[i+28>>2]=c[d+28>>2],(lv(f,i)|0)!=0):0)b=1;else h=3;do if((h|0)==3){e=c[b+96>>2]|0;if(e){c[i>>2]=c[d>>2];c[i+4>>2]=c[d+4>>2];c[i+8>>2]=c[d+8>>2];c[i+12>>2]=c[d+12>>2];c[i+16>>2]=c[d+16>>2];c[i+20>>2]=c[d+20>>2];c[i+24>>2]=c[d+24>>2];c[i+28>>2]=c[d+28>>2];if((CB(e,i)|0)<<24>>24){b=1;break}b=c[g>>2]|0}b=c[b+108>>2]|0;if((b|0?a[b+81>>0]|0:0)?(c[i>>2]=c[d>>2],c[i+4>>2]=c[d+4>>2],c[i+8>>2]=c[d+8>>2],c[i+12>>2]=c[d+12>>2],c[i+16>>2]=c[d+16>>2],c[i+20>>2]=c[d+20>>2],c[i+24>>2]=c[d+24>>2],c[i+28>>2]=c[d+28>>2],(CB(b,i)|0)<<24>>24):0){b=1;break}b=0}while(0);l=j;return b|0}function Cu(b,d){b=b|0;d=d|0;var e=0,f=0;a:do if((c[b+156>>2]|0)>=2?(e=FA(d,c[42234]|0,174181)|0,(hv(b,e)|0)<<24>>24==0):0)if(!(a[e>>0]|0)){e=0;while(1){if((e|0)>=2){e=0;break a}f=(e|0)==1;f=FA(c[((c[d>>2]&3|0)==((f?2:3)|0)?d:d+((f?-1:1)*48|0)|0)+40>>2]|0,c[42211]|0,174181)|0;if(!(a[f>>0]|0)){e=1;break a}if(!((hv(b,f)|0)<<24>>24))e=e+1|0;else{e=1;break}}}else e=0;else e=1;while(0);return e|0}function Du(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0;p=l;l=l+192|0;o=p+24|0;n=p+16|0;m=p+8|0;k=p;g=p+48|0;j=p+32|0;if(a[85305]|0){cm(168672,128,173948);a[85305]=0}cm(j,128,p+56|0);c[g>>2]=b;h=j+4|0;i=j+8|0;d=0;e=0;a:while(1){f=d;b:while(1)switch(fv(g,j)|0){case 0:{d=21;break a}case 40:if(!(f<<24>>24)){f=1;continue b}else{d=7;break a}case 41:if(!(f<<24>>24)){d=9;break a}else{f=0;continue b}default:break b}if(!(f<<24>>24)){if((e|0)==63){d=12;break}d=c[42169]|0;if(d>>>0>=(c[42170]|0)>>>0){dm(168672,1)|0;d=c[42169]|0}c[42169]=d+1;a[d>>0]=0;c[168408+(e<<2)>>2]=c[42169];e=e+1|0}d=c[h>>2]|0;if(d>>>0>=(c[i>>2]|0)>>>0){dm(j,1)|0;d=c[h>>2]|0}a[d>>0]=0;d=c[j>>2]|0;c[h>>2]=d;fm(168672,d)|0;d=c[42169]|0;if(d>>>0>=(c[42170]|0)>>>0){dm(168672,1)|0;d=c[42169]|0}c[42169]=d+1;a[d>>0]=0;d=f}do if((d|0)==7){c[k>>2]=b;_l(1,85306,k)|0;c[42102]=0;gm(j)}else if((d|0)==9){c[m>>2]=b;_l(1,85340,m)|0;c[42102]=0;gm(j)}else if((d|0)==12){c[n>>2]=b;_l(0,85368,n)|0;c[42165]=0;gm(j)}else if((d|0)==21){if(f<<24>>24){c[o>>2]=b;_l(1,85391,o)|0;c[42102]=0;gm(j);break}c[168408+(e<<2)>>2]=0;gm(j);d=c[42169]|0;if(d>>>0>=(c[42170]|0)>>>0){dm(168672,1)|0;d=c[42169]|0}a[d>>0]=0;c[42169]=c[42168]}while(0);l=p;return 168408}function Eu(d,f,g){d=d|0;f=f|0;g=g|0;var i=0,j=0,k=0,m=0.0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0;A=l;l=l+160|0;y=A+24|0;w=A+20|0;v=A+16|0;o=A;p=A+32|0;x=c[d+152>>2]|0;c[y>>2]=0;c[w>>2]=0;c[v>>2]=0;z=Vt(d)|0;c[z+4>>2]=3;c[z+8>>2]=f;c[z+12>>2]=9;t=f+16|0;n=c[(c[t>>2]|0)+96>>2]|0;if((n|0?(a[n+82>>0]|0)==0:0)?(JA(Im(f,85121)|0,0)|0)<<24>>24:0){n=z+260|0;b[n>>1]=b[n>>1]|512}if(g|0?c[(c[t>>2]|0)+8>>2]|0:0)FD(d,g);g=c[42250]|0;if((g|0?(i=Jm(f,g)|0,i|0):0)?a[i>>0]|0:0)OD(d,+EA(f,c[42250]|0,1.0,0.0));do if(x&16777216|0){g=f+48|0;if((e[(c[(ro(c[((c[f>>2]&3|0)==3?f:g)+40>>2]|0)|0)+16>>2]|0)+178>>1]|0)>2){m=+h[(c[(c[(c[((c[f>>2]&3|0)==3?f:g)+40>>2]|0)+16>>2]|0)+132>>2]|0)+16>>3]*72.0;h[z+176>>3]=+(~~(m+(m>=0.0?.5:-.5))|0);m=+h[(c[(c[(c[((c[f>>2]&3|0)==2?f:f+-48|0)+40>>2]|0)+16>>2]|0)+132>>2]|0)+16>>3]*72.0;h[z+184>>3]=+(~~(m+(m>=0.0?.5:-.5))|0);break}else{n=z+176|0;c[n>>2]=0;c[n+4>>2]=0;c[n+8>>2]=0;c[n+12>>2]=0;break}}while(0);if(x&32768|0){n=c[t>>2]|0;g=c[n+96>>2]|0;if(!g)g=c[z+192>>2]|0;else{g=c[g>>2]|0;c[z+192>>2]=g}i=z+196|0;c[i>>2]=g;k=z+204|0;c[k>>2]=g;j=z+200|0;c[j>>2]=g;g=c[n+108>>2]|0;if(g|0)c[i>>2]=c[g>>2];g=c[n+104>>2]|0;if(g|0)c[j>>2]=c[g>>2];g=c[n+100>>2]|0;if(g|0)c[k>>2]=c[g>>2]}if(!(x&65536))j=0;else{cm(o,128,p);c[z+212>>2]=qw(Yt(d,f,o)|0,f)|0;gm(o);g=Im(f,96264)|0;if((g|0)!=0?(a[g>>0]|0)!=0:0)q=31;else{g=Im(f,96269)|0;if((g|0)!=0?(a[g>>0]|0)!=0:0)q=31;else i=0}if((q|0)==31)i=qw(g,f)|0;g=Im(f,85134)|0;if((g|0)!=0?(a[g>>0]|0)!=0:0)q=36;else q=34;do if((q|0)==34){g=Im(f,85143)|0;if(g|0?a[g>>0]|0:0){q=36;break}if(i|0){g=GL(i)|0;q=39}}while(0);if((q|0)==36){g=qw(g,f)|0;q=39}if((q|0)==39)c[z+208>>2]=g;g=Im(f,85151)|0;if((g|0)!=0?(a[g>>0]|0)!=0:0)q=44;else q=42;do if((q|0)==42){g=Im(f,85161)|0;if(g|0?a[g>>0]|0:0){q=44;break}if(i|0){g=GL(i)|0;q=47}}while(0);if((q|0)==44){g=qw(g,f)|0;q=47}if((q|0)==47)c[z+216>>2]=g;g=Im(f,85170)|0;if((g|0)!=0?(a[g>>0]|0)!=0:0)q=52;else q=50;do if((q|0)==50){g=Im(f,85179)|0;if(g|0?a[g>>0]|0:0){q=52;break}if(i|0)c[z+220>>2]=GL(i)|0}while(0);if((q|0)==52){c[z+220>>2]=qw(g,f)|0;q=z+260|0;b[q>>1]=b[q>>1]|128}g=Im(f,85187)|0;if((g|0)!=0?(a[g>>0]|0)!=0:0)q=59;else q=57;do if((q|0)==57){g=Im(f,85196)|0;if(g|0?a[g>>0]|0:0){q=59;break}if(i|0)c[z+224>>2]=GL(i)|0}while(0);if((q|0)==59){c[z+224>>2]=qw(g,f)|0;q=z+260|0;b[q>>1]=b[q>>1]|256}j=i}do if(x&8388608){g=Im(f,85204)|0;if((g|0)!=0?(a[g>>0]|0)!=0:0)i=qw(g,f)|0;else i=0;g=Im(f,85211)|0;if((g|0)!=0?(a[g>>0]|0)!=0:0){q=z+260|0;b[q>>1]=b[q>>1]|64;g=qw(g,f)|0;q=72}else q=70;if((q|0)==70?i|0:0){g=GL(i)|0;q=72}if((q|0)==72)c[z+244>>2]=g;g=Im(f,85222)|0;if((g|0)!=0?(a[g>>0]|0)!=0:0){g=qw(g,f)|0;q=78}else q=76;if((q|0)==76?i|0:0){g=GL(i)|0;q=78}if((q|0)==78)c[z+248>>2]=g;g=Im(f,85234)|0;if((g|0)!=0?(a[g>>0]|0)!=0:0){c[z+252>>2]=qw(g,f)|0;p=z+260|0;b[p>>1]=b[p>>1]|16}else q=82;if((q|0)==82?i|0:0)c[z+252>>2]=GL(i)|0;g=Im(f,85245)|0;if(g|0?a[g>>0]|0:0){q=z+260|0;b[q>>1]=b[q>>1]|32;c[z+256>>2]=qw(g,f)|0;break}if(i)c[z+256>>2]=GL(i)|0;else i=0}else i=0;while(0);do if(x&4194304|0){g=Im(f,96229)|0;if((g|0)!=0?(a[g>>0]|0)!=0:0)q=94;else q=92;do if((q|0)==92){g=Im(f,85256)|0;if(g|0?a[g>>0]|0:0){q=94;break}g=c[z+192>>2]|0;if(g|0)c[z+228>>2]=GL(g)|0}while(0);if((q|0)==94){p=Zu(g,f)|0;c[z+228>>2]=qw(p,f)|0;_I(p);p=z+260|0;b[p>>1]=b[p>>1]|1}g=Im(f,85268)|0;if((g|0)!=0?(a[g>>0]|0)!=0:0){p=Zu(g,f)|0;c[z+232>>2]=qw(p,f)|0;_I(p);p=z+260|0;b[p>>1]=b[p>>1]|8}else q=100;if((q|0)==100?(r=c[z+192>>2]|0,r|0):0)c[z+232>>2]=GL(r)|0;g=Im(f,85281)|0;if((g|0)!=0?(a[g>>0]|0)!=0:0){r=Zu(g,f)|0;c[z+236>>2]=qw(r,f)|0;_I(r);r=z+260|0;b[r>>1]=b[r>>1]|2}else q=105;if((q|0)==105?(s=c[z+200>>2]|0,s|0):0)c[z+236>>2]=GL(s)|0;g=Im(f,85293)|0;if(g|0?a[g>>0]|0:0){s=Zu(g,f)|0;c[z+240>>2]=qw(s,f)|0;_I(s);s=z+260|0;b[s>>1]=b[s>>1]|4;break}g=c[z+204>>2]|0;if(g|0)c[z+240>>2]=GL(g)|0}while(0);_I(j);_I(i);do if(x&4259840|0?(u=c[(c[t>>2]|0)+8>>2]|0,u|0):0){if(!(c[z+208>>2]|0)){if((x&524288|0)==0|(c[z+228>>2]|0)==0)break}else if(!(x&524288))break;m=+h[(c[d+16>>2]|0)+152>>3]*.5;m=m>2.0?m:2.0;i=c[u+4>>2]|0;g=0;while(1){if((g|0)>=(i|0))break;_u(y,w,v,(c[u>>2]|0)+(g*48|0)|0,m);g=g+1|0}j=c[v>>2]|0;c[z+276>>2]=j;k=c[w>>2]|0;c[z+280>>2]=k;if(!(x&8192)){g=0;i=0;while(1){if((i|0)>=(j|0))break;g=(c[k+(i<<2)>>2]|0)+g|0;i=i+1|0}y=c[y>>2]|0;fD(d,y,y,g)|0;g=y}else g=c[y>>2]|0;c[z+284>>2]=g;c[z+264>>2]=2;c[z+272>>2]=g;c[z+268>>2]=c[k>>2]}while(0);uD(d,f);g=c[z+208>>2]|0;if(!((g|0)==0?!(b[z+260>>1]&1):0))wD(d,g,c[z+228>>2]|0,c[z+244>>2]|0,c[z+212>>2]|0);l=A;return}function Fu(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0.0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0.0,N=0.0,O=0,P=0,Q=0,R=0,S=0;P=l;l=l+240|0;L=P+224|0;K=P+208|0;x=P+128|0;w=P+112|0;O=P+64|0;C=P+48|0;D=P+32|0;E=P+16|0;F=P;G=P+192|0;H=P+176|0;y=P+160|0;B=P+144|0;c[E>>2]=0;c[E+4>>2]=0;c[E+8>>2]=0;c[E+12>>2]=0;M=+h[(c[b+16>>2]|0)+152>>3];ZE(Im(e,85048)|0);J=e+16|0;a:do if(c[(c[J>>2]|0)+8>>2]|0){N=+EA(e,c[42232]|0,1.0,0.0);k=FA(e,c[42220]|0,174181)|0;v=(f|0)!=0;b:do if(v){g=f;while(1){i=g;g=g+4|0;i=c[i>>2]|0;if(!i){o=0;break b}if((a[i>>0]|0)!=116)continue;if(!(xJ(i,95939)|0)){o=1;break}}}else o=0;while(0);j=k;q=0;i=0;c:while(1){switch(a[j>>0]|0){case 0:break c;case 58:{g=q+1|0;break}case 59:{g=q;i=i+1|0;break}default:g=q}j=j+1|0;q=g}n=(q|0)!=0;if((i|0)!=0&n)if(!(Nu(b,e,f,k,q+1|0,N,M)|0))break;else m=122106;else m=k;g=d[(c[J>>2]|0)+115>>0]|0;if(!(g&1))if(!(g&2))if(!(g&8))if(!(g&4)){i=m;j=GA(e,c[42221]|0,m)|0}else{j=91340;g=91332;k=168888;i=168888;p=18}else{j=91324;g=91316;k=168888;i=168888;p=18}else{j=91308;g=91300;k=168888;i=168888;p=18}else{j=91292;g=91284;k=168888;i=168888;p=18}if((p|0)==18){i=c[i>>2]|0;i=GA(e,i,Ou(m,g)|0)|0;g=GA(e,c[k>>2]|0,j)|0;if((i|0)==(m|0)){i=m;j=g}else{BD(b,i);j=g}}if((j|0)!=(m|0))DD(b,j);if(o<<24>>24){i=(a[i>>0]|0)==0?122106:i;g=(a[j>>0]|0)==0?122106:j;BD(b,122171);DD(b,i);u=O;r=c[c[(c[J>>2]|0)+8>>2]>>2]|0;s=u+48|0;do{c[u>>2]=c[r>>2];u=u+4|0;r=r+4|0}while((u|0)<(s|0));J=dA(O,Pu(e)|0,M,0,0)|0;HD(b,c[J+8>>2]|0,c[J>>2]|0,1);Qu(J);BD(b,i);if((g|0)!=(i|0))DD(b,g);g=c[O+8>>2]|0;if(g|0){I=O+16|0;J=c[O>>2]|0;c[K>>2]=c[I>>2];c[K+4>>2]=c[I+4>>2];c[K+8>>2]=c[I+8>>2];c[K+12>>2]=c[I+12>>2];c[L>>2]=c[J>>2];c[L+4>>2]=c[J+4>>2];c[L+8>>2]=c[J+8>>2];c[L+12>>2]=c[J+12>>2];St(b,2,K,L,N,M,g)}g=c[O+12>>2]|0;if(!g)break;J=O+32|0;O=(c[O>>2]|0)+((c[O+4>>2]|0)+-1<<4)|0;c[K>>2]=c[J>>2];c[K+4>>2]=c[J+4>>2];c[K+8>>2]=c[J+8>>2];c[K+12>>2]=c[J+12>>2];c[L>>2]=c[O>>2];c[L+4>>2]=c[O+4>>2];c[L+8>>2]=c[O+8>>2];c[L+12>>2]=c[O+12>>2];St(b,3,K,L,N,M,g);break}g=c[J>>2]|0;if(!n){do if(!(a[g+115>>0]&3)){if(a[i>>0]|0){BD(b,i);DD(b,j);break}BD(b,122106);if(!(a[j>>0]|0)){DD(b,122106);break}else{DD(b,j);break}}while(0);k=b+152|0;m=O+4|0;n=O+8|0;o=O+12|0;p=O+32|0;q=O+16|0;j=0;while(1){g=c[(c[J>>2]|0)+8>>2]|0;if((j|0)>=(c[g+4>>2]|0))break a;u=O;r=(c[g>>2]|0)+(j*48|0)|0;s=u+48|0;do{c[u>>2]=c[r>>2];u=u+4|0;r=r+4|0}while((u|0)<(s|0));g=c[O>>2]|0;i=c[m>>2]|0;do if(!(c[k>>2]&16384)){JD(b,g,i,0,0,0);g=c[n>>2]|0;if(g|0){I=c[O>>2]|0;c[K>>2]=c[q>>2];c[K+4>>2]=c[q+4>>2];c[K+8>>2]=c[q+8>>2];c[K+12>>2]=c[q+12>>2];c[L>>2]=c[I>>2];c[L+4>>2]=c[I+4>>2];c[L+8>>2]=c[I+8>>2];c[L+12>>2]=c[I+12>>2];St(b,2,K,L,N,M,g)}g=c[o>>2]|0;if(g|0){I=(c[O>>2]|0)+((c[m>>2]|0)+-1<<4)|0;c[K>>2]=c[p>>2];c[K+4>>2]=c[p+4>>2];c[K+8>>2]=c[p+8>>2];c[K+12>>2]=c[p+12>>2];c[L>>2]=c[I>>2];c[L+4>>2]=c[I+4>>2];c[L+8>>2]=c[I+8>>2];c[L+12>>2]=c[I+12>>2];St(b,3,K,L,N,M,g)}if((c[(c[(c[J>>2]|0)+8>>2]|0)+4>>2]|0)>1){if(!(c[n>>2]|0)){if(!(v&(c[o>>2]|0)!=0))break}else if(!v)break;FD(b,f)}}else JD(b,g,i,c[n>>2]|0,c[o>>2]|0,0);while(0);j=j+1|0}}I=c[(c[g+8>>2]|0)+4>>2]|0;A=I*48|0;z=ZI(A)|0;A=ZI(A)|0;t=+(q+2|0)*.5;v=O+4|0;p=C+8|0;q=D+8|0;e=E+8|0;f=F+8|0;o=0;while(1){if((o|0)>=(I|0))break;u=O;r=(c[c[(c[J>>2]|0)+8>>2]>>2]|0)+(o*48|0)|0;s=u+48|0;do{c[u>>2]=c[r>>2];u=u+4|0;r=r+4|0}while((u|0)<(s|0));g=c[v>>2]|0;c[z+(o*48|0)+4>>2]=g;c[A+(o*48|0)+4>>2]=g;n=g<<4;m=ZI(n)|0;c[z+(o*48|0)>>2]=m;n=ZI(n)|0;c[A+(o*48|0)>>2]=n;k=c[O>>2]|0;c[F>>2]=c[k>>2];c[F+4>>2]=c[k+4>>2];c[F+8>>2]=c[k+8>>2];c[F+12>>2]=c[k+12>>2];k=0;while(1){if((k|0)>=(g+-1|0))break;c[C>>2]=c[F>>2];c[C+4>>2]=c[F+4>>2];c[C+8>>2]=c[F+8>>2];c[C+12>>2]=c[F+12>>2];g=k+1|0;j=(c[O>>2]|0)+(g<<4)|0;c[D>>2]=c[j>>2];c[D+4>>2]=c[j+4>>2];c[D+8>>2]=c[j+8>>2];c[D+12>>2]=c[j+12>>2];j=m+(k<<4)|0;if(!k){c[K>>2]=c[C>>2];c[K+4>>2]=c[C+4>>2];c[K+8>>2]=c[C+8>>2];c[K+12>>2]=c[C+12>>2];c[L>>2]=c[D>>2];c[L+4>>2]=c[D+4>>2];c[L+8>>2]=c[D+8>>2];c[L+12>>2]=c[D+12>>2];Ru(G,K,L);c[j>>2]=c[G>>2];c[j+4>>2]=c[G+4>>2];c[j+8>>2]=c[G+8>>2];c[j+12>>2]=c[G+12>>2]}else{c[K>>2]=c[E>>2];c[K+4>>2]=c[E+4>>2];c[K+8>>2]=c[E+8>>2];c[K+12>>2]=c[E+12>>2];c[L>>2]=c[D>>2];c[L+4>>2]=c[D+4>>2];c[L+8>>2]=c[D+8>>2];c[L+12>>2]=c[D+12>>2];Ru(H,K,L);c[j>>2]=c[H>>2];c[j+4>>2]=c[H+4>>2];c[j+8>>2]=c[H+8>>2];c[j+12>>2]=c[H+12>>2]}R=c[O>>2]|0;s=k+2|0;S=R+(s<<4)|0;c[E>>2]=c[S>>2];c[E+4>>2]=c[S+4>>2];c[E+8>>2]=c[S+8>>2];c[E+12>>2]=c[S+12>>2];u=k+3|0;R=R+(u<<4)|0;c[F>>2]=c[R>>2];c[F+4>>2]=c[R+4>>2];c[F+8>>2]=c[R+8>>2];c[F+12>>2]=c[R+12>>2];Q=m+(g<<4)|0;r=m+(s<<4)|0;c[w>>2]=c[C>>2];c[w+4>>2]=c[C+4>>2];c[w+8>>2]=c[C+8>>2];c[w+12>>2]=c[C+12>>2];c[x>>2]=c[D>>2];c[x+4>>2]=c[D+4>>2];c[x+8>>2]=c[D+8>>2];c[x+12>>2]=c[D+12>>2];c[K>>2]=c[S>>2];c[K+4>>2]=c[S+4>>2];c[K+8>>2]=c[S+8>>2];c[K+12>>2]=c[S+12>>2];c[L>>2]=c[R>>2];c[L+4>>2]=c[R+4>>2];c[L+8>>2]=c[R+8>>2];c[L+12>>2]=c[R+12>>2];Su(y,w,x,K,L);c[r>>2]=c[y>>2];c[r+4>>2]=c[y+4>>2];c[r+8>>2]=c[y+8>>2];c[r+12>>2]=c[y+12>>2];c[Q>>2]=c[y>>2];c[Q+4>>2]=c[y+4>>2];c[Q+8>>2]=c[y+8>>2];c[Q+12>>2]=c[y+12>>2];h[n+(k<<4)>>3]=+h[C>>3]-+h[j>>3]*t;h[n+(k<<4)+8>>3]=+h[p>>3]-+h[m+(k<<4)+8>>3]*t;h[n+(g<<4)>>3]=+h[D>>3]-+h[Q>>3]*t;h[n+(g<<4)+8>>3]=+h[q>>3]-+h[m+(g<<4)+8>>3]*t;h[n+(s<<4)>>3]=+h[E>>3]-+h[r>>3]*t;h[n+(s<<4)+8>>3]=+h[e>>3]-+h[m+(s<<4)+8>>3]*t;k=u;g=c[v>>2]|0}S=m+(k<<4)|0;c[K>>2]=c[E>>2];c[K+4>>2]=c[E+4>>2];c[K+8>>2]=c[E+8>>2];c[K+12>>2]=c[E+12>>2];c[L>>2]=c[F>>2];c[L+4>>2]=c[F+4>>2];c[L+8>>2]=c[F+8>>2];c[L+12>>2]=c[F+12>>2];Ru(B,K,L);c[S>>2]=c[B>>2];c[S+4>>2]=c[B+4>>2];c[S+8>>2]=c[B+8>>2];c[S+12>>2]=c[B+12>>2];h[n+(k<<4)>>3]=+h[F>>3]-+h[S>>3]*t;h[n+(k<<4)+8>>3]=+h[f>>3]-+h[m+(k<<4)+8>>3]*t;o=o+1|0}s=GL(i)|0;f=0;r=i;g=i;j=i;i=s;while(1){i=DL(i,93017)|0;if(!i)break;e=(a[i>>0]|0)==0?122106:i;if((e|0)!=(j|0))if(!(a[(c[J>>2]|0)+115>>0]&3)){BD(b,e);DD(b,e);j=e}else j=e;m=(f|0)==0;n=f>>>0<2;i=0;while(1){if((i|0)>=(I|0))break;o=c[A+(i*48|0)>>2]|0;p=c[z+(i*48|0)>>2]|0;q=c[A+(i*48|0)+4>>2]|0;k=0;while(1){if((k|0)>=(q|0))break;S=o+(k<<4)|0;h[S>>3]=+h[S>>3]+ +h[p+(k<<4)>>3];S=o+(k<<4)+8|0;h[S>>3]=+h[S>>3]+ +h[p+(k<<4)+8>>3];k=k+1|0}JD(b,o,q,0,0,0);i=i+1|0}f=f+1|0;r=m?e:r;g=n?e:g;i=0}i=c[O+8>>2]|0;if(!i)i=0;else{if(g){if(!(a[(c[J>>2]|0)+115>>0]&3)){BD(b,g);DD(b,g)}}else g=0;R=O+16|0;S=c[O>>2]|0;c[K>>2]=c[R>>2];c[K+4>>2]=c[R+4>>2];c[K+8>>2]=c[R+8>>2];c[K+12>>2]=c[R+12>>2];c[L>>2]=c[S>>2];c[L+4>>2]=c[S+4>>2];c[L+8>>2]=c[S+8>>2];c[L+12>>2]=c[S+12>>2];St(b,2,K,L,N,M,i);i=g}j=O+12|0;g=c[j>>2]|0;if(g|0){if((i|0)!=(r|0)?(a[(c[J>>2]|0)+115>>0]&3)==0:0){BD(b,r);DD(b,r);g=c[j>>2]|0}R=O+32|0;S=(c[O>>2]|0)+((c[v>>2]|0)+-1<<4)|0;c[K>>2]=c[R>>2];c[K+4>>2]=c[R+4>>2];c[K+8>>2]=c[R+8>>2];c[K+12>>2]=c[R+12>>2];c[L>>2]=c[S>>2];c[L+4>>2]=c[S+4>>2];c[L+8>>2]=c[S+8>>2];c[L+12>>2]=c[S+12>>2];St(b,3,K,L,N,M,g)}_I(s);g=0;while(1){if((g|0)>=(I|0))break;_I(c[z+(g*48|0)>>2]|0);_I(c[A+(g*48|0)>>2]|0);g=g+1|0}_I(z);_I(A)}while(0);l=P;return}function Gu(a){a=a|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;x=l;l=l+64|0;r=x+48|0;u=x+32|0;t=x+16|0;s=x;w=c[a+16>>2]|0;v=c[w+8>>2]|0;q=w+208|0;if(!((c[q>>2]|0)==0?!(b[w+260>>1]&1):0))d=3;a:do if((d|0)==3?(xD(a),p=w+276|0,e=c[p>>2]|0,e|0):0){h=w+280|0;d=c[h>>2]|0;i=w+268|0;j=w+284|0;k=w+272|0;m=w+228|0;n=w+244|0;o=w+212|0;f=c[d>>2]|0;g=1;while(1){if((g|0)>=(e|0))break a;c[i>>2]=c[d+(g<<2)>>2];c[k>>2]=(c[j>>2]|0)+(f<<4);wD(a,c[q>>2]|0,c[m>>2]|0,c[n>>2]|0,c[o>>2]|0);xD(a);y=c[h>>2]|0;f=(c[y+(g<<2)>>2]|0)+f|0;g=g+1|0;e=c[p>>2]|0;d=y}}while(0);c[w+268>>2]=0;c[w+272>>2]=0;q=v+16|0;d=c[q>>2]|0;e=c[d+8>>2]|0;if(!e)f=w+260|0;else{p=c[e>>2]|0;d=c[p>>2]|0;y=c[p+8>>2]|0;o=p+16|0;c[t>>2]=c[o>>2];c[t+4>>2]=c[o+4>>2];c[t+8>>2]=c[o+8>>2];c[t+12>>2]=c[o+12>>2];p=p+32|0;c[s>>2]=c[p>>2];c[s+4>>2]=c[p+4>>2];c[s+8>>2]=c[p+8>>2];c[s+12>>2]=c[p+12>>2];if(!y){c[u>>2]=c[d>>2];c[u+4>>2]=c[d+4>>2];c[u+8>>2]=c[d+8>>2];c[u+12>>2]=c[d+12>>2]}else{c[u>>2]=c[t>>2];c[u+4>>2]=c[t+4>>2];c[u+8>>2]=c[t+8>>2];c[u+12>>2]=c[t+12>>2]}f=w+260|0;p=b[f>>1]|0;o=c[w+220>>2]|0;c[r>>2]=c[u>>2];c[r+4>>2]=c[u+4>>2];c[r+8>>2]=c[u+8>>2];c[r+12>>2]=c[u+12>>2];Hu(a,r,(p<<8&65535)<<16>>16>>15&255,o,(p<<14&65535)<<16>>16>>15&255);p=c[(c[q>>2]|0)+8>>2]|0;o=c[p>>2]|0;p=(c[p+4>>2]|0)+-1|0;d=c[o+(p*48|0)>>2]|0;e=c[o+(p*48|0)+4>>2]|0;y=c[o+(p*48|0)+12>>2]|0;n=o+(p*48|0)+16|0;c[t>>2]=c[n>>2];c[t+4>>2]=c[n+4>>2];c[t+8>>2]=c[n+8>>2];c[t+12>>2]=c[n+12>>2];t=o+(p*48|0)+32|0;c[s>>2]=c[t>>2];c[s+4>>2]=c[t+4>>2];c[s+8>>2]=c[t+8>>2];c[s+12>>2]=c[t+12>>2];if(!y){y=d+(e+-1<<4)|0;c[u>>2]=c[y>>2];c[u+4>>2]=c[y+4>>2];c[u+8>>2]=c[y+8>>2];c[u+12>>2]=c[y+12>>2]}else{c[u>>2]=c[s>>2];c[u+4>>2]=c[s+4>>2];c[u+8>>2]=c[s+8>>2];c[u+12>>2]=c[s+12>>2]}d=b[f>>1]|0;y=c[w+224>>2]|0;c[r>>2]=c[u>>2];c[r+4>>2]=c[u+4>>2];c[r+8>>2]=c[u+8>>2];c[r+12>>2]=c[u+12>>2];Hu(a,r,(d<<7&65535)<<16>>16>>15&255,y,(d<<13&65535)<<16>>16>>15&255);d=c[q>>2]|0}e=c[d+96>>2]|0;g=(b[f>>1]<<12&65535)<<16>>16>>15<<16>>16;m=w+216|0;h=c[m>>2]|0;n=w+232|0;i=c[n>>2]|0;o=w+248|0;j=c[o>>2]|0;p=w+212|0;k=c[p>>2]|0;if(!((IA(FA(v,c[42230]|0,122100)|0)|0)<<24>>24))d=0;else d=c[(c[q>>2]|0)+8>>2]|0;Iu(a,e,11,g,h,i,j,k,d);j=c[(c[q>>2]|0)+108>>2]|0;k=(b[f>>1]<<12&65535)<<16>>16>>15<<16>>16;i=c[m>>2]|0;h=c[n>>2]|0;e=c[o>>2]|0;g=c[p>>2]|0;if(!((IA(FA(v,c[42230]|0,122100)|0)|0)<<24>>24))d=0;else d=c[(c[q>>2]|0)+8>>2]|0;Iu(a,j,11,k,i,h,e,g,d);Iu(a,c[(c[q>>2]|0)+100>>2]|0,7,(b[f>>1]<<13&65535)<<16>>16>>15<<16>>16,c[w+224>>2]|0,c[w+240>>2]|0,c[w+256>>2]|0,c[p>>2]|0,0);Iu(a,c[(c[q>>2]|0)+104>>2]|0,6,(b[f>>1]<<14&65535)<<16>>16>>15<<16>>16,c[w+220>>2]|0,c[w+236>>2]|0,c[w+252>>2]|0,c[p>>2]|0,0);vD(a);Wt(a);l=x;return}function Hu(a,d,e,f,g){a=a|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0;j=l;l=l+16|0;h=j;i=c[a+16>>2]|0;if(!(e<<24>>24))f=c[i+208>>2]|0;if(!(g<<24>>24==0?((f|0)==0?(b[i+260>>1]&1)==0:0):0)){c[h>>2]=c[d>>2];c[h+4>>2]=c[d+4>>2];c[h+8>>2]=c[d+8>>2];c[h+12>>2]=c[d+12>>2];Mu(a,h)}l=j;return}function Iu(b,d,e,f,g,h,i,j,k){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;var m=0,n=0,o=0,p=0,q=0,r=0;r=l;l=l+16|0;o=r;q=c[b+152>>2]|0;if(d|0?a[d+81>>0]|0:0){if(!j)n=0;else{n=vw((rJ(j)|0)+11|0)|0;switch(e|0){case 11:{m=86240;break}case 7:{m=86656;break}case 6:{m=86666;break}default:ma(123205,84925,2730,85060)}c[o>>2]=j;c[o+4>>2]=m;pL(n,85076,o)|0}o=b+16|0;j=(c[o>>2]|0)+12|0;p=c[j>>2]|0;c[j>>2]=e;j=(f|0)!=0|(g|0)!=0;m=(q&4|0)==0;if(j&m){Ju(b,d);wD(b,g,h,i,n)}pw(b,e,d);if(k|0)Ku(b,d,k);if(j){if(!m){Ju(b,d);wD(b,g,h,i,n)}xD(b)}_I(n);c[(c[o>>2]|0)+12>>2]=p}l=r;return}function Ju(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0;d=c[a+16>>2]|0;e=c[a+152>>2]|0;if(e&4259840|0){f=e&131072;i=f>>>16^2;c[d+264>>2]=i;j=d+268|0;c[j>>2]=i+2;i=d+272|0;_I(c[i>>2]|0);d=vw(c[j>>2]<<4)|0;c[i>>2]=d;i=b+56|0;j=b+24|0;h[d>>3]=+h[i>>3]-+h[j>>3]*.5;g=b+64|0;b=b+32|0;h[d+8>>3]=+h[g>>3]-+h[b>>3]*.5;h[d+16>>3]=+h[j>>3]*.5+ +h[i>>3];h[d+24>>3]=+h[b>>3]*.5+ +h[g>>3];if(!(e&8192))fD(a,d,d,2)|0;if(!f)Zv(d)}return}function Ku(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0.0;o=l;l=l+96|0;g=o+80|0;i=o+32|0;j=o+16|0;k=o;f=c[d>>2]|0;while(1){m=a[f>>0]|0;if(!(m<<24>>24))break;if(!(XJ(m&255)|0)){n=4;break}else f=f+1|0}if((n|0)==4){p=+h[d+24>>3];m=d+56|0;Lu(i,+h[m>>3]+p*.5,+h[d+64>>3]-+h[d+32>>3]*.5);n=i+16|0;Lu(j,+h[i>>3]-p,+h[i+8>>3]);c[n>>2]=c[j>>2];c[n+4>>2]=c[j+4>>2];c[n+8>>2]=c[j+8>>2];c[n+12>>2]=c[j+12>>2];n=i+32|0;c[g>>2]=c[m>>2];c[g+4>>2]=c[m+4>>2];c[g+8>>2]=c[m+8>>2];c[g+12>>2]=c[m+12>>2];VA(k,e,g);c[n>>2]=c[k>>2];c[n+4>>2]=c[k+4>>2];c[n+8>>2]=c[k+8>>2];c[n+12>>2]=c[k+12>>2];FD(b,c[(c[b>>2]|0)+336>>2]|0);BD(b,c[d+8>>2]|0);KD(b,i,3)}l=o;return}function Lu(a,b,c){a=a|0;b=+b;c=+c;h[a>>3]=b;h[a+8>>3]=c;return}function Mu(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0.0,i=0.0,j=0,k=0;d=c[a+16>>2]|0;e=c[a+152>>2]|0;if(e&4259840|0){f=e&131072;j=f>>>16^2;c[d+264>>2]=j;k=d+268|0;c[k>>2]=j+2;j=d+272|0;_I(c[j>>2]|0);d=vw(c[k>>2]<<4)|0;c[j>>2]=d;i=+h[b>>3];h[d>>3]=i+-3.0;g=+h[b+8>>3];h[d+8>>3]=g+-3.0;h[d+16>>3]=i+3.0;h[d+24>>3]=g+3.0;if(!(e&8192))fD(a,d,d,2)|0;if(!f)Zv(d)}return}function Nu(a,b,d,e,f,h,i){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;h=+h;i=+i;var j=0,k=0,m=0.0,n=0.0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0;J=l;l=l+256|0;D=J+224|0;C=J+208|0;j=J+192|0;F=J+144|0;G=J+96|0;H=J+48|0;E=J;k=J+240|0;e=$t(e,f,k)|0;if((e|0)>1){z=b+48|0;A=ro(c[((c[b>>2]&3|0)==3?b:z)+40>>2]|0)|0;z=Dn(c[((c[b>>2]&3|0)==3?b:z)+40>>2]|0)|0;A=(qn(A)|0)!=0;B=Dn(c[((c[b>>2]&3|0)==2?b:b+-48|0)+40>>2]|0)|0;c[j>>2]=z;c[j+4>>2]=A?85095:85100;c[j+8>>2]=B;_l(3,85105,j)|0;if((e|0)==2)e=1;else I=4}else if((e|0)==1)e=1;else I=4;if((I|0)==4){B=b+16|0;r=c[k>>2]|0;s=r+8|0;t=H+4|0;u=F+8|0;v=F+12|0;w=(d|0)!=0;q=(d|0)==0;x=F+32|0;y=F+4|0;z=F+16|0;A=E+4|0;e=0;p=0;while(1){f=c[(c[B>>2]|0)+8>>2]|0;if((p|0)>=(c[f+4>>2]|0))break;j=F;f=(c[f>>2]|0)+(p*48|0)|0;b=j+48|0;do{c[j>>2]=c[f>>2];j=j+4|0;f=f+4|0}while((j|0)<(b|0));b=1;m=1.0;o=c[s>>2]|0;a:while(1){f=c[o>>2]|0;if(!f)break;k=o+4|0;n=+g[k>>2];do if(n<1.0e-05&n>-1.0e-05)f=b;else{BD(a,f);n=+g[k>>2];m=m-n;e=c[o>>2]|0;if(b|0){Xu(F,n,H,E);k=c[H>>2]|0;JD(a,k,c[t>>2]|0,0,0,0);_I(k);if(m<1.0e-05&m>-1.0e-05){I=11;break a}else{f=0;break}}if(m<1.0e-05&m>-1.0e-05){I=13;break a}j=G;f=E;b=j+48|0;do{c[j>>2]=c[f>>2];j=j+4|0;f=f+4|0}while((j|0)<(b|0));n=+g[k>>2];Xu(G,n/(m+n),H,E);_I(c[G>>2]|0);f=c[H>>2]|0;JD(a,f,c[t>>2]|0,0,0,0);_I(f);f=0}while(0);b=f;o=o+12|0}if((I|0)==11){I=0;_I(c[E>>2]|0)}else if((I|0)==13){I=0;o=c[E>>2]|0;JD(a,o,c[A>>2]|0,0,0,0);_I(o)}if(c[u>>2]|0){BD(a,c[c[s>>2]>>2]|0);DD(a,c[c[s>>2]>>2]|0);k=c[F>>2]|0;o=c[u>>2]|0;c[C>>2]=c[z>>2];c[C+4>>2]=c[z+4>>2];c[C+8>>2]=c[z+8>>2];c[C+12>>2]=c[z+12>>2];c[D>>2]=c[k>>2];c[D+4>>2]=c[k+4>>2];c[D+8>>2]=c[k+8>>2];c[D+12>>2]=c[k+12>>2];St(a,2,C,D,h,i,o)}if(c[v>>2]|0){BD(a,e);DD(a,e);k=(c[F>>2]|0)+((c[y>>2]|0)+-1<<4)|0;o=c[v>>2]|0;c[C>>2]=c[x>>2];c[C+4>>2]=c[x+4>>2];c[C+8>>2]=c[x+8>>2];c[C+12>>2]=c[x+12>>2];c[D>>2]=c[k>>2];c[D+4>>2]=c[k+4>>2];c[D+8>>2]=c[k+8>>2];c[D+12>>2]=c[k+12>>2];St(a,3,C,D,h,i,o)}do if((c[(c[(c[B>>2]|0)+8>>2]|0)+4>>2]|0)>1){if(!(c[u>>2]|0)){if(!(w&(c[v>>2]|0)!=0))break}else if(q)break;FD(a,d)}while(0);p=p+1|0}au(r);e=0}l=J;return e|0}function Ou(b,d){b=b|0;d=d|0;var e=0,f=0;e=1;a:while(1){switch(a[b>>0]|0){case 0:break a;case 58:{e=e+1|0;break}default:{}}b=b+1|0}f=O((rJ(d)|0)+1|0,e)|0;b=f+10|0;if((c[42166]|0)<(f|0)){c[42166]=b;b=aJ(c[42167]|0,b)|0;c[42167]=b}else b=c[42167]|0;xK(b,d)|0;while(1){e=e+-1|0;b=c[42167]|0;if(!e)break;f=b+(rJ(b)|0)|0;a[f>>0]=58;a[f+1>>0]=0;IL(b,d)|0}return b|0}function Pu(b){b=b|0;var d=0,e=0;d=c[42228]|0;a:do if(!d)e=7;else{d=Jm(b,d)|0;switch(a[d>>0]|0){case 110:if(!(xJ(d,120501)|0)){d=1;break a}else{e=7;break a}case 102:if(!(xJ(d,85082)|0)){d=2;break a}else{e=7;break a}case 98:{if(!(xJ(d,85090)|0)){d=3;break a}if(!(xJ(d,96056)|0)){d=4;break a}else{e=7;break a}}default:{e=7;break a}}}while(0);if((e|0)==7){d=(qn(ro(c[((c[b>>2]&3|0)==2?b:b+-48|0)+40>>2]|0)|0)|0)!=0;d=d?2:1}return d|0}function Qu(a){a=a|0;if(a|0){_I(c[a+8>>2]|0);_I(a)}return}function Ru(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0;e=+h[b>>3]-+h[c>>3];f=+h[b+8>>3]-+h[c+8>>3];d=2.0/+C(+(e*e+.0001+f*f));h[a>>3]=d*f;h[a+8>>3]=-(e*d);return}function Su(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0.0,g=0.0,i=0.0,j=0.0;g=+h[c>>3]-+h[d>>3];i=+h[c+8>>3]-+h[d+8>>3];f=+C(+(i*i+g*g));if(f<.0001){j=+h[b>>3]-+h[e>>3];f=+h[b+8>>3]-+h[e+8>>3];i=f;g=j;f=+C(+(j*j+.0001+f*f))}j=2.0/f;h[a>>3]=i*j;h[a+8>>3]=-(j*g);return}function Tu(a,b,c){a=+a;b=+b;c=+c;return +(c*.5*(1.0-a/b))}function Uu(a,b,c){a=+a;b=+b;c=+c;return +(c*.5)}function Vu(a,b,c){a=+a;b=+b;c=+c;return +(c*.5*(a/b))}function Wu(a,b,c){a=+a;b=+b;c=+c;b=a/b;return +((!(b<=.5)?1.0-b:b)*c)}function Xu(a,b,d,e){a=a|0;b=+b;d=d|0;e=e|0;var f=0.0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0.0,r=0,s=0;p=l;l=l+16|0;o=p;n=c[a+4>>2]|0;j=(n+-1|0)/3|0;if((n+-4|0)>>>0<3){c[d+4>>2]=4;c[d>>2]=vw(64)|0;c[e+4>>2]=4;n=vw(64)|0;c[e>>2]=n;PA(o,c[a>>2]|0,3,b,c[d>>2]|0,n)}else{n=vw(j<<3)|0;g=0;i=c[a>>2]|0;f=0.0;while(1){if((g|0)>=(j|0))break;q=+Yu(i);h[n+(g<<3)>>3]=q;g=g+1|0;i=i+48|0;f=q+f}b=f*b;m=0;f=0.0;while(1){if((j|0)<=(m|0))break;f=+h[n+(m<<3)>>3]+f;if(f>=b)break;m=m+1|0}k=m*3|0;g=k+4|0;i=d+4|0;c[i>>2]=g;c[d>>2]=vw(g<<4)|0;g=((j-m|0)*3|0)+1|0;j=e+4|0;c[j>>2]=g;c[e>>2]=vw(g<<4)|0;g=0;while(1){if((g|0)>=(c[i>>2]|0))break;r=(c[d>>2]|0)+(g<<4)|0;s=(c[a>>2]|0)+(g<<4)|0;c[r>>2]=c[s>>2];c[r+4>>2]=c[s+4>>2];c[r+8>>2]=c[s+8>>2];c[r+12>>2]=c[s+12>>2];g=g+1|0}g=g+-4|0;i=0;while(1){if((i|0)>=(c[j>>2]|0))break;s=(c[e>>2]|0)+(i<<4)|0;r=(c[a>>2]|0)+(g<<4)|0;c[s>>2]=c[r>>2];c[s+4>>2]=c[r+4>>2];c[s+8>>2]=c[r+8>>2];c[s+12>>2]=c[r+12>>2];g=g+1|0;i=i+1|0}q=+h[n+(m<<3)>>3];PA(o,(c[a>>2]|0)+(k<<4)|0,3,(b-f+q)/q,(c[d>>2]|0)+(k<<4)|0,c[e>>2]|0);_I(n)}l=p;return}function Yu(a){a=a|0;var b=0.0,c=0.0,d=0.0,e=0.0,f=0.0;e=+h[a+16>>3];d=+h[a>>3]-e;f=+h[a+24>>3];b=+h[a+8>>3]-f;d=+C(+(b*b+d*d));b=+h[a+32>>3];e=e-b;c=+h[a+40>>3];f=f-c;d=+C(+(f*f+e*e))+d;b=b-+h[a+48>>3];c=c-+h[a+56>>3];return +(d+ +C(+(c*c+b*b)))}function Zu(b,d){b=b|0;d=d|0;d=so(d)|0;if((a[(c[d+16>>2]|0)+115>>0]|0)==1)d=yB(b)|0;else d=vB(b,d)|0;return ev(d)|0}function _u(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=+f;var g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;q=l;l=l+1664|0;m=q+1600|0;n=q+800|0;o=q;p=ww(24)|0;c[p+16>>2]=1;j=((c[e+4>>2]|0)+-1|0)/3|0;h=0;i=p;while(1){if((h|0)>=(j|0))break;k=h*3|0;g=0;while(1){if((g|0)==4)break;r=m+(g<<4)|0;s=(c[e>>2]|0)+(g+k<<4)|0;c[r>>2]=c[s>>2];c[r+4>>2]=c[s+4>>2];c[r+8>>2]=c[s+8>>2];c[r+12>>2]=c[s+12>>2];g=g+1|0}h=h+1|0;i=$u(m,i)|0}g=0;h=0;i=p;while(1){if(!i){h=p;g=p;break}j=c[i+16>>2]|0;k=n+(g<<4)|0;e=o+(g<<4)|0;av(h,i,j,k,e,f);g=g+1|0;if(!((g|0)==50|(j|0)==0)){h=i;i=j;continue}bv(a,b,d,g,n,o);c[n>>2]=c[k>>2];c[n+4>>2]=c[k+4>>2];c[n+8>>2]=c[k+8>>2];c[n+12>>2]=c[k+12>>2];c[o>>2]=c[e>>2];c[o+4>>2]=c[e+4>>2];c[o+8>>2]=c[e+8>>2];c[o+12>>2]=c[e+12>>2];h=i;g=1;i=j}while(1){if(!h)break;s=c[h+16>>2]|0;_I(g);h=s;g=s}l=q;return}function $u(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;g=l;l=l+144|0;f=g+128|0;d=g+64|0;e=g;if(!(fu(a)|0)){PA(f,a,3,.5,d,e);d=$u(e,$u(d,b)|0)|0}else{d=b+16|0;if((c[d>>2]|0)==1){c[d>>2]=0;c[b>>2]=c[a>>2];c[b+4>>2]=c[a+4>>2];c[b+8>>2]=c[a+8>>2];c[b+12>>2]=c[a+12>>2]}d=a+48|0;c[f>>2]=c[d>>2];c[f+4>>2]=c[d+4>>2];c[f+8>>2]=c[d+8>>2];c[f+12>>2]=c[d+12>>2];d=dv(f,b)|0}l=g;return d|0}function av(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=+g;var i=0.0,j=0.0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0.0,t=0.0;r=l;l=l+96|0;n=r+80|0;m=r+64|0;k=r+48|0;o=r+32|0;p=r+16|0;q=r;c[o>>2]=c[b>>2];c[o+4>>2]=c[b+4>>2];c[o+8>>2]=c[b+8>>2];c[o+12>>2]=c[b+12>>2];do if(a){c[p>>2]=c[a>>2];c[p+4>>2]=c[a+4>>2];c[p+8>>2]=c[a+8>>2];c[p+12>>2]=c[a+12>>2];if(!d){i=+h[o>>3];h[q>>3]=i*2.0-+h[p>>3];j=+h[o+8>>3];h[q+8>>3]=j*2.0-+h[p+8>>3];break}else{c[q>>2]=c[d>>2];c[q+4>>2]=c[d+4>>2];c[q+8>>2]=c[d+8>>2];c[q+12>>2]=c[d+12>>2];i=+h[o>>3];j=+h[o+8>>3];break}}else{c[q>>2]=c[d>>2];c[q+4>>2]=c[d+4>>2];c[q+8>>2]=c[d+8>>2];c[q+12>>2]=c[d+12>>2];i=+h[o>>3];h[p>>3]=i*2.0-+h[q>>3];j=+h[o+8>>3];h[p+8>>3]=j*2.0-+h[q+8>>3]}while(0);c[k>>2]=c[p>>2];c[k+4>>2]=c[p+4>>2];c[k+8>>2]=c[p+8>>2];c[k+12>>2]=c[p+12>>2];c[m>>2]=c[o>>2];c[m+4>>2]=c[o+4>>2];c[m+8>>2]=c[o+8>>2];c[m+12>>2]=c[o+12>>2];c[n>>2]=c[q>>2];c[n+4>>2]=c[q+4>>2];c[n+8>>2]=c[q+8>>2];c[n+12>>2]=c[q+12>>2];t=+cv(k,m,n);s=+E(+t)*g;g=+F(+t)*g;h[e>>3]=i+s;h[e+8>>3]=j+g;h[f>>3]=i-s;h[f+8>>3]=j-g;l=r;return}function bv(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,l=0;i=e<<1;j=c[d>>2]|0;h=0;k=0;while(1){if((h|0)>=(j|0))break;l=(c[(c[b>>2]|0)+(h<<2)>>2]|0)+k|0;h=h+1|0;k=l}l=j+1|0;c[d>>2]=l;l=yw(c[b>>2]|0,l<<2)|0;c[b>>2]=l;c[l+(h<<2)>>2]=i;c[a>>2]=yw(c[a>>2]|0,k+i<<4)|0;b=i+-1+k|0;h=0;while(1){if((h|0)>=(e|0))break;l=(c[a>>2]|0)+(h+k<<4)|0;j=f+(h<<4)|0;c[l>>2]=c[j>>2];c[l+4>>2]=c[j+4>>2];c[l+8>>2]=c[j+8>>2];c[l+12>>2]=c[j+12>>2];l=(c[a>>2]|0)+(b-h<<4)|0;j=g+(h<<4)|0;c[l>>2]=c[j>>2];c[l+4>>2]=c[j+4>>2];c[l+8>>2]=c[j+8>>2];c[l+12>>2]=c[j+12>>2];h=h+1|0}return}function cv(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0;f=+h[b+8>>3];d=+h[b>>3];e=+K(+(+h[c+8>>3]-f),+(+h[c>>3]-d));d=+K(+(+h[a+8>>3]-f),+(+h[a>>3]-d));e=e-d;return +((e>0.0?e+-6.283185307179586:e)*.5+d)}function dv(a,b){a=a|0;b=b|0;var d=0;d=ww(24)|0;c[d+16>>2]=0;c[d>>2]=c[a>>2];c[d+4>>2]=c[a+4>>2];c[d+8>>2]=c[a+8>>2];c[d+12>>2]=c[a+12>>2];c[b+16>>2]=d;return d|0}function ev(b){b=b|0;var c=0,d=0,e=0,f=0,g=0;c=b;f=b;a:while(1){e=0;while(1){d=c;c=c+1|0;d=a[d>>0]|0;if(!(d<<24>>24))break a;if(e<<24>>24){g=5;break}if(d<<24>>24!=92)break;else e=1}b:do if((g|0)==5){g=0;switch(d<<24>>24|0){case 114:{d=13;break b}case 108:case 110:{d=10;break b}default:break b}}while(0);a[f>>0]=d;f=f+1|0}a[f>>0]=0;return b|0}function fv(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;e=c[b>>2]|0;while(1){g=a[e>>0]|0;if(!(g<<24>>24)){f=0;break}f=g<<24>>24;if(!(g<<24>>24==44|(XJ(f)|0)!=0)){h=5;break}e=e+1|0}a:do if((h|0)==5){switch(f|0){case 0:{f=0;break a}case 41:case 40:{e=e+1|0;break a}default:{}}h=d+4|0;i=d+8|0;while(1){if((gv(g<<24>>24)|0)<<24>>24){f=1;break a}f=c[h>>2]|0;if(f>>>0>=(c[i>>2]|0)>>>0){dm(d,1)|0;f=c[h>>2]|0}c[h>>2]=f+1;a[f>>0]=g;f=e+1|0;e=f;g=a[f>>0]|0}}while(0);c[b>>2]=e;return f|0}function gv(a){a=a|0;switch(a|0){case 0:case 44:case 41:case 40:{a=1;break}default:a=0}return a|0}function hv(a,b){a=a|0;b=b|0;return iv(c[a>>2]|0,c[a+160>>2]|0,c[a+156>>2]|0,b)|0}function iv(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0;o=l;l=l+160|0;k=o+20|0;m=o+16|0;n=o;c[k>>2]=0;c[m>>2]=0;cm(n,128,o+24|0);fm(n,f)|0;g=n+4|0;f=c[g>>2]|0;if(f>>>0>=(c[n+8>>2]|0)>>>0){dm(n,1)|0;f=c[g>>2]|0}a[f>>0]=0;h=c[n>>2]|0;c[g>>2]=h;i=b+300|0;j=b+296|0;f=0;g=h;a:while(1){if(f){f=1;break}f=FL(g,c[i>>2]|0,k)|0;if(!f){f=0;break}g=FL(f,c[j>>2]|0,m)|0;h=(g|0)!=0;if(h)f=FL(0,c[j>>2]|0,m)|0;else f=0;switch(((f|0)!=0&1)+(h&1)&3){case 2:{g=jv(b,g,0)|0;f=jv(b,f,e)|0;h=(g|0)>(f|0);f=(f&g|0)>-1&(((h?g:f)|0)>=(d|0)&((h?f:g)|0)<=(d|0));g=0;continue a}case 1:{f=(jv(b,g,d)|0)==(d|0);g=0;continue a}default:{f=0;g=0;continue a}}}gm(n);l=o;return f|0}function jv(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;h=a[d>>0]|0;if(!(h<<24>>24==97?(xJ(d,85419)|0)==0:0))f=3;a:do if((f|0)==3){if((kv(d)|0)<<24>>24){e=rM(d)|0;break}g=c[b+308>>2]|0;if(!g)e=-1;else{b=c[b+312>>2]|0;e=1;while(1){if((e|0)>(b|0)){e=-1;break a}f=c[g+(e<<2)>>2]|0;if(h<<24>>24==(a[f>>0]|0)?(xJ(d,f)|0)==0:0)break a;e=e+1|0}}}while(0);return e|0}function kv(b){b=b|0;var c=0;while(1){c=a[b>>0]|0;if(!(c<<24>>24)){b=1;break}if(((c&255)+-48|0)>>>0<10)b=b+1|0;else{b=0;break}}return b|0}function lv(a,b){a=a|0;b=b|0;if((+h[a+16>>3]>=+h[b>>3]?+h[b+16>>3]>=+h[a>>3]:0)?+h[a+24>>3]>=+h[b+8>>3]:0)a=+h[b+24>>3]>=+h[a+8>>3]&1;else a=0;return a|0}function mv(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0;a:do if((c[b+156>>2]|0)>=2?(f=FA(e,c[42211]|0,174181)|0,(hv(b,f)|0)<<24>>24==0):0)if(!(a[f>>0]|0))if(!(Um(d,e)|0))f=1;else{f=Um(d,e)|0;while(1){if(!f){f=0;break a}g=FA(f,c[42234]|0,174181)|0;if(!(a[g>>0]|0)){f=1;break a}if((hv(b,g)|0)<<24>>24){f=1;break a}f=Vm(d,f,e)|0}}else f=0;else f=1;while(0);return f|0}function nv(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=l;l=l+64|0;e=d+32|0;f=d;a=(c[a+16>>2]|0)+48|0;c[f>>2]=c[a>>2];c[f+4>>2]=c[a+4>>2];c[f+8>>2]=c[a+8>>2];c[f+12>>2]=c[a+12>>2];c[f+16>>2]=c[a+16>>2];c[f+20>>2]=c[a+20>>2];c[f+24>>2]=c[a+24>>2];c[f+28>>2]=c[a+28>>2];c[e>>2]=c[b>>2];c[e+4>>2]=c[b+4>>2];c[e+8>>2]=c[b+8>>2];c[e+12>>2]=c[b+12>>2];c[e+16>>2]=c[b+16>>2];c[e+20>>2]=c[b+20>>2];c[e+24>>2]=c[b+24>>2];c[e+28>>2]=c[b+28>>2];b=(lv(f,e)|0)&255;l=d;return b|0}function ov(a,d){a=a|0;d=d|0;var f=0.0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0.0,r=0,s=0,t=0,u=0.0,v=0.0;r=c[a+152>>2]|0;s=Vt(a)|0;c[s+4>>2]=2;c[s+8>>2]=d;c[s+12>>2]=8;if(r&16777216|0){if((e[(c[(ro(d)|0)+16>>2]|0)+178>>1]|0)>2){f=+h[(c[(c[d+16>>2]|0)+132>>2]|0)+16>>3]*72.0;f=+(~~(f+(f>=0.0?.5:-.5))|0)}else f=0.0;h[s+168>>3]=f}k=d+16|0;qv(a,c[(c[k>>2]|0)+104>>2]|0,d);do if(r&4259840|0){if((c[s+208>>2]|0)==0?(b[s+260>>1]&1)==0:0)break;p=By(d)|0;l=c[k>>2]|0;f=+h[l+16>>3];q=+h[l+24>>3];l=rv(d)|0;a:do if((p|2|0)==3){n=c[(c[k>>2]|0)+12>>2]|0;if(!((sv(n)|0)<<24>>24))g=0;else g=(c[n+4>>2]|l|0)!=0;if(!((r&524288|0)==0|((n|0)==0|g))){i=n+8|0;o=c[i>>2]|0;o=(o|0)<3?1:o;j=n+4|0;m=c[j>>2]|0;m=(m|0)>1?m:1;p=c[n+44>>2]|0;g=Im(d,87739)|0;if(!g)g=0;else g=rM(g)|0;g=(g+-4|0)>>>0>56?20:g;if(!(c[j>>2]|l)){c[s+264>>2]=0;i=vw(32)|0;g=c[k>>2]|0;v=+h[g+88>>3];h[i>>3]=f-v;u=+h[g+80>>3]*.5;h[i+8>>3]=q-u;h[i+16>>3]=v+f;h[i+24>>3]=u+q;g=2;break}i=c[i>>2]|0;if(((i|0)<3?+h[n+32>>3]==0.0:0)?+h[n+24>>3]==0.0:0){i=s+264|0;if(c[n>>2]|0){c[i>>2]=1;i=vw(32)|0;h[i>>3]=f;h[i+8>>3]=q;g=(m<<1)+-1|0;h[i+16>>3]=+h[p+(g<<4)>>3]+f;h[i+24>>3]=+h[p+(g<<4)+8>>3]+q;g=2;break}c[i>>2]=2;i=(m<<1)+-1|0;i=tv(+h[p+(i<<4)>>3],+h[p+(i<<4)+8>>3],g)|0;j=0;while(1){if((j|0)>=(g|0))break a;p=i+(j<<4)|0;h[p>>3]=+h[p>>3]+f;p=i+(j<<4)+8|0;h[p>>3]=+h[p>>3]+q;j=j+1|0}}m=O(i,m+-1|0)|0;c[s+264>>2]=2;if((i|0)<(g|0)){i=vw(o<<4)|0;g=0;while(1){if((g|0)>=(o|0)){g=o;break a}n=g+m|0;h[i+(g<<4)>>3]=+h[p+(n<<4)>>3]+f;h[i+(g<<4)+8>>3]=+h[p+(n<<4)+8>>3]+q;g=g+1|0}}else{l=(i|0)/(g|0)|0;i=vw(g<<4)|0;j=0;k=0;while(1){if((j|0)>=(g|0))break a;o=k+m|0;h[i+(j<<4)>>3]=+h[p+(o<<4)>>3]+f;h[i+(j<<4)+8>>3]=+h[p+(o<<4)+8>>3]+q;j=j+1|0;k=k+l|0}}}else t=31}else t=31;while(0);if((t|0)==31){c[s+264>>2]=0;i=vw(32)|0;g=c[k>>2]|0;h[i>>3]=f-+h[g+88>>3];v=+h[g+80>>3]*.5;h[i+8>>3]=q-v;h[i+16>>3]=+h[g+96>>3]+f;h[i+24>>3]=v+q;g=2}if(!(r&8192))fD(a,i,i,g)|0;c[s+272>>2]=i;c[s+268>>2]=g}while(0);ZE(Im(d,85048)|0);sD(a,d);return}function pv(a){a=a|0;tD(a);Wt(a);return}function qv(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0;m=l;l=l+144|0;j=m;f=Im(e,96264)|0;i=Im(e,96229)|0;k=Im(e,85204)|0;cm(j,128,m+16|0);if(!d)h=0;else h=c[d>>2]|0;if(!((f|0)!=0?(a[f>>0]|0)!=0:0))f=Im(e,96269)|0;g=Yt(b,e,j)|0;if(!i)d=0;else d=Zu(i,e)|0;Xt(b,h,f,d,k,g,e)|0;_I(d);gm(j);l=m;return}function rv(b){b=b|0;var d=0,e=0;b=GA(b,c[42201]|0,174181)|0;a:do if(!(a[b>>0]|0))b=0;else{Du(b)|0;b=0;d=168408;while(1){e=c[d>>2]|0;if(!e)break a;e=(xJ(e,95923)|0)==0;b=e?1:b;d=d+4|0}}while(0);return b|0}function sv(a){a=a|0;var b=0.0;if(((c[a+8>>2]|0)==4?(b=+h[a+16>>3],((~~(b+(b>=0.0?.5:-.5))|0)%90|0|0)==0):0)?+h[a+24>>3]==0.0:0)a=+h[a+32>>3]==0.0&1;else a=0;return a|0}function tv(a,b,c){a=+a;b=+b;c=c|0;var d=0.0,e=0,f=0.0,g=0;f=6.283185307179586/+(c|0);g=vw(c<<4)|0;d=0.0;e=0;while(1){if((e|0)>=(c|0))break;h[g+(e<<4)>>3]=+E(+d)*a;h[g+(e<<4)+8>>3]=+F(+d)*b;d=d+f;e=e+1|0}return g|0}function uv(b,d){b=b|0;d=d|0;var e=0;a:do if((c[b+156>>2]|0)>=2?(e=FA(d,ym(d,0,86583,0)|0,174181)|0,(hv(b,e)|0)<<24>>24==0):0)if(!(a[e>>0]|0)){e=co(d)|0;while(1){if(!e){e=0;break a}if((mv(b,d,e)|0)<<24>>24){e=1;break a}e=eo(d,e)|0}}else e=0;else e=1;while(0);return e|0}function vv(a,b){a=a|0;b=b|0;var d=0;d=Vt(a)|0;c[d+4>>2]=1;c[d+8>>2]=b;c[d+12>>2]=1;qv(a,c[(c[b+16>>2]|0)+12>>2]|0,b);mD(a,b);return}function wv(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0;b=Im(b,86479)|0;a:do if((b|0)!=0?(a[b>>0]|0)!=0:0){Du(b)|0;e=168408;b=0;while(1){while(1){f=c[e>>2]|0;if(!f){e=168408;break a}if(!(xJ(f,95923)|0)){g=10;break}if(!(xJ(f,91378)|0)){f=e;g=12;break}if(!(xJ(f,91385)|0)){f=e;g=14;break}if(!(xJ(f,91360)|0)){f=e;g=16;break}e=e+4|0}if((g|0)==10){e=e+4|0;b=b|1;continue}else if((g|0)==12){while(1){h=f;f=f+4|0;g=c[f>>2]|0;c[h>>2]=g;if(!g)break;else g=12}b=b|3;continue}else if((g|0)==14){while(1){g=f;f=f+4|0;h=c[f>>2]|0;c[g>>2]=h;if(!h)break;else g=14}b=b|64;continue}else if((g|0)==16){while(1){g=f;f=f+4|0;h=c[f>>2]|0;c[g>>2]=h;if(!h)break;else g=16}b=b|4;continue}}}else{e=0;b=0}while(0);c[d>>2]=b;return e|0}function xv(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,h=0,i=0,j=0,k=0,m=0;k=l;l=l+16|0;i=k;j=k+4|0;c[j>>2]=0;m=($t(b,0,j)|0)==0;j=c[j>>2]|0;if((m?(f=c[j>>2]|0,(f|0)>=2):0)?(h=j+8|0,(c[c[h>>2]>>2]|0)!=0):0){if((f|0)>2)_l(0,85446,i)|0;m=ww((rJ(b)|0)+1|0)|0;c[d>>2]=m;xK(m,c[c[h>>2]>>2]|0)|0;if(!(c[(c[h>>2]|0)+12>>2]|0))c[d+4>>2]=0;else{m=c[d>>2]|0;m=m+((rJ(m)|0)+1)|0;c[d+4>>2]=m;xK(m,c[(c[h>>2]|0)+12>>2]|0)|0}b=c[h>>2]|0;do if(!(a[b+8>>0]|0))if(!(a[b+20>>0]|0)){g[e>>2]=0.0;break}else{g[e>>2]=1.0-+g[b+16>>2];break}else c[e>>2]=c[b+4>>2];while(0);au(j);b=1}else{c[d>>2]=0;au(j);b=0}l=k;return b|0}function yv(a,b){a=a|0;b=b|0;nD(a,b);Wt(a);return}function zv(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,i=0,j=0,k=0.0,m=0.0,n=0,o=0.0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0;x=l;l=l+96|0;p=x+48|0;s=x+16|0;w=x+8|0;v=x;t=x+80|0;c[t>>2]=1e3;f=ww(16e3)|0;u=a+256|0;e=1;j=1;i=0;q=0;r=c[b+8>>2]|0;while(1){if((q|0)>=(c[b>>2]|0))break;d=c[r>>2]|0;a:do switch(d|0){case 1:case 0:{n=r+80|0;c[s>>2]=c[n>>2];c[s+4>>2]=c[n+4>>2];c[s+8>>2]=c[n+8>>2];c[s+12>>2]=c[n+12>>2];c[s+16>>2]=c[n+16>>2];c[s+20>>2]=c[n+20>>2];c[s+24>>2]=c[n+24>>2];c[s+28>>2]=c[n+28>>2];c[p>>2]=c[u>>2];c[p+4>>2]=c[u+4>>2];c[p+8>>2]=c[u+8>>2];c[p+12>>2]=c[u+12>>2];c[p+16>>2]=c[u+16>>2];c[p+20>>2]=c[u+20>>2];c[p+24>>2]=c[u+24>>2];c[p+28>>2]=c[u+28>>2];if(!(lv(s,p)|0))d=j;else{z=r+8|0;A=r+24|0;h[f>>3]=+h[z>>3]-+h[A>>3];n=r+16|0;y=r+32|0;h[f+8>>3]=+h[n>>3]-+h[y>>3];h[f+16>>3]=+h[A>>3]+ +h[z>>3];h[f+24>>3]=+h[y>>3]+ +h[n>>3];GD(a,f,2,(d|0)==0?j:0);d=j}break}case 3:case 2:{A=r+80|0;c[s>>2]=c[A>>2];c[s+4>>2]=c[A+4>>2];c[s+8>>2]=c[A+8>>2];c[s+12>>2]=c[A+12>>2];c[s+16>>2]=c[A+16>>2];c[s+20>>2]=c[A+20>>2];c[s+24>>2]=c[A+24>>2];c[s+28>>2]=c[A+28>>2];c[p>>2]=c[u>>2];c[p+4>>2]=c[u+4>>2];c[p+8>>2]=c[u+8>>2];c[p+12>>2]=c[u+12>>2];c[p+16>>2]=c[u+16>>2];c[p+20>>2]=c[u+20>>2];c[p+24>>2]=c[u+24>>2];c[p+28>>2]=c[u+28>>2];if(!(lv(s,p)|0))d=j;else{d=r+8|0;f=Av(f,t,c[d+4>>2]|0,c[d>>2]|0)|0;HD(a,f,c[d>>2]|0,(c[r>>2]|0)==2?j:0);d=j}break}case 5:case 4:{A=r+80|0;c[s>>2]=c[A>>2];c[s+4>>2]=c[A+4>>2];c[s+8>>2]=c[A+8>>2];c[s+12>>2]=c[A+12>>2];c[s+16>>2]=c[A+16>>2];c[s+20>>2]=c[A+20>>2];c[s+24>>2]=c[A+24>>2];c[s+28>>2]=c[A+28>>2];c[p>>2]=c[u>>2];c[p+4>>2]=c[u+4>>2];c[p+8>>2]=c[u+8>>2];c[p+12>>2]=c[u+12>>2];c[p+16>>2]=c[u+16>>2];c[p+20>>2]=c[u+20>>2];c[p+24>>2]=c[u+24>>2];c[p+28>>2]=c[u+28>>2];if(!(lv(s,p)|0))d=j;else{d=r+8|0;f=Av(f,t,c[d+4>>2]|0,c[d>>2]|0)|0;JD(a,f,c[d>>2]|0,0,0,(c[r>>2]|0)==4?j&255:0);d=j}break}case 6:{A=r+80|0;c[s>>2]=c[A>>2];c[s+4>>2]=c[A+4>>2];c[s+8>>2]=c[A+8>>2];c[s+12>>2]=c[A+12>>2];c[s+16>>2]=c[A+16>>2];c[s+20>>2]=c[A+20>>2];c[s+24>>2]=c[A+24>>2];c[s+28>>2]=c[A+28>>2];c[p>>2]=c[u>>2];c[p+4>>2]=c[u+4>>2];c[p+8>>2]=c[u+8>>2];c[p+12>>2]=c[u+12>>2];c[p+16>>2]=c[u+16>>2];c[p+20>>2]=c[u+20>>2];c[p+24>>2]=c[u+24>>2];c[p+28>>2]=c[u+28>>2];if(!(lv(s,p)|0))d=j;else{d=r+8|0;f=Av(f,t,c[d+4>>2]|0,c[d>>2]|0)|0;KD(a,f,c[d>>2]|0);d=j}break}case 7:{A=r+80|0;c[s>>2]=c[A>>2];c[s+4>>2]=c[A+4>>2];c[s+8>>2]=c[A+8>>2];c[s+12>>2]=c[A+12>>2];c[s+16>>2]=c[A+16>>2];c[s+20>>2]=c[A+20>>2];c[s+24>>2]=c[A+24>>2];c[s+28>>2]=c[A+28>>2];c[p>>2]=c[u>>2];c[p+4>>2]=c[u+4>>2];c[p+8>>2]=c[u+8>>2];c[p+12>>2]=c[u+12>>2];c[p+16>>2]=c[u+16>>2];c[p+20>>2]=c[u+20>>2];c[p+24>>2]=c[u+24>>2];c[p+28>>2]=c[u+28>>2];if(!(lv(s,p)|0))d=j;else{h[f>>3]=+h[r+8>>3];h[f+8>>3]=+h[r+16>>3];d=c[r+112>>2]|0;c[p>>2]=c[f>>2];c[p+4>>2]=c[f+4>>2];c[p+8>>2]=c[f+8>>2];c[p+12>>2]=c[f+12>>2];AD(a,p,d);d=j}break}case 8:{DD(a,c[r+8>>2]|0);d=1;break}case 9:{BD(a,c[r+8>>2]|0);d=1;break}case 13:{if((c[r+8>>2]|0)!=2){d=r+16|0;z=c[d+36>>2]|0;A=c[z+12>>2]|0;o=+g[z+8>>2];d=~~(+K(+(+h[r+40>>3]-+h[r+24>>3]),+(+h[r+32>>3]-+h[d>>3]))*57.29577951308232);DD(a,c[z+4>>2]|0);ED(a,A,d,o);d=2;break a}A=c[r+68>>2]|0;j=c[A+4>>2]|0;n=c[A+12>>2]|0;o=+g[A+8>>2];k=+h[r+40>>3];m=+h[r+16>>3];if(k==m?+h[r+48>>3]==+h[r+24>>3]:0)d=0;else d=~~(+H(+((m-k)/+h[r+32>>3]))*57.29577951308232);DD(a,j);ED(a,n,d,o);d=3;break}case 14:{_l(0,85512,v)|0;d=j;break}case 12:{if(!e){e=0;d=j}else{_l(0,85552,w)|0;e=0;d=j}break}case 11:{Du(c[r+8>>2]|0)|0;FD(a,168408);i=168408;d=j;break}default:d=j}while(0);j=d;q=q+1|0;r=r+120|0}if(i|0)FD(a,c[(c[a>>2]|0)+336>>2]|0);_I(f);l=x;return}function Av(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;g=c[b>>2]|0;f=g<<1;f=(f|0)>(e|0)?f:e;if((g|0)<(e|0)){a=yw(a,f<<4)|0;c[b>>2]=f}b=0;while(1){if((b|0)>=(e|0))break;h[a+(b<<4)>>3]=+h[d+(b*24|0)>>3];h[a+(b<<4)+8>>3]=+h[d+(b*24|0)+8>>3];b=b+1|0}return a|0}function Bv(a,b){a=a|0;b=b|0;var d=0;d=c[b>>2]|0;c[a>>2]=c[b+4>>2];c[a+4>>2]=d;return}function Cv(b,d){b=b|0;d=d|0;var e=0,f=0,g=0;g=d+16|0;f=1;while(1){d=c[g>>2]|0;if((f|0)>(c[d+180>>2]|0))break;e=c[(c[d+184>>2]|0)+(f<<2)>>2]|0;Cv(b,e);d=Im(e,122540)|0;if(d|0?a[d>>0]|0:0)BD(b,d);d=Im(e,122531)|0;if(d|0?a[d>>0]|0:0)BD(b,d);d=Im(e,85423)|0;if(d|0?a[d>>0]|0:0)BD(b,d);d=Im(e,86469)|0;if(d|0?a[d>>0]|0:0)DD(b,d);d=Im(e,86503)|0;if(d|0?a[d>>0]|0:0)BD(b,d);f=f+1|0}return}function Dv(a){a=a|0;var b=0,d=0,e=0;b=c[42172]|0;if(!b){b=Ql(19684,c[4345]|0)|0;c[42172]=b}if(!(bb[c[b>>2]&31](b,a,4)|0)){d=c[42172]|0;e=c[d>>2]|0;b=GL(a)|0;bb[e&31](d,b,1)|0;b=1}else b=0;return b|0}function Ev(a,b,c){a=a|0;b=b|0;c=c|0;_I(b);return}function Fv(a){a=a|0;var b=0;b=c[42173]|0;if(!a){if((b|0)>0?(b=b+-1|0,c[42173]=b,(b|0)==0):0){bL(1,c[42174]|0)|0;_I(c[42174]|0)}}else{c[42173]=b+1;if(!b){c[42174]=GL(bL(1,0)|0)|0;bL(1,134865)|0}}return}function Gv(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0.0;u=l;l=l+96|0;r=u+72|0;q=u+56|0;p=u+48|0;t=u+32|0;s=u+24|0;e=u+8|0;d=u;if(0)xA();do if((No(b,122277,0,1)|0)!=0?(o=b+16|0,(c[(c[o>>2]|0)+8>>2]|0)!=0):0){Hv(b);Iv(a,b);Jv(a,b);Fv(1);j=a+56|0;k=a+184|0;m=a+192|0;n=a+28|0;i=Cr(a)|0;a:while(1){if(!i){g=33;break}d=c[j>>2]|0;if(!d){c[i+20>>2]=0;d=0}else{c[i+20>>2]=c[d+8>>2];d=c[d+12>>2]|0}c[i+24>>2]=d;c[i+12>>2]=a;c[i+28>>2]=c[k>>2];c[i+620>>2]=24748;c[i+624>>2]=14;if(!(c[(c[o>>2]|0)+8>>2]|0)){g=13;break}e=i+52|0;g=bD(i,c[e>>2]|0)|0;c[i+56>>2]=g;switch(g|0){case 999:{g=16;break a}case 21:{d=1;break}case 24:{d=520;break}default:d=Kv(b)|0}f=i+152|0;c[f>>2]=c[f>>2]|d;d=c[m>>2]|0;do if(!d)g=24;else{if(c[d+152>>2]&32|0?(xJ(c[e>>2]|0,c[d+52>>2]|0)|0)==0:0){d=c[42175]|0;if(!d){g=27;break}c[d+8>>2]=i;c[i+36>>2]=c[d+36>>2];g=29;break}dD(d);c[m>>2]=0;c[n>>2]=0;g=24}while(0);if((g|0)==24){c[42175]=0;g=27}if((g|0)==27?(g=0,(cD(i)|0)==0):0){c[m>>2]=i;g=29}if((g|0)==29){c[i+8>>2]=0;c[i+104>>2]=24860;Lv(i);Mv(i);Nv(i,b);Ov(i,b);Pv(i,b);if(!(c[f>>2]&128))gu(i,b);c[42175]=i}i=Dr(a)|0}if((g|0)==13){_l(1,85710,s)|0;Fv(0);if(!0){d=-1;break}d=c[13918]|0;s=Dn(b)|0;v=+yA();c[t>>2]=s;h[t+8>>3]=v;zL(d,85681,t)|0;d=-1;break}else if((g|0)==16){c[p>>2]=c[e>>2];_l(1,85731,p)|0;Fv(0);if(!0){d=-1;break}d=c[13918]|0;t=Dn(b)|0;v=+yA();c[q>>2]=t;h[q+8>>3]=v;zL(d,85681,q)|0;d=-1;break}else if((g|0)==33){Fv(0);if(!0){d=0;break}d=c[13918]|0;t=Dn(b)|0;v=+yA();c[r>>2]=t;h[r+8>>3]=v;zL(d,85681,r)|0;d=0;break}}else g=5;while(0);if((g|0)==5){_l(1,85633,d)|0;if(!0)d=-1;else{d=c[13918]|0;t=Dn(b)|0;v=+yA();c[e>>2]=t;h[e+8>>3]=v;zL(d,85681,e)|0;d=-1}}l=u;return d|0}function Hv(a){a=a|0;var b=0;b=co(a)|0;while(1){if(!b)break;Uv(a,b);b=eo(a,b)|0}return}function Iv(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0.0;o=l;l=l+32|0;k=o+24|0;f=o+16|0;j=o+8|0;n=o;c[b+168>>2]=d;g=b+293|0;a[g>>0]=0;e=Im(d,90530)|0;if(e|0?(c[f>>2]=j,c[f+4>>2]=n,i=cM(e,90537,f)|0,(i|0)>0):0){p=+h[j>>3]*72.0;e=b+208|0;h[e>>3]=p;h[b+200>>3]=p;if((i|0)!=1)h[e>>3]=+h[n>>3]*72.0;a[g>>0]=1}f=b+292|0;a[f>>0]=0;e=Im(d,86133)|0;if(e|0?(c[k>>2]=j,c[k+4>>2]=n,m=cM(e,90537,k)|0,(m|0)>0):0){p=+h[j>>3]*72.0;e=b+224|0;h[e>>3]=p;h[b+216>>3]=p;if((m|0)!=1)h[e>>3]=+h[n>>3]*72.0;a[f>>0]=1}e=b+294|0;a[e>>0]=0;f=b+232|0;g=d+16|0;n=(c[(c[g>>2]|0)+8>>2]|0)+48|0;c[f>>2]=c[n>>2];c[f+4>>2]=c[n+4>>2];c[f+8>>2]=c[n+8>>2];c[f+12>>2]=c[n+12>>2];f=c[(c[g>>2]|0)+8>>2]|0;if(+h[f+48>>3]>.001?+h[f+56>>3]>.001:0)a[e>>0]=1;c[b+288>>2]=a[f+81>>0]|0?90:0;e=b+196|0;c[e>>2]=86137;f=Im(d,86140)|0;if(f|0?a[f>>0]|0:0)c[e>>2]=f;n=b+256|0;m=(c[g>>2]|0)+16|0;c[n>>2]=c[m>>2];c[n+4>>2]=c[m+4>>2];c[n+8>>2]=c[m+8>>2];c[n+12>>2]=c[m+12>>2];c[n+16>>2]=c[m+16>>2];c[n+20>>2]=c[m+20>>2];c[n+24>>2]=c[m+24>>2];c[n+28>>2]=c[m+28>>2];c[42185]=ym(d,0,86535,0)|0;c[42186]=ym(d,0,86520,0)|0;c[b+320>>2]=GA(0,c[42195]|0,93027)|0;h[b+328>>3]=+EA(0,c[42194]|0,14.0,1.0);c[b+336>>2]=19720;c[b+188>>2]=Dn(d)|0;l=o;return}function Jv(b,d){b=b|0;d=d|0;var e=0,f=0,g=0;e=b+304|0;f=c[e>>2]|0;if(f|0){_I(f);c[e>>2]=0}f=b+308|0;e=c[f>>2]|0;if(e|0){_I(e);c[f>>2]=0}g=b+316|0;e=c[g>>2]|0;if(e|0){_I(e);c[g>>2]=0}e=Im(d,85884)|0;if(e){c[b+312>>2]=Sv(b,d,e)|0;e=Im(d,85891)|0;if(e|0?a[e>>0]|0:0)c[g>>2]=Tv(b,e)|0}else{c[f>>2]=0;c[b+312>>2]=1}return}function Kv(b){b=b|0;b=Im(b,85852)|0;a:do if(!b)b=0;else switch(a[b>>0]|0){case 110:{if(!(xJ(b+1|0,85864)|0))b=1;else{b=0;break a}break}case 101:{if(!(xJ(b+1|0,85874)|0))b=16;else{b=0;break a}break}default:{b=0;break a}}while(0);return b|0}function Lv(b){b=b|0;var d=0.0,e=0;e=c[b>>2]|0;if(!(a[e+292>>0]|0)){if((c[b+56>>2]|0)==300)d=+h[(c[b+68>>2]|0)+8>>3];else d=4.0;h[b+248>>3]=d;h[b+240>>3]=d}else{b=b+240|0;e=e+216|0;c[b>>2]=c[e>>2];c[b+4>>2]=c[e+4>>2];c[b+8>>2]=c[e+8>>2];c[b+12>>2]=c[e+12>>2]}return}function Mv(b){b=b|0;var d=0;d=c[b>>2]|0;a:do if(!(a[d+293>>0]|0))switch(c[b+56>>2]|0){case 300:{d=b+416|0;b=(c[b+84>>2]|0)+8|0;c[d>>2]=c[b>>2];c[d+4>>2]=c[b+4>>2];c[d+8>>2]=c[b+8>>2];c[d+12>>2]=c[b+12>>2];break a}case 30:case 21:case 22:case 4:case 3:case 2:{h[b+424>>3]=36.0;h[b+416>>3]=36.0;break a}default:{d=b+416|0;c[d>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;break a}}else{b=b+416|0;d=d+200|0;c[b>>2]=c[d>>2];c[b+4>>2]=c[d+4>>2];c[b+8>>2]=c[d+8>>2];c[b+12>>2]=c[d+12>>2]}while(0);return}function Nv(b,d){b=b|0;d=d|0;var e=0.0,f=0;f=c[(c[b>>2]|0)+192>>2]|0;e=+h[(c[(c[d+16>>2]|0)+8>>2]|0)+24>>3];do if(!(e!=0.0)){if(f|0?a[f+128>>0]|0:0){b=b+432|0;f=f+112|0;c[b>>2]=c[f>>2];c[b+4>>2]=c[f+4>>2];c[b+8>>2]=c[f+8>>2];c[b+12>>2]=c[f+12>>2];break}d=b+432|0;if((c[b+56>>2]|0)==300){b=(c[b+84>>2]|0)+40|0;c[d>>2]=c[b>>2];c[d+4>>2]=c[b+4>>2];c[d+8>>2]=c[b+8>>2];c[d+12>>2]=c[b+12>>2];break}else{h[b+440>>3]=96.0;h[d>>3]=96.0;break}}else{h[b+440>>3]=e;h[b+432>>3]=e}while(0);return}function Ov(b,d){b=b|0;d=d|0;var e=0.0,f=0.0,g=0,i=0.0,j=0.0,k=0.0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0;A=l;l=l+112|0;t=A+80|0;u=A+56|0;s=A+40|0;v=A+32|0;w=A+24|0;x=A+16|0;y=A+8|0;z=A;m=c[b>>2]|0;o=+h[m+272>>3];q=+h[m+280>>3];p=+h[m+256>>3];r=+h[m+264>>3];f=+h[b+240>>3];e=p-f;h[b+208>>3]=e;i=+h[b+248>>3];j=r-i;h[b+216>>3]=j;f=f+o;h[b+224>>3]=f;i=i+q;h[b+232>>3]=i;e=f-e;j=i-j;h[x>>3]=1.0;g=c[(c[d+16>>2]|0)+8>>2]|0;i=+h[g+64>>3];do if(i>.001?(k=+h[g+72>>3],k>.001):0){e=e==0.0?i:e;f=j==0.0?k:j;if(!(if&(i>e&(a[g+80>>0]|0)!=0)):0){k=e;j=f;i=1.0;break}n=i/e>3]=i;k=e;j=f}else{k=e;i=1.0}while(0);f=(p+o)*.5;h[y>>3]=f;e=(r+q)*.5;h[z>>3]=e;c[b+360>>2]=c[m+288>>2];k=i*k;h[v>>3]=k;j=i*j;h[w>>3]=j;g=Im(d,85783)|0;if(g){m=ZI((rJ(g)|0)+1|0)|0;n=ZI((rJ(g)|0)+1|0)|0;c[s>>2]=v;c[s+4>>2]=w;c[s+8>>2]=x;c[s+12>>2]=m;do if((cM(g,85792,s)|0)==4){g=no(c[d+60>>2]|0,m,0)|0;if(g|0){u=c[g+16>>2]|0;h[y>>3]=+h[u+16>>3];h[z>>3]=+h[u+24>>3]}}else{c[u>>2]=v;c[u+4>>2]=w;c[u+8>>2]=x;c[u+12>>2]=m;c[u+16>>2]=n;if((cM(g,85812,u)|0)!=4){c[t>>2]=v;c[t+4>>2]=w;c[t+8>>2]=x;c[t+12>>2]=y;c[t+16>>2]=z;cM(g,85832,t)|0;break}g=no(c[d+60>>2]|0,m,0)|0;if(g|0){u=c[g+16>>2]|0;h[y>>3]=+h[u+16>>3];h[z>>3]=+h[u+24>>3]}}while(0);_I(m);_I(n);k=+h[v>>3];j=+h[w>>3];i=+h[x>>3];f=+h[y>>3];e=+h[z>>3]}h[b+368>>3]=k;h[b+376>>3]=j;h[b+352>>3]=i;h[b+336>>3]=f;h[b+344>>3]=e;l=A;return}function Pv(b,d){b=b|0;d=d|0;var e=0,f=0,g=0.0,i=0.0,j=0,k=0.0,m=0.0,n=0.0,o=0.0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0.0,P=0.0,Q=0.0;M=l;l=l+224|0;J=M+200|0;z=M+168|0;E=M+144|0;I=M+120|0;F=M+96|0;G=M+64|0;e=M+184|0;v=M+176|0;w=M+160|0;y=M+136|0;x=M+112|0;A=M+80|0;B=M+48|0;C=M+32|0;D=M+16|0;K=M+8|0;L=M;u=c[b>>2]|0;c[G>>2]=0;c[G+4>>2]=0;c[G+8>>2]=0;c[G+12>>2]=0;H=b+368|0;c[I>>2]=c[H>>2];c[I+4>>2]=c[H+4>>2];c[I+8>>2]=c[H+8>>2];c[I+12>>2]=c[H+12>>2];H=b+360|0;if(c[H>>2]|0){c[J>>2]=c[I>>2];c[J+4>>2]=c[I+4>>2];c[J+8>>2]=c[I+8>>2];c[J+12>>2]=c[I+12>>2];Qv(e,J);c[I>>2]=c[e>>2];c[I+4>>2]=c[e+4>>2];c[I+8>>2]=c[e+8>>2];c[I+12>>2]=c[e+12>>2]}t=b+416|0;c[F>>2]=c[t>>2];c[F+4>>2]=c[t+4>>2];c[F+8>>2]=c[t+8>>2];c[F+12>>2]=c[t+12>>2];if((a[u+294>>0]|0)!=0?(c[b+152>>2]&32|0)!=0:0){i=+h[u+232>>3]-+h[F>>3]*2.0;h[E>>3]=i;k=+h[u+240>>3]-+h[F+8>>3]*2.0;p=E+8|0;h[p>>3]=k;if(!(i<.0001)){o=+h[I>>3];e=~~(o/i);f=b+164|0;c[f>>2]=e;if(o-i*+(e|0)>.0001){e=e+1|0;c[f>>2]=e}}else{c[b+164>>2]=1;e=1}if(!(k<.0001)){g=+h[I+8>>3];f=~~(g/k);j=b+168|0;c[j>>2]=f;if(g-k*+(f|0)>.0001){f=f+1|0;c[j>>2]=f}}else{c[b+168>>2]=1;f=1;g=+h[I+8>>3]}c[b+204>>2]=O(f,e)|0;o=+h[(+h[I>>3]>3];h[I>>3]=o;e=p;f=I;m=+h[(g>3];g=o;j=21}else{if(c[b+68>>2]|0){e=c[b+84>>2]|0;i=+h[e+24>>3]-+h[F>>3]*2.0;i=i<0.0?0.0:i;h[E>>3]=i;o=+h[e+32>>3]-+h[F+8>>3]*2.0;e=E+8|0;h[e>>3]=o;if(o<0.0){f=E;j=17}else e=E}else{h[E+8>>3]=0.0;f=E;e=E;j=17}if((j|0)==17){h[e>>3]=0.0;e=f;i=+h[f>>3]}c[b+204>>2]=1;c[b+168>>2]=1;c[b+164>>2]=1;g=+h[I>>3];if(i>3]=g;i=g}e=E+8|0;k=+h[e>>3];m=+h[I+8>>3];if(k>3]=m;r=e;m=+h[e>>3]}n=+h[F>>3];s=b+432|0;k=+h[s>>3]*.013888888888888888*(n*2.0+i);c[b+448>>2]=~~(k+(k>=0.0?.5:-.5));q=F+8|0;k=+h[q>>3];t=b+440|0;o=+h[t>>3]*.013888888888888888*(k*2.0+m);c[b+452>>2]=~~(o+(o>=0.0?.5:-.5));j=b+188|0;p=b+180|0;e=b+172|0;f=u+196|0;c[e>>2]=0;c[e+4>>2]=0;c[e+8>>2]=0;c[e+12>>2]=0;c[e+16>>2]=0;c[e+20>>2]=0;Rv(v,b,a[c[f>>2]>>0]|0);u=v;v=c[u+4>>2]|0;e=p;c[e>>2]=c[u>>2];c[e+4>>2]=v;Rv(w,b,a[(c[f>>2]|0)+1>>0]|0);e=w;w=c[e>>2]|0;e=c[e+4>>2]|0;v=j;c[v>>2]=w;c[v+4>>2]=e;w=(c[p>>2]|0)+w|0;if(!((((w|0)>-1?w:0-w|0)|0)==1?(w=(c[b+184>>2]|0)+e|0,(((w|0)>-1?w:0-w|0)|0)==1):0)){Rv(y,b,66);v=y;y=c[v+4>>2]|0;w=p;c[w>>2]=c[v>>2];c[w+4>>2]=y;Rv(x,b,76);w=x;x=c[w+4>>2]|0;y=j;c[y>>2]=c[w>>2];c[y+4>>2]=x;c[z>>2]=c[f>>2];_l(0,85763,z)|0}if(a[(c[(c[d+16>>2]|0)+8>>2]|0)+82>>0]|0){if(i>g){m=(i-g)*.5;h[G>>3]=m}else m=0.0;i=+h[r>>3];o=+h[I+8>>3];if(i>o){i=(i-o)*.5;h[G+8>>3]=i}else i=0.0}else{i=0.0;m=0.0}if(!(c[H>>2]|0))j=1;else{c[J>>2]=c[I>>2];c[J+4>>2]=c[I+4>>2];c[J+8>>2]=c[I+8>>2];c[J+12>>2]=c[I+12>>2];Qv(A,J);c[I>>2]=c[A>>2];c[I+4>>2]=c[A+4>>2];c[I+8>>2]=c[A+8>>2];c[I+12>>2]=c[A+12>>2];c[J>>2]=c[E>>2];c[J+4>>2]=c[E+4>>2];c[J+8>>2]=c[E+8>>2];c[J+12>>2]=c[E+12>>2];Qv(B,J);c[E>>2]=c[B>>2];c[E+4>>2]=c[B+4>>2];c[E+8>>2]=c[B+8>>2];c[E+12>>2]=c[B+12>>2];c[J>>2]=c[F>>2];c[J+4>>2]=c[F+4>>2];c[J+8>>2]=c[F+8>>2];c[J+12>>2]=c[F+12>>2];Qv(C,J);c[F>>2]=c[C>>2];c[F+4>>2]=c[C+4>>2];c[F+8>>2]=c[C+8>>2];c[F+12>>2]=c[C+12>>2];c[J>>2]=c[G>>2];c[J+4>>2]=c[G+4>>2];c[J+8>>2]=c[G+8>>2];c[J+12>>2]=c[G+12>>2];Qv(D,J);c[G>>2]=c[D>>2];c[G+4>>2]=c[D+4>>2];c[G+8>>2]=c[D+8>>2];c[G+12>>2]=c[D+12>>2];n=+h[F>>3];m=+h[G>>3];k=+h[q>>3];i=+h[G+8>>3];g=+h[I>>3];j=(c[H>>2]|0)==0}o=m+n;h[b+384>>3]=o;P=i+k;h[b+392>>3]=P;N=m+n+g;h[b+400>>3]=N;Q=+h[I+8>>3];n=i+k+Q;h[b+408>>3]=n;m=+h[b+352>>3];h[b+320>>3]=g/m;h[b+328>>3]=Q/m;m=+h[s>>3];o=o*.013888888888888888*m;f=b+456|0;c[f>>2]=~~(o+(o>=0.0?.5:-.5));o=+h[t>>3];k=P*.013888888888888888*o;c[b+460>>2]=~~(k+(k>=0.0?.5:-.5));m=N*.013888888888888888*m;e=b+464|0;c[e>>2]=~~(m+(m>=0.0?.5:-.5));o=n*.013888888888888888*o;c[b+468>>2]=~~(o+(o>=0.0?.5:-.5));if(!j){c[J>>2]=c[f>>2];c[J+4>>2]=c[f+4>>2];Bv(K,J);I=K;K=c[I+4>>2]|0;b=f;c[b>>2]=c[I>>2];c[b+4>>2]=K;c[J>>2]=c[e>>2];c[J+4>>2]=c[e+4>>2];Bv(L,J);b=L;K=c[b+4>>2]|0;L=e;c[L>>2]=c[b>>2];c[L+4>>2]=K}l=M;return}function Qv(a,b){a=a|0;b=b|0;var c=0.0;c=+h[b>>3];h[a>>3]=+h[b+8>>3];h[a+8>>3]=c;return}function Rv(a,b,d){a=a|0;b=b|0;d=d|0;d=(d<<24>>24)+-66|0;switch(d>>>1|d<<31|0){case 9:{c[b+176>>2]=(c[b+168>>2]|0)+-1;b=0;d=-1;break}case 0:{b=0;d=1;break}case 5:{b=1;d=0;break}case 8:{c[b+172>>2]=(c[b+164>>2]|0)+-1;b=-1;d=0;break}default:{b=0;d=0}}c[a>>2]=b;c[a+4>>2]=d;return}function Sv(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;j=l;l=l+16|0;g=j;f=Im(d,86004)|0;i=b+296|0;c[i>>2]=(f|0)==0?86013:f;d=Im(d,86017)|0;f=b+300|0;d=(d|0)==0?86030:d;c[f>>2]=d;d=JL(c[i>>2]|0,d)|0;if(d|0){c[g>>2]=a[d>>0];_l(0,86032,g)|0;c[f>>2]=174181}d=GL(e)|0;c[b+304>>2]=d;h=b+308|0;f=0;b=0;while(1){e=DL(d,c[i>>2]|0)|0;if(!e)break;g=b+1|0;if((b|0)<(f|0))d=c[h>>2]|0;else{f=f+128|0;d=c[h>>2]|0;if(!d)d=ww(f<<2)|0;else d=yw(d,f<<2)|0;c[h>>2]=d}c[d+(g<<2)>>2]=e;b=g;d=0}if(b|0){i=yw(c[h>>2]|0,(b<<2)+8|0)|0;c[h>>2]=i;c[i>>2]=0;c[(c[h>>2]|0)+(b+1<<2)>>2]=0}l=j;return b|0}function Tv(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;k=l;l=l+16|0;j=k;i=a+312|0;d=ww((c[i>>2]<<2)+8|0)|0;e=0;h=1;while(1){g=c[i>>2]|0;if((h|0)>(g|0))break;f=e+1|0;if((iv(a,h,g,b)|0)<<24>>24){c[d+(f<<2)>>2]=h;e=f}h=h+1|0}if(!e){c[j>>2]=b;_l(0,85903,j)|0;_I(d);d=0}else{c[d>>2]=e;c[d+(e+1<<2)>>2]=(c[i>>2]|0)+1}l=k;return d|0}function Uv(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,g=0.0;d=c[b+16>>2]|0;g=+h[d+16>>3];h[d+48>>3]=g-+h[d+88>>3];e=+h[d+24>>3];f=+h[d+80>>3]*.5;h[d+56>>3]=e-f;h[d+64>>3]=+h[d+96>>3]+g;h[d+72>>3]=f+e;b=Pm(a,b)|0;while(1){if(!b)break;Vv(b);b=Rm(a,b)|0}return}function Vv(a){a=a|0;a=c[(c[a+16>>2]|0)+8>>2]|0;if(a|0)Wv(a);return}function Wv(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;C=l;l=l+240|0;v=C+192|0;u=C+176|0;w=C+64|0;x=C+32|0;y=C;z=C+144|0;A=C+112|0;B=a+4|0;if((c[B>>2]|0)<=0)ma(86171,84925,3994,86185);b=c[a>>2]|0;d=w;e=b;f=d+48|0;do{c[d>>2]=c[e>>2];d=d+4|0;e=e+4|0}while((d|0)<(f|0));d=v;e=b;f=d+48|0;do{c[d>>2]=c[e>>2];d=d+4|0;e=e+4|0}while((d|0)<(f|0));Xv(x,v);i=x+8|0;j=y+8|0;k=x+16|0;m=y+16|0;n=x+24|0;o=y+24|0;p=w+8|0;q=w+12|0;r=w+32|0;s=w+4|0;t=w+16|0;g=0;while(1){if((g|0)>=(c[B>>2]|0))break;if((g|0)>0){b=(c[a>>2]|0)+(g*48|0)|0;d=w;e=b;f=d+48|0;do{c[d>>2]=c[e>>2];d=d+4|0;e=e+4|0}while((d|0)<(f|0));d=v;e=b;f=d+48|0;do{c[d>>2]=c[e>>2];d=d+4|0;e=e+4|0}while((d|0)<(f|0));Xv(y,v);h[x>>3]=+h[(+h[x>>3]<+h[y>>3]?x:y)>>3];h[i>>3]=+h[(+h[i>>3]<+h[j>>3]?x:y)+8>>3];h[k>>3]=+h[(+h[k>>3]>+h[m>>3]?x:y)+16>>3];h[n>>3]=+h[(+h[n>>3]>+h[o>>3]?x:y)+24>>3]}b=c[p>>2]|0;if(b|0){f=c[w>>2]|0;c[u>>2]=c[t>>2];c[u+4>>2]=c[t+4>>2];c[u+8>>2]=c[t+8>>2];c[u+12>>2]=c[t+12>>2];c[v>>2]=c[f>>2];c[v+4>>2]=c[f+4>>2];c[v+8>>2]=c[f+8>>2];c[v+12>>2]=c[f+12>>2];Rt(z,u,v,1.0,b);c[y>>2]=c[z>>2];c[y+4>>2]=c[z+4>>2];c[y+8>>2]=c[z+8>>2];c[y+12>>2]=c[z+12>>2];c[y+16>>2]=c[z+16>>2];c[y+20>>2]=c[z+20>>2];c[y+24>>2]=c[z+24>>2];c[y+28>>2]=c[z+28>>2];h[x>>3]=+h[(+h[x>>3]<+h[y>>3]?x:y)>>3];h[i>>3]=+h[(+h[i>>3]<+h[j>>3]?x:y)+8>>3];h[k>>3]=+h[(+h[k>>3]>+h[m>>3]?x:y)+16>>3];h[n>>3]=+h[(+h[n>>3]>+h[o>>3]?x:y)+24>>3]}b=c[q>>2]|0;if(b|0){f=(c[w>>2]|0)+((c[s>>2]|0)+-1<<4)|0;c[u>>2]=c[r>>2];c[u+4>>2]=c[r+4>>2];c[u+8>>2]=c[r+8>>2];c[u+12>>2]=c[r+12>>2];c[v>>2]=c[f>>2];c[v+4>>2]=c[f+4>>2];c[v+8>>2]=c[f+8>>2];c[v+12>>2]=c[f+12>>2];Rt(A,u,v,1.0,b);c[y>>2]=c[A>>2];c[y+4>>2]=c[A+4>>2];c[y+8>>2]=c[A+8>>2];c[y+12>>2]=c[A+12>>2];c[y+16>>2]=c[A+16>>2];c[y+20>>2]=c[A+20>>2];c[y+24>>2]=c[A+24>>2];c[y+28>>2]=c[A+28>>2];h[x>>3]=+h[(+h[x>>3]<+h[y>>3]?x:y)>>3];h[i>>3]=+h[(+h[i>>3]<+h[j>>3]?x:y)+8>>3];h[k>>3]=+h[(+h[k>>3]>+h[m>>3]?x:y)+16>>3];h[n>>3]=+h[(+h[n>>3]>+h[o>>3]?x:y)+24>>3]}g=g+1|0}B=a+8|0;c[B>>2]=c[x>>2];c[B+4>>2]=c[x+4>>2];c[B+8>>2]=c[x+8>>2];c[B+12>>2]=c[x+12>>2];c[B+16>>2]=c[x+16>>2];c[B+20>>2]=c[x+20>>2];c[B+24>>2]=c[x+24>>2];c[B+28>>2]=c[x+28>>2];l=C;return}function Xv(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0;n=l;l=l+48|0;i=n+32|0;j=n;k=c[b+4>>2]|0;if((k|0)<=0)ma(86201,84925,3968,86213);if(((k>>>0)%3|0|0)!=1)ma(86223,84925,3969,86213);m=j+16|0;d=c[b>>2]|0;c[m>>2]=c[d>>2];c[m+4>>2]=c[d+4>>2];c[m+8>>2]=c[d+8>>2];c[m+12>>2]=c[d+12>>2];c[j>>2]=c[d>>2];c[j+4>>2]=c[d+4>>2];c[j+8>>2]=c[d+8>>2];c[j+12>>2]=c[d+12>>2];e=i+8|0;f=j+8|0;g=j+24|0;b=1;while(1){if((b|0)>=(k|0))break;p=+h[d+(b<<4)+8>>3];t=b+1|0;o=+h[d+(t<<4)+8>>3];r=(+h[d+(t<<4)>>3]+ +h[d+(b<<4)>>3])*.5;h[i>>3]=r;p=(o+p)*.5;h[e>>3]=p;o=+h[(+h[j>>3]>3];h[j>>3]=o;s=+h[(+h[f>>3]>3];h[f>>3]=s;r=+h[(+h[m>>3]>r?m:i)>>3];h[m>>3]=r;p=+h[(+h[g>>3]>p?m:i)+8>>3];h[g>>3]=p;t=d+(b+2<<4)|0;c[i>>2]=c[t>>2];c[i+4>>2]=c[t+4>>2];c[i+8>>2]=c[t+8>>2];c[i+12>>2]=c[t+12>>2];q=+h[i>>3];h[j>>3]=+h[(o>3];o=+h[e>>3];h[f>>3]=+h[(s>3];h[m>>3]=+h[(r>q?m:i)>>3];h[g>>3]=+h[(p>o?m:i)+8>>3];b=b+3|0}c[a>>2]=c[j>>2];c[a+4>>2]=c[j+4>>2];c[a+8>>2]=c[j+8>>2];c[a+12>>2]=c[j+12>>2];c[a+16>>2]=c[j+16>>2];c[a+20>>2]=c[j+20>>2];c[a+24>>2]=c[j+24>>2];c[a+28>>2]=c[j+28>>2];l=n;return}function Yv(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0.0,f=0.0,g=0.0,i=0,j=0.0,k=0,l=0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0;q=+h[a>>3];r=+h[c>>3];k=!(q>=r);if((!k?q<=+h[c+16>>3]:0)?(e=+h[a+8>>3],e>=+h[c+8>>3]):0)i=e<=+h[c+24>>3];else i=0;e=+h[b>>3];if((e>=r?e<=+h[c+16>>3]:0)?(f=+h[b+8>>3],f>=+h[c+8>>3]):0){d=f<=+h[c+24>>3];if(!(i^d))if(i&d)d=1;else l=11;else d=0}else if(i)d=0;else l=11;a:do if((l|0)==11){p=+h[a+8>>3];do if(q==e){r=+h[c+8>>3];if(!(k|p>=r^+h[b+8>>3]>=r^1)?q<=+h[c+16>>3]:0){d=0;break a}}else{j=+h[b+8>>3];if(p==j){if(!(q>=r^e>=r))break;if(!(p>=+h[c+8>>3]))break;if(!(p<=+h[c+24>>3]))break;else{d=0;break a}}o=(j-p)/(e-q);l=q>3];if(!(!(r>=g)|!(r<=e)|!(f>=m))?f<=+h[c+24>>3]:0){d=0;break a}n=+h[c+16>>3];f=(n-r)*o+f;if(f>=m?!(!(n<=e)|(n>=g?!(f<=+h[c+24>>3]):1)):0){d=0;break a}l=p=r?!(!(m<=f)|(!(m>=g)|!(e<=n))):0){d=0;break a}p=+h[c+24>>3];q=(p-m)/o+e;if(q>=r?!(!(p<=f)|(!(p>=g)|!(q<=n))):0){d=0;break a}}while(0);d=-1}while(0);return d|0}function Zv(a){a=a|0;var b=0,c=0.0;b=a+16|0;c=+h[b>>3];h[a+32>>3]=c;h[a+48>>3]=c;h[a+40>>3]=+h[a+24>>3];h[a+56>>3]=+h[a+8>>3];h[b>>3]=+h[a>>3];return}function _v(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0,g=0.0,i=0.0;if((c[42176]|0)!=(d|0)){SJ(+(d|0)*.15915494309189535,167112,167120);c[42176]=d}g=+h[b>>3];e=+h[20890];f=+h[b+8>>3];i=+h[20889];h[a>>3]=e*g-i*f;h[a+8>>3]=i*g+f*e;return}function $v(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0,g=0.0,i=0,j=0,k=0;k=l;l=l+16|0;f=k;e=+h[b>>3];i=b+8|0;g=+h[i>>3];a:do switch(d|0){case 0:{j=11;break}case 90:{h[b>>3]=g;e=-e;j=10;break}case 180:{e=-g;j=10;break}case 270:{h[b>>3]=g;j=10;break}default:{if((d|0)<0){c[f>>2]=c[b>>2];c[f+4>>2]=c[b+4>>2];c[f+8>>2]=c[b+8>>2];c[f+12>>2]=c[b+12>>2];aw(a,f,0-d|0);break a}if((d|0)>360){c[f>>2]=c[b>>2];c[f+4>>2]=c[b+4>>2];c[f+8>>2]=c[b+8>>2];c[f+12>>2]=c[b+12>>2];$v(a,f,(d>>>0)%360|0);break a}else{c[f>>2]=c[b>>2];c[f+4>>2]=c[b+4>>2];c[f+8>>2]=c[b+8>>2];c[f+12>>2]=c[b+12>>2];_v(a,f,d);break a}}}while(0);if((j|0)==10){h[i>>3]=e;j=11}if((j|0)==11){c[a>>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];c[a+12>>2]=c[b+12>>2]}l=k;return}function aw(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0,g=0.0,i=0,j=0,k=0;k=l;l=l+16|0;f=k;e=+h[b>>3];i=b+8|0;g=+h[i>>3];a:do switch(d|0){case 0:{j=11;break}case 90:{h[b>>3]=-g;j=10;break}case 180:{e=-g;j=10;break}case 270:{h[b>>3]=g;j=10;break}default:{if((d|0)<0){c[f>>2]=c[b>>2];c[f+4>>2]=c[b+4>>2];c[f+8>>2]=c[b+8>>2];c[f+12>>2]=c[b+12>>2];$v(a,f,0-d|0);break a}if((d|0)>360){c[f>>2]=c[b>>2];c[f+4>>2]=c[b+4>>2];c[f+8>>2]=c[b+8>>2];c[f+12>>2]=c[b+12>>2];aw(a,f,(d>>>0)%360|0);break a}else{c[f>>2]=c[b>>2];c[f+4>>2]=c[b+4>>2];c[f+8>>2]=c[b+8>>2];c[f+12>>2]=c[b+12>>2];_v(a,f,360-d|0);break a}}}while(0);if((j|0)==10){h[i>>3]=e;j=11}if((j|0)==11){c[a>>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];c[a+12>>2]=c[b+12>>2]}l=k;return}function bw(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0,g=0.0;g=+h[c>>3];d=+h[c+8>>3];f=d+ +h[b>>3];e=g+ +h[b+24>>3];d=d+ +h[b+16>>3];h[a>>3]=g+ +h[b+8>>3];h[a+8>>3]=f;h[a+16>>3]=e;h[a+24>>3]=d;return}function cw(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0,g=0.0;f=+h[a>>3];d=+h[b>>3]-f;g=+h[a+8>>3];e=+h[b+8>>3]-g;f=(+h[c+8>>3]-g)*d-(+h[c>>3]-f)*e;f=f*f;return +(f<1.0e-10?0.0:f/(e*e+d*d))}function dw(b,d){b=b|0;d=d|0;var e=0,f=0.0,g=0,i=0,j=0,k=0,m=0,n=0;n=l;l=l+16|0;g=n+8|0;i=n;e=vw(96)|0;m=b+16|0;c[(c[m>>2]|0)+8>>2]=e;e=Im(b,86250)|0;if(!e){e=Na(86259)|0;if(e|0)k=3}else k=3;if((k|0)==3)Va(86271,e|0,1)|0;e=(ew(b)|0)&255;a[(c[m>>2]|0)+115>>0]=e;if(0==0?(e=Im(b,86282)|0,c[42178]=e,(e|0)==0):0)c[42178]=c[42177];f=+EA(b,ym(b,0,86292,0)|0,0.0,0.0);h[c[(c[m>>2]|0)+8>>2]>>3]=f;e=Im(b,86300)|0;a:do if(!e)e=0;else{switch(a[e>>0]|0){case 76:{if(!(xJ(e,86308)|0)){e=1;break a}break}case 66:{if(!(xJ(e,86311)|0)){e=2;break a}break}case 82:{e=(xJ(e,86314)|0)==0;e=e?3:0;break a}default:{e=0;break a}}e=0}while(0);c[(c[m>>2]|0)+116>>2]=e<<2|(d<<24>>24==0?0:e);f=+EA(b,ym(b,0,86317,0)|0,.25,.02);h[i>>3]=f;f=f*72.0;c[(c[m>>2]|0)+248>>2]=~~(f+(f>=0.0?.5:-.5));e=FA(b,ym(b,0,86325,0)|0,0)|0;if(e){c[g>>2]=i;if(cM(e,86246,g)|0){f=+h[i>>3];if(f<.02){h[i>>3]=.02;f=.02}}else{h[i>>3]=.5;f=.5}if(hL(e,86333)|0)a[(c[m>>2]|0)+276>>0]=1}else{h[i>>3]=.5;f=.5}f=f*72.0;c[(c[m>>2]|0)+252>>2]=~~(f+(f>=0.0?.5:-.5));i=(DA(b,ym(b,0,86341,0)|0,0,0)|0)&255;a[(c[m>>2]|0)+243>>0]=i;i=UA(FA(b,ym(b,0,86351,0)|0,0)|0,19732,19748)|0;c[(c[m>>2]|0)+244>>2]=i;fw(b);i=gw(b,86361,(c[(c[m>>2]|0)+8>>2]|0)+64|0)|0;e=c[(c[m>>2]|0)+8>>2]|0;a[e+80>>0]=i;gw(b,86366,e+48|0)|0;e=IA(Im(b,86371)|0)|0;a[(c[(c[m>>2]|0)+8>>2]|0)+82>>0]=e;e=Im(b,86378)|0;do if(!e){e=Im(b,86385)|0;if(e|0){e=(a[e>>0]|32)<<24>>24==108&1;k=27;break}e=Im(b,86397)|0;if(e|0){e=IA(e)|0;k=27}}else{e=(rM(e)|0)==90&1;k=27}while(0);if((k|0)==27)a[(c[(c[m>>2]|0)+8>>2]|0)+81>>0]=e;c[42179]=UA(Im(b,86407)|0,19764,19780)|0;a[174076]=IA(Im(b,86419)|0)|0;c[42181]=0;c[42182]=0;h[(c[(c[m>>2]|0)+8>>2]|0)+24>>3]=0.0;e=Im(b,86431)|0;if((e|0)!=0?(a[e>>0]|0)!=0:0)k=32;else k=30;if(((k|0)==30?(j=Im(b,86435)|0,j|0):0)?a[j>>0]|0:0){e=j;k=32}if((k|0)==32){f=+sM(e);h[(c[(c[m>>2]|0)+8>>2]|0)+24>>3]=f}hw(b);c[42184]=ym(b,0,86446,0)|0;c[42187]=ym(b,0,86455,0)|0;c[42188]=ym(b,0,90530,0)|0;c[42189]=ym(b,1,96049,0)|0;c[42190]=ym(b,1,96043,0)|0;c[42191]=ym(b,1,90671,0)|0;c[42192]=ym(b,1,122540,0)|0;c[42193]=ym(b,1,86469,0)|0;c[42201]=ym(b,1,86479,0)|0;c[42194]=ym(b,1,86485,0)|0;c[42195]=ym(b,1,86494,0)|0;c[42196]=ym(b,1,86503,0)|0;k=ym(b,1,86240,0)|0;c[42198]=k;if(!k)c[42198]=ym(b,1,86240,90527)|0;c[42199]=ym(b,1,86513,0)|0;c[42202]=ym(b,1,86341,0)|0;c[42216]=ym(b,1,86520,0)|0;c[42205]=ym(b,1,86446,0)|0;c[42197]=ym(b,1,90530,0)|0;c[42203]=ym(b,1,86529,0)|0;c[42204]=ym(b,1,86535,0)|0;c[42207]=ym(b,1,86547,0)|0;c[42206]=ym(b,1,86385,0)|0;c[42208]=ym(b,1,86552,0)|0;c[42209]=ym(b,1,86563,0)|0;c[42210]=ym(b,1,122089,0)|0;c[42200]=ym(b,1,86573,0)|0;c[42211]=ym(b,1,86583,0)|0;c[42212]=ym(b,1,86589,0)|0;c[42213]=ym(b,1,86595,0)|0;c[42214]=ym(b,1,86603,0)|0;c[42215]=ym(b,1,86612,0)|0;c[42217]=ym(b,1,86455,0)|0;c[42218]=ym(b,2,86614,0)|0;c[42220]=ym(b,2,122540,0)|0;c[42221]=ym(b,2,86469,0)|0;c[42223]=ym(b,2,86485,0)|0;c[42224]=ym(b,2,86494,0)|0;c[42225]=ym(b,2,86503,0)|0;c[42226]=ym(b,2,86240,0)|0;c[42227]=ym(b,2,86513,0)|0;c[42236]=ym(b,2,86621,0)|0;c[42228]=ym(b,2,86632,0)|0;c[42239]=ym(b,2,86636,0)|0;c[42240]=ym(b,2,86646,0)|0;c[42241]=ym(b,2,86656,0)|0;c[42242]=ym(b,2,86666,0)|0;c[42243]=ym(b,2,86676,0)|0;c[42244]=ym(b,2,86690,0)|0;c[42245]=ym(b,2,86704,0)|0;c[42246]=ym(b,2,86719,0)|0;c[42247]=ym(b,2,86733,0)|0;c[42219]=ym(b,2,86744,0)|0;c[42231]=ym(b,2,86341,0)|0;c[42229]=ym(b,2,86479,0)|0;c[42230]=ym(b,2,86751,0)|0;c[42232]=ym(b,2,86760,0)|0;c[42233]=ym(b,2,86770,0)|0;c[42234]=ym(b,2,86583,0)|0;c[42235]=ym(b,2,86595,0)|0;c[42248]=ym(b,2,86781,0)|0;c[42249]=ym(b,2,86790,0)|0;c[42250]=ym(b,2,86520,0)|0;e=Ut(b)|0;c[(c[(c[m>>2]|0)+8>>2]|0)+88>>2]=e;e=Im(b,86799)|0;if(e|0?a[e>>0]|0:0){b=qw(e,b)|0;c[(c[(c[m>>2]|0)+8>>2]|0)+92>>2]=b}l=n;return}function ew(a){a=a|0;var b=0,d=0;d=l;l=l+16|0;b=d;a=GA(a,ym(a,0,86883,0)|0,86891)|0;if(((((((iK(a,86897)|0)!=0?(iK(a,86905)|0)!=0:0)?(iK(a,86912)|0)!=0:0)?(iK(a,86915)|0)!=0:0)?(iK(a,86926)|0)!=0:0)?(iK(a,86937)|0)!=0:0)?(iK(a,86947)|0)!=0:0)if((iK(a,86958)|0)!=0?(iK(a,86964)|0)!=0:0)if((iK(a,86891)|0)!=0?(iK(a,86969)|0)!=0:0){c[b>>2]=a;_l(0,86974,b)|0;a=0}else a=0;else a=2;else a=1;l=d;return a|0}function fw(b){b=b|0;var d=0.0,e=0,f=0;e=Im(b,86841)|0;a:do if(e|0?(f=a[e>>0]|0,f<<24>>24):0)switch(f<<24>>24|0){case 97:{if(f<<24>>24!=97)break a;if(xJ(e,86847)|0)break a;c[(c[(c[b+16>>2]|0)+8>>2]|0)+84>>2]=4;break a}case 99:{if(f<<24>>24!=99)break a;if(xJ(e,86852)|0)break a;c[(c[(c[b+16>>2]|0)+8>>2]|0)+84>>2]=3;break a}case 101:{if(f<<24>>24!=101)break a;if(xJ(e,86861)|0)break a;c[(c[(c[b+16>>2]|0)+8>>2]|0)+84>>2]=5;break a}case 102:{if(f<<24>>24!=102)break a;if(xJ(e,86868)|0)break a;c[(c[(c[b+16>>2]|0)+8>>2]|0)+84>>2]=2;break a}default:{d=+sM(e);if(!(d>0.0))break a;b=c[(c[b+16>>2]|0)+8>>2]|0;c[b+84>>2]=1;h[b+16>>3]=d;break a}}while(0);return}function gw(b,d,e){b=b|0;d=d|0;e=e|0;var f=0.0,g=0.0,i=0,j=0,k=0,m=0,n=0,o=0;o=l;l=l+48|0;m=o+32|0;i=o+16|0;k=o+8|0;j=o;n=o+40|0;a[n>>0]=0;b=Im(b,d)|0;do if(b){c[i>>2]=k;c[i+4>>2]=j;c[i+8>>2]=n;i=(cM(b,86825,i)|0)>1;g=+h[k>>3];f=+h[j>>3];if(i&g>0.0&f>0.0){g=g*72.0;h[e>>3]=+(~~(g+(g>=0.0?.5:-.5))|0);g=f*72.0;h[e+8>>3]=+(~~(g+(g>=0.0?.5:-.5))|0);b=(a[n>>0]|0)==33;break}a[n>>0]=0;c[m>>2]=k;c[m+4>>2]=n;m=(cM(b,86835,m)|0)>0;f=+h[k>>3];if(m&f>0.0){g=f*72.0;g=+(~~(g+(g>=0.0?.5:-.5))|0);h[e>>3]=g;h[e+8>>3]=g;b=(a[n>>0]|0)==33}else b=0}else b=0;while(0);l=o;return b&1|0}function hw(b){b=b|0;var d=0,e=0,f=0.0,g=0.0,i=0;d=Im(b,86240)|0;do if(d|0?a[d>>0]|0:0){e=(c[(c[b+60>>2]|0)+16>>2]|0)+113|0;a[e>>0]=a[e>>0]|8;e=(cp(d)|0)!=0;g=+EA(b,ym(b,0,86485,0)|0,14.0,1.0);i=GA(b,ym(b,0,86494,0)|0,93027)|0;d=lw(b,d,e?2:0,g,i,GA(b,ym(b,0,86503,0)|0,122106)|0)|0;i=b+16|0;c[(c[i>>2]|0)+12>>2]=d;d=Im(b,90662)|0;e=(d|0)!=0;do if((so(b)|0)==(b|0)){if(e?(a[d>>0]|0)==116:0){d=1;break}d=0}else{if(e?(a[d>>0]|0)==98:0){d=0;break}d=1}while(0);e=Im(b,86802)|0;a:do if(e)switch(a[e>>0]|0){case 108:{d=d|2;break a}case 114:{d=d|4;break a}default:break a}while(0);a[(c[i>>2]|0)+275>>0]=d;if((so(b)|0)!=(b|0)){d=c[(c[i>>2]|0)+12>>2]|0;f=+h[d+24>>3]+16.0;g=+h[d+32>>3]+8.0;b=(c[(c[(so(b)|0)+16>>2]|0)+116>>2]&1|0)==0;d=c[i>>2]|0;e=a[d+275>>0]<<1&2;if(b){b=e&255;h[d+48+(b<<4)>>3]=f;h[d+48+(b<<4)+8>>3]=g;break}else{b=(e^3)&255;h[d+48+(b<<4)>>3]=g;h[d+48+(b<<4)+8>>3]=f;break}}}while(0);return}function iw(a){a=a|0;var b=0,d=0,e=0;e=a+16|0;d=c[e>>2]|0;b=c[d+8>>2]|0;do if(!b)b=d;else{d=c[b+88>>2]|0;if(d){xt(d);d=c[e>>2]|0;b=c[d+8>>2]|0;if(!b){b=d;break}}_I(c[b+92>>2]|0);b=c[e>>2]|0}while(0);_I(c[b+8>>2]|0);e=c[e>>2]|0;c[e+8>>2]=0;ow(c[e+12>>2]|0);To(a,0,122277);return}function jw(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;f=c[d>>2]|0;l=d+24|0;c[l>>2]=0;c[l+4>>2]=0;c[l+8>>2]=0;c[l+12>>2]=0;if(a[f>>0]|0){i=ww((rJ(f)|0)+1|0)|0;a[i>>0]=0;j=d+12|0;e=i;a:while(1){b:while(1){h=f+1|0;g=a[f>>0]|0;if(!(g<<24>>24))break a;if(!(g<<24>>24==-1|((g&255)<161|(c[j>>2]|0)!=2))){a[e>>0]=g;h=a[h>>0]|0;g=e+2|0;a[e+1>>0]=h;if(!(h<<24>>24)){e=g;break a}else{e=g;f=f+2|0;continue}}switch(g<<24>>24){case 92:break b;case 10:{k=12;break b}default:{}}a[e>>0]=g;e=e+1|0;f=h}if((k|0)==12){k=0;f=e+1|0;a[e>>0]=0;kw(b,d,i,110);e=f;i=f;f=h;continue}g=a[h>>0]|0;switch(g<<24>>24|0){case 114:case 108:case 110:{g=e+1|0;a[e>>0]=0;kw(b,d,i,a[h>>0]|0);e=g;break}default:{a[e>>0]=g;e=e+1|0;g=i}}i=g;f=(a[h>>0]|0)==0?h:f+2|0}if((i|0)!=(e|0)){a[e>>0]=0;kw(b,d,i,110)}d=d+40|0;c[d>>2]=c[l>>2];c[d+4>>2]=c[l+4>>2];c[d+8>>2]=c[l+8>>2];c[d+12>>2]=c[l+12>>2]}return}function kw(d,e,f,g){d=d|0;e=e|0;f=f|0;g=g|0;var i=0.0,j=0.0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;s=l;l=l+32|0;q=s+16|0;p=s;r=e+76|0;k=b[r>>1]|0;o=e+72|0;m=c[o>>2]|0;if(!m)n=vw((k*56|0)+112|0)|0;else n=xw(m,k+2|0,56,k+1|0)|0;c[o>>2]=n;k=b[r>>1]|0;m=n+(k*56|0)|0;c[m>>2]=f;a[n+(k*56|0)+48>>0]=g;if((f|0)!=0?(a[f>>0]|0)!=0:0){c[41782]=c[e+4>>2];h[20893]=+h[e+16>>3];g=c[d+144>>2]|0;c[n+(k*56|0)+4>>2]=bb[c[g>>2]&31](g,167128,1)|0;pA(p,d,m);j=+h[p>>3];h[q>>3]=j;i=+h[p+8>>3]}else{h[q>>3]=0.0;i=+(~~(+h[e+16>>3]*1.2)|0);h[n+(k*56|0)+40>>3]=i;j=0.0}b[r>>1]=(b[r>>1]|0)+1<<16>>16;r=e+24|0;h[r>>3]=+h[(+h[r>>3]>j?r:q)>>3];r=e+32|0;h[r>>3]=+h[r>>3]+i;l=s;return}function lw(b,e,f,g,i,j){b=b|0;e=e|0;f=f|0;g=+g;i=i|0;j=j|0;var k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;u=l;l=l+32|0;r=u+16|0;q=u+8|0;p=u;t=vw(88)|0;switch(Co(b)|0){case 0:{m=0;s=c[b+60>>2]|0;n=b;o=0;break}case 1:{m=0;s=so(ro(b)|0)|0;n=0;o=b;break}case 2:{m=b;s=so(ro(c[((c[b>>2]&3|0)==2?b:b+-48|0)+40>>2]|0)|0)|0;n=0;o=0;break}default:{m=0;s=0;n=0;o=0}}c[t+4>>2]=i;c[t+8>>2]=j;h[t+16>>3]=g;k=s+16|0;j=t+12|0;c[j>>2]=d[(c[k>>2]|0)+115>>0];a:do if(f&4){c[t>>2]=GL(e)|0;if(f&2|0)a[t+82>>0]=1}else switch(f|0){case 2:{c[t>>2]=GL(e)|0;a[t+82>>0]=1;if(!(TF(b,t)|0))break a;switch(Co(b)|0){case 0:{c[p>>2]=Dn(n)|0;_l(3,87017,p)|0;break a}case 1:{c[q>>2]=Dn(o)|0;_l(3,87039,q)|0;break a}case 2:{p=Dn(c[((c[m>>2]&3|0)==3?m:m+48|0)+40>>2]|0)|0;q=(qn(s)|0)!=0;s=Dn(c[((c[m>>2]&3|0)==2?m:m+-48|0)+40>>2]|0)|0;c[r>>2]=p;c[r+4>>2]=q?122546:122549;c[r+8>>2]=s;_l(3,87060,r)|0;break a}default:break a}}case 0:{i=mw(e,b,0)|0;c[t>>2]=i;if((c[j>>2]|0)==1)i=yB(i)|0;else i=vB(i,s)|0;_I(c[t>>2]|0);c[t>>2]=i;jw(c[(c[k>>2]|0)+144>>2]|0,t);break a}default:ma(87087,87103,166,87112)}while(0);l=u;return t|0}function mw(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;switch(Co(d)|0){case 0:{i=Dn(d)|0;g=rJ(i)|0;f=c[(c[d+16>>2]|0)+12>>2]|0;if(f){f=c[f>>2]|0;if(!b){v=0;t=2;u=2;s=2;h=2;y=87135;m=87132;j=90527;o=174181;q=174181;p=0;r=0;n=2;w=f;x=87129}else{v=0;t=2;u=2;s=2;h=2;y=87135;m=87132;j=90527;o=174181;q=174181;p=0;r=0;n=rJ(f)|0;w=f;x=87129}}else{v=0;t=2;u=2;s=2;h=2;y=87135;m=87132;j=90527;o=174181;q=174181;p=0;r=0;n=2;w=87123;x=87129}break}case 1:{i=Dn(ro(d)|0)|0;g=rJ(i)|0;j=Dn(d)|0;h=rJ(j)|0;f=c[(c[d+16>>2]|0)+104>>2]|0;if(f){f=c[f>>2]|0;if(!b){v=0;t=2;u=2;s=2;y=87135;m=87132;o=174181;q=174181;p=0;r=0;n=2;w=f;x=87129}else{v=0;t=2;u=2;s=2;y=87135;m=87132;o=174181;q=174181;p=0;r=0;n=rJ(f)|0;w=f;x=87129}}else{v=0;t=2;u=2;s=2;y=87135;m=87132;o=174181;q=174181;p=0;r=0;n=2;w=87123;x=87129}break}case 2:{h=d+48|0;i=Dn(so(ro(c[((c[d>>2]&3|0)==3?d:h)+40>>2]|0)|0)|0)|0;g=rJ(i)|0;l=Dn(c[((c[d>>2]&3|0)==3?d:h)+40>>2]|0)|0;k=rJ(l)|0;f=d+16|0;q=c[(c[f>>2]|0)+52>>2]|0;if(!q)r=0;else r=rJ(q)|0;m=Dn(c[((c[d>>2]&3|0)==2?d:d+-48|0)+40>>2]|0)|0;f=c[f>>2]|0;o=c[f+92>>2]|0;if(!o)p=0;else p=rJ(o)|0;j=rJ(m)|0;f=c[f+96>>2]|0;if(f){f=c[f>>2]|0;if(!b)n=2;else n=rJ(f)|0}else{n=2;f=87123}x=(qn(so(ro(c[((c[d>>2]&3|0)==3?d:h)+40>>2]|0)|0)|0)|0)==0;v=1;t=k;u=j;s=k+2+(r|0?r+1|0:0)+j+(p|0?p+1|0:0)|0;h=2;y=l;j=90527;w=f;x=x?122549:122546;break}default:{v=0;t=2;u=2;s=2;h=2;g=2;y=87135;m=87132;j=90527;i=87126;o=174181;q=174181;p=0;r=0;n=2;w=87123;x=87129}}e=(e|0)==0;l=0;f=b;a:while(1){d=f+1|0;b:do switch(a[f>>0]|0){case 0:break a;case 92:{f=f+2|0;switch(a[d>>0]|0){case 78:{k=h;break b}case 71:{k=g;break b}case 69:{k=s;break b}case 72:{k=u;break b}case 84:{k=t;break b}case 76:{k=n;break b}case 92:{if(!e){k=1;break b}break}default:{}}k=2;break}default:{k=1;f=d}}while(0);l=l+k|0}s=ww(l+1|0)|0;n=(v|0)==0;l=(r|0)==0;d=(p|0)==0;f=s;g=b;c:while(1){k=g+1|0;h=a[g>>0]|0;switch(h<<24>>24){case 0:break c;case 92:break;default:{a[f>>0]=h;f=f+1|0;g=k;continue c}}h=g+2|0;g=a[k>>0]|0;switch(g<<24>>24|0){case 71:{g=i;while(1){b=a[g>>0]|0;a[f>>0]=b;if(!(b<<24>>24)){g=h;continue c}g=g+1|0;f=f+1|0}}case 78:{g=j;while(1){b=a[g>>0]|0;a[f>>0]=b;if(!(b<<24>>24)){g=h;continue c}g=g+1|0;f=f+1|0}}case 69:{if(n){g=h;continue c}else g=y;while(1){b=a[g>>0]|0;a[f>>0]=b;if(!(b<<24>>24))break;g=g+1|0;f=f+1|0}if(l)g=x;else{a[f>>0]=58;g=q;while(1){f=f+1|0;b=a[g>>0]|0;a[f>>0]=b;if(!(b<<24>>24)){g=x;break}else g=g+1|0}}while(1){b=a[g>>0]|0;a[f>>0]=b;if(!(b<<24>>24)){g=m;break}g=g+1|0;f=f+1|0}while(1){b=a[g>>0]|0;a[f>>0]=b;if(!(b<<24>>24))break;g=g+1|0;f=f+1|0}if(d){g=h;continue c}a[f>>0]=58;g=o;while(1){f=f+1|0;b=a[g>>0]|0;a[f>>0]=b;if(!(b<<24>>24)){g=h;continue c}else g=g+1|0}}case 84:{g=y;while(1){b=a[g>>0]|0;a[f>>0]=b;if(!(b<<24>>24)){g=h;continue c}g=g+1|0;f=f+1|0}}case 72:{g=m;while(1){b=a[g>>0]|0;a[f>>0]=b;if(!(b<<24>>24)){g=h;continue c}f=f+1|0;g=g+1|0}}case 76:{g=w;while(1){b=a[g>>0]|0;a[f>>0]=b;if(!(b<<24>>24)){g=h;continue c}f=f+1|0;g=g+1|0}}case 92:{if(!e){a[f>>0]=92;f=f+1|0;g=h;continue c}break}default:{}}a[f>>0]=92;a[f+1>>0]=g;f=f+2|0;g=h}a[f>>0]=0;return s|0}function nw(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;if(a|0){d=a;e=0;while(1){if((e|0)>=(b|0))break;if(!e)_I(c[d>>2]|0);g=c[d+8>>2]|0;if(g|0?(f=c[d+12>>2]|0,f|0):0)gb[f&127](g);d=d+56|0;e=e+1|0}_I(a)}return}function ow(d){d=d|0;var e=0;if(d|0){_I(c[d>>2]|0);e=d+72|0;if(a[d+82>>0]|0){e=c[e>>2]|0;if(e|0)EF(e,1)}else nw(c[e>>2]|0,b[d+76>>1]|0);_I(d)}return}function pw(d,e,f){d=d|0;e=e|0;f=f|0;var g=0.0,i=0,j=0.0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;u=l;l=l+32|0;q=u+16|0;r=u;k=c[d+16>>2]|0;s=k+12|0;t=c[s>>2]|0;c[s>>2]=e;if(!(a[f+82>>0]|0)){p=f+76|0;if((b[p>>1]|0)>=1){yD(d,0);BD(d,c[f+8>>2]|0);switch(a[f+80>>0]|0){case 116:{j=+h[f+64>>3];g=+h[f+48>>3]*.5+j;break}case 98:{j=+h[f+64>>3];g=+h[f+48>>3]*-.5+j+ +h[f+32>>3];break}default:{j=+h[f+64>>3];g=+h[f+32>>3]*.5+j}}g=g-+h[f+16>>3];o=r+8|0;h[o>>3]=g;if(b[k+260>>1]&512)h[o>>3]=g-j;m=f+72|0;n=f+56|0;i=f+40|0;e=0;while(1){if((e|0)>=(b[p>>1]|0))break;k=c[m>>2]|0;switch(a[k+(e*56|0)+48>>0]|0){case 108:{g=+h[n>>3]-+h[i>>3]*.5;break}case 114:{g=+h[i>>3]*.5+ +h[n>>3];break}default:g=+h[n>>3]}h[r>>3]=g;c[q>>2]=c[r>>2];c[q+4>>2]=c[r+4>>2];c[q+8>>2]=c[r+8>>2];c[q+12>>2]=c[r+12>>2];AD(d,q,k+(e*56|0)|0);h[o>>3]=+h[o>>3]-+h[(c[m>>2]|0)+(e*56|0)+40>>3];e=e+1|0}zD(d);i=18}}else{jF(d,c[f+72>>2]|0,f);i=18}if((i|0)==18)c[s>>2]=t;l=u;return}function qw(a,b){a=a|0;b=b|0;return mw(a,b,1)|0}function rw(a){a=a|0;return sw(a,0)|0}function sw(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0;e=c[42251]|0;if(!e){c[42252]=64;e=ww(64)|0;c[42251]=e}j=d<<24>>24==0;i=0;f=0;h=b;while(1){if(!h)break;d=a[h>>0]|0;if(!(d<<24>>24))break;b=c[42252]|0;if((i|0)>(b+-8|0)){e=b<<1;c[42252]=e;e=yw(c[42251]|0,e)|0;c[42251]=e;e=e+i|0;d=a[h>>0]|0}a:do switch(d<<24>>24){case 38:{if(j?(tw(h)|0)!=0:0)k=18;else{f=5;d=87164}break}case 60:{f=4;d=87187;break}case 62:{f=4;d=87170;break}case 45:{f=5;d=87181;break}default:{if((f|0)!=0&d<<24>>24==32)if((a[f>>0]|0)==32){f=6;d=87157;break a}else{k=18;break a}switch(d<<24>>24){case 34:{f=6;d=87150;break a}case 39:{f=5;d=87175;break a}case 10:if(j){k=18;break a}else{f=5;d=87144;break a}default:{k=18;break a}}}}while(0);if((k|0)==18){k=0;d=j|d<<24>>24!=13;f=d?1:5;d=d?h:87138}g=e+f|0;b=f;while(1){if(!b)break;a[e>>0]=a[d>>0]|0;b=b+-1|0;d=d+1|0;e=e+1|0}b=h;i=f+i|0;e=g;h=h+1|0;f=b}a[e>>0]=0;return c[42251]|0}function tw(b){b=b|0;var c=0,d=0;d=b+1|0;c=a[d>>0]|0;a:do if(c<<24>>24==35){d=b+2|0;c=a[d>>0]|0;switch(c<<24>>24){case 88:case 120:break;default:{b=d;while(1){d=b+1|0;if((c+-48&255)>=10)break a;b=d;c=a[d>>0]|0}}}d=b+3|0;while(1){c=a[d>>0]|0;if((c+-48&255)>=10)switch(c<<24>>24){case 65:case 66:case 67:case 68:case 69:case 70:case 97:case 98:case 99:case 100:case 101:case 102:break;default:break a}d=d+1|0}}else while(1){b=d+1|0;if(((c&-33)+-65&255)>=26)break a;d=b;c=a[b>>0]|0}while(0);return c<<24>>24==59|0}function uw(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0;d=c[42253]|0;if(!d){c[42254]=64;d=ww(64)|0;c[42253]=d;i=0}else i=0;while(1){if(!b)break;e=a[b>>0]|0;if(!(e<<24>>24))break;f=c[42254]|0;if((i|0)>(f+-8|0)){d=f<<1;c[42254]=d;d=yw(c[42253]|0,d)|0;c[42253]=d;d=d+i|0;e=a[b>>0]|0}switch(e<<24>>24){case 38:{if(!(tw(b)|0)){g=5;e=87164}else j=12;break}case 60:{g=4;e=87187;break}case 62:{g=4;e=87170;break}case 34:{g=6;e=87150;break}case 39:{g=5;e=87175;break}default:j=12}if((j|0)==12){j=0;g=1;e=b}h=d+g|0;f=g;while(1){if(!f)break;a[d>>0]=a[e>>0]|0;f=f+-1|0;e=e+1|0;d=d+1|0}i=g+i|0;d=h;b=b+1|0}a[d>>0]=0;return c[42253]|0}function vw(a){a=a|0;var b=0;if(!a)a=0;else{b=ww(a)|0;VN(b|0,0,a|0)|0;a=b}return a|0}function ww(a){a=a|0;if(a){a=ZI(a)|0;if(!a){XL(96532,14,1,c[13918]|0)|0;a=0}}else a=0;return a|0}function xw(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;a=aJ(a,O(d,b)|0)|0;if(!((b|0)!=0&(a|0)==0)){if(b>>>0>e>>>0)VN(a+(O(e,d)|0)|0,0,O(b-e|0,d)|0)|0}else XL(96532,14,1,c[13918]|0)|0;return a|0}function yw(a,b){a=a|0;b=b|0;a=aJ(a,b)|0;if((b|0)!=0&(a|0)==0)XL(96532,14,1,c[13918]|0)|0;return a|0}function zw(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0.0,m=0,n=0,q=0,r=0,s=0,t=0,u=0;u=l;l=l+80|0;r=u+40|0;q=u+32|0;n=u+24|0;m=u;s=4;t=ZI(40)|0;c[t>>2]=0;f=u+68|0;g=u+64|0;if(0){o=0;ha(57,a|0,f|0,g|0);i=o;o=0;if((i|0)!=0&(p|0)!=0){j=SN(c[i>>2]|0,t|0,s|0)|0;if(!j)Ua(i|0,p|0);z=p}else j=-1;if((j|0)!=1){j=c[13918]|0;i=c[f>>2]|0;f=c[g>>2]|0;o=0;c[m>>2]=87236;c[m+4>>2]=i;c[m+8>>2]=f;c[m+12>>2]=d;c[m+16>>2]=b;aa(13,j|0,87192,m|0)|0;f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,t|0,s|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)!=1){o=0;ea(1);f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,t|0,s|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)!=1)j=6;else{f=z;j=15}}else{f=z;j=15}}else{f=z;j=15}}else j=6;do if((j|0)==6){o=0;f=_(20,a|0)|0;g=o;o=0;if((g|0)!=0&(p|0)!=0){i=SN(c[g>>2]|0,t|0,s|0)|0;if(!i)Ua(g|0,p|0);z=p}else i=-1;if((i|0)!=1){if(!f){o=0;ea(2);f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,t|0,s|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)==1){f=z;j=15;break}}if((d|0)<1){o=0;ea(3);f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,t|0,s|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)==1){f=z;j=15;break}f=0;break}else{c[42255]=(e|0)>-1?e:30;t=RN(169024,1,t|0,s|0)|0;s=z;o=0;f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,t|0,s|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)==1){f=z;j=15;break}f=0;j=15;break}}else{f=z;j=15}}while(0);a:do if((j|0)==15){b:while(1){if(f|0){f=2;break a}o=0;ea(4);f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,t|0,s|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)==1){f=z;j=15;continue}a=c[13918]|0;m=0;while(1){o=0;j=Z(1)|0;f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,t|0,s|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)==1){f=z;j=15;continue b}if(!j)break;o=0;f=_(21,j|0)|0;g=o;o=0;if((g|0)!=0&(p|0)!=0){i=SN(c[g>>2]|0,t|0,s|0)|0;if(!i)Ua(g|0,p|0);z=p}else i=-1;if((i|0)==1){f=z;j=15;continue b}o=0;ga(24,j|0,f|0);f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,t|0,s|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)==1){f=z;j=15;continue b}m=m+1|0;do if(((m|0)%100|0|0)==0&0!=0){f=(m|0)%1e3|0;if((f|0)==100){o=0;$(27,87236,a|0)|0;f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,t|0,s|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)==1){f=z;j=15;continue b}o=0;c[n>>2]=m;aa(13,a|0,87254,n|0)|0;f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,t|0,s|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)==1){f=z;j=15;continue b}break}o=0;c[q>>2]=m;aa(13,a|0,87254,q|0)|0;g=o;o=0;if((g|0)!=0&(p|0)!=0){i=SN(c[g>>2]|0,t|0,s|0)|0;if(!i)Ua(g|0,p|0);z=p}else i=-1;if((i|0)==1){f=z;j=15;continue b}if(!f){o=0;$(28,10,a|0)|0;f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,t|0,s|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)==1){f=z;j=15;continue b}}}while(0);if((m|0)>=(d|0))break}switch(b|0){case 1:{o=0;ea(5);f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,t|0,s|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)==1){f=z;j=15;continue b}break}case 2:{o=0;ea(6);f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,t|0,s|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)==1){f=z;j=15;continue b}break}default:{o=0;ea(7);f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,t|0,s|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)==1){f=z;j=15;continue b}o=0;ea(3);f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,t|0,s|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)==1){f=z;j=15;continue b}}}if(!0){f=0;break a}if((m|0)>99){o=0;$(28,10,a|0)|0;f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,t|0,s|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)==1){f=z;j=15;continue}}f=c[42295]|0;g=c[42296]|0;o=0;k=+X(1);i=o;o=0;if((i|0)!=0&(p|0)!=0){j=SN(c[i>>2]|0,t|0,s|0)|0;if(!j)Ua(i|0,p|0);z=p}else j=-1;if((j|0)==1){f=z;j=15;continue}o=0;c[r>>2]=87236;c[r+4>>2]=f;c[r+8>>2]=g;c[r+12>>2]=m;h[r+16>>3]=k;aa(13,a|0,87258,r|0)|0;f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,t|0,s|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)==1){f=z;j=15}else break}f=0}while(0);_I(t|0);l=u;return f|0}function Aw(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0;a=(c[a+16>>2]|0)+192|0;e=0;h=0;while(1){a=c[a>>2]|0;if(!a)break;g=c[a+16>>2]|0;f=c[g+180>>2]|0;a=0;while(1){if(!(c[f+(a<<2)>>2]|0))break;a=a+1|0;e=e+1|0}a=g+164|0;h=h+1|0}c[b>>2]=h;c[d>>2]=e;return}function Bw(b){b=b|0;var d=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;c[42298]=b;c[42305]=0;c[42296]=0;c[42295]=0;i=b+16|0;b=(c[i>>2]|0)+192|0;h=0;f=0;while(1){b=c[b>>2]|0;if(!b)break;g=c[b+16>>2]|0;a[g+157>>0]=0;h=h+1|0;c[42295]=h;d=c[g+180>>2]|0;b=0;while(1){if(!(c[d+(b<<2)>>2]|0))break;k=f+1|0;c[42296]=k;b=b+1|0;f=k}b=g+164|0}b=c[42306]|0;if(!b)b=ww(h<<2)|0;else b=yw(b,h<<2)|0;c[42306]=b;c[42307]=0;b=c[42300]|0;if(!b)b=ww(c[42295]<<2)|0;else b=yw(b,c[42295]<<2)|0;c[42300]=b;c[42299]=0;d=1;b=(c[i>>2]|0)+192|0;while(1){b=c[b>>2]|0;if(!b)break;k=b+16|0;i=c[k>>2]|0;j=i+292|0;c[j>>2]=0;i=c[i+172>>2]|0;h=d;g=0;b=0;while(1){d=c[i+(g<<2)>>2]|0;if(!d)break;f=b+1|0;c[j>>2]=f;b=c[d+16>>2]|0;c[b+160>>2]=0;c[b+164>>2]=-1;if(!h)b=0;else{l=c[d>>2]&3;b=((c[(c[(c[((l|0)==2?d:d+-48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)-(c[(c[(c[((l|0)==3?d:d+48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)|0)<(e[b+170>>1]|0|0)?0:h}h=b;g=g+1|0;b=f}b=vw((g<<2)+4|0)|0;d=c[k>>2]|0;c[d+264>>2]=b;c[d+268>>2]=0;d=c[d+180>>2]|0;b=0;do{l=b;b=b+1|0}while((c[d+(l<<2)>>2]|0)!=0);d=vw(b<<2)|0;b=c[k>>2]|0;c[b+272>>2]=d;c[b+276>>2]=0;d=h;b=b+164|0}return d|0}function Cw(){var a=0,b=0,d=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0;o=l;l=l+16|0;n=o+8|0;k=o;m=zA(c[42295]|0)|0;a=(c[(c[42298]|0)+16>>2]|0)+192|0;while(1){b=c[a>>2]|0;if(!b){j=0;break}d=b+16|0;a=c[d>>2]|0;if(!(c[a+292>>2]|0)){BA(m,b);a=c[d>>2]|0}a=a+164|0}while(1){a=CA(m)|0;if(!a)break;i=a+16|0;a=c[i>>2]|0;f=a+232|0;c[f>>2]=0;d=c[a+172>>2]|0;b=0;h=0;while(1){g=c[d+(b<<2)>>2]|0;if(!g){f=0;break}g=(c[(c[(c[((c[g>>2]&3|0)==3?g:g+48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)+(e[(c[g+16>>2]|0)+170>>1]|0)|0;g=(h|0)>(g|0)?h:g;c[f>>2]=g;b=b+1|0;h=g}while(1){b=c[(c[a+180>>2]|0)+(f<<2)>>2]|0;if(!b)break;d=b+-48|0;g=(c[(c[((c[b>>2]&3|0)==2?b:d)+40>>2]|0)+16>>2]|0)+292|0;h=c[g>>2]|0;c[g>>2]=h+-1;if((h|0)<2){BA(m,c[((c[b>>2]&3|0)==2?b:d)+40>>2]|0);a=c[i>>2]|0}f=f+1|0}j=j+1|0}a:do if((j|0)!=(c[42295]|0)){_l(1,87590,k)|0;a=(c[(c[42298]|0)+16>>2]|0)+192|0;while(1){b=c[a>>2]|0;if(!b)break a;d=b+16|0;a=c[d>>2]|0;if(c[a+292>>2]|0){k=Dn(b)|0;a=c[(c[d>>2]|0)+292>>2]|0;c[n>>2]=k;c[n+4>>2]=a;_l(3,87612,n)|0;a=c[d>>2]|0}a=a+164|0}}while(0);AA(m);l=o;return}function Dw(){var b=0,d=0,e=0;b=(c[(c[42298]|0)+16>>2]|0)+192|0;while(1){b=c[b>>2]|0;if(!b)break;e=b+16|0;b=c[e>>2]|0;d=c[b+264>>2]|0;if(d){_I(d);b=c[e>>2]|0}d=c[b+272>>2]|0;if(d){_I(d);b=c[e>>2]|0}a[b+157>>0]=0;b=b+164|0}return}function Ew(){var a=0,b=0,d=0,e=0,f=0;a=(c[(c[42298]|0)+16>>2]|0)+192|0;while(1){a=c[a>>2]|0;if(!a)break;a=c[a+16>>2]|0;c[a+280>>2]=0;a=a+164|0}f=vw(c[42295]<<2)|0;e=0;a=(c[(c[42298]|0)+16>>2]|0)+192|0;while(1){b=c[a>>2]|0;if(!b)break;d=b+16|0;a=c[d>>2]|0;if(!(c[a+280>>2]|0)){c[f+(e<<2)>>2]=Rw(b)|0;b=e+1|0;a=c[d>>2]|0}else b=e;e=b;a=a+164|0}a=Sw(f,e)|0;while(1){if((Tw(a)|0)<=1)break;Xw(a,c[(Ww(Vw(Uw(a)|0)|0)|0)+8>>2]|0)}_I(a);a=0;while(1){if((a|0)>=(e|0))break;_I(c[f+(a<<2)>>2]|0);a=a+1|0}_I(f);if((c[42299]|0)==((c[42295]|0)+-1|0)){Yw();return}else ma(87335,87365,523,87370)}function Fw(){var a=0,b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;i=c[42305]|0;f=c[42299]|0;j=c[42300]|0;k=c[42255]|0;b=0;a=0;g=i;while(1){if((g|0)>=(f|0)){h=8;break}e=c[j+(g<<2)>>2]|0;d=c[(c[e+16>>2]|0)+160>>2]|0;if((d|0)<0){if(!a)a=e;else a=(c[(c[a+16>>2]|0)+160>>2]|0)>(d|0)?e:a;b=b+1|0;if((b|0)>=(k|0))break}e=g+1|0;c[42305]=e;g=e}if((h|0)==8)if((i|0)>0){f=0;while(1){if((f|0)>=(i|0))break;d=c[j+(f<<2)>>2]|0;e=c[(c[d+16>>2]|0)+160>>2]|0;if((e|0)<0){if(!a)a=d;else a=(c[(c[a+16>>2]|0)+160>>2]|0)>(e|0)?d:a;b=b+1|0;if((b|0)>=(k|0))break}f=f+1|0}c[42305]=f}return a|0}function Gw(a){a=a|0;var b=0,d=0;b=c[a>>2]&3;d=c[((b|0)==3?a:a+48|0)+40>>2]|0;a=c[((b|0)==2?a:a+-48|0)+40>>2]|0;b=(c[(c[d+16>>2]|0)+288>>2]|0)<(c[(c[a+16>>2]|0)+288>>2]|0);a=b?d:a;c[42301]=0;c[42302]=2147483647;d=c[a+16>>2]|0;c[42303]=c[d+284>>2];c[42304]=c[d+288>>2];if(b)Qw(a);else Pw(a);return c[42301]|0}function Hw(a,b){a=a|0;b=b|0;var d=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0;o=l;l=l+16|0;n=o;g=c[b>>2]&3;m=b+-48|0;j=b+48|0;k=b+16|0;g=(c[(c[(c[((g|0)==2?b:m)+40>>2]|0)+16>>2]|0)+232>>2]|0)-(c[(c[(c[((g|0)==3?b:j)+40>>2]|0)+16>>2]|0)+232>>2]|0)-(e[(c[k>>2]|0)+170>>1]|0)|0;do if((g|0)>0){d=c[a>>2]&3;h=c[((d|0)==3?a:a+48|0)+40>>2]|0;i=c[h+16>>2]|0;if(((c[i+276>>2]|0)+(c[i+268>>2]|0)|0)==1){Lw(h,g);break}d=c[((d|0)==2?a:a+-48|0)+40>>2]|0;f=c[d+16>>2]|0;if(((c[f+276>>2]|0)+(c[f+268>>2]|0)|0)==1){Lw(d,0-g|0);break}if((c[i+288>>2]|0)<(c[f+288>>2]|0)){Lw(h,g);break}else{Lw(d,0-g|0);break}}while(0);d=a+16|0;f=c[(c[d>>2]|0)+160>>2]|0;g=c[b>>2]&3;g=Mw(c[((g|0)==3?b:j)+40>>2]|0,c[((g|0)==2?b:m)+40>>2]|0,f,1)|0;i=c[b>>2]&3;if((Mw(c[((i|0)==2?b:m)+40>>2]|0,c[((i|0)==3?b:j)+40>>2]|0,f,0)|0)==(g|0)){c[(c[k>>2]|0)+160>>2]=0-f;c[(c[d>>2]|0)+160>>2]=0;Nw(a,b);n=c[g+16>>2]|0;Ow(g,c[n+280>>2]|0,c[n+284>>2]|0)|0;l=o;return}else{_l(1,87296,n)|0;Ua(169024,1)}}function Iw(){var b=0,d=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;Kw();m=vw((c[42297]<<2)+4|0)|0;d=c[42297]|0;b=0;while(1){if((b|0)>(d|0))break;c[m+(b<<2)>>2]=0;b=b+1|0}b=(c[(c[42298]|0)+16>>2]|0)+192|0;d=b;while(1){d=c[d>>2]|0;if(!d)break;d=c[d+16>>2]|0;if(!(a[d+156>>0]|0)){l=m+(c[d+232>>2]<<2)|0;c[l>>2]=(c[l>>2]|0)+1}d=d+164|0}while(1){b=c[b>>2]|0;if(!b)break;l=b+16|0;b=c[l>>2]|0;if(!(a[b+156>>0]|0)){h=c[42297]|0;f=c[b+172>>2]|0;k=0;j=0;d=0;while(1){g=c[f+(d<<2)>>2]|0;if(!g)break;n=c[g+16>>2]|0;i=(c[(c[(c[((c[g>>2]&3|0)==3?g:g+48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)+(e[n+170>>1]|0)|0;k=(c[n+156>>2]|0)+k|0;j=(j|0)>(i|0)?j:i;d=d+1|0}g=c[b+180>>2]|0;i=0;d=0;while(1){f=c[g+(d<<2)>>2]|0;if(!f)break;o=c[f+16>>2]|0;n=(c[(c[(c[((c[f>>2]&3|0)==2?f:f+-48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)-(e[o+170>>1]|0)|0;i=(c[o+156>>2]|0)+i|0;h=(h|0)<(n|0)?h:n;d=d+1|0}d=(j|0)>0?j:0;if((k|0)==(i|0)){g=d;f=d;while(1){d=f+1|0;if((f|0)>=(h|0))break;g=(c[m+(d<<2)>>2]|0)<(c[m+(g<<2)>>2]|0)?d:g;f=d}o=b+232|0;n=m+(c[o>>2]<<2)|0;c[n>>2]=(c[n>>2]|0)+-1;n=m+(g<<2)|0;c[n>>2]=(c[n>>2]|0)+1;c[o>>2]=g}d=c[b+264>>2]|0;if(d){_I(d);b=c[l>>2]|0}d=c[b+272>>2]|0;if(d){_I(d);b=c[l>>2]|0}a[b+157>>0]=0}b=b+164|0}_I(m);return}function Jw(){var a=0,b=0,d=0,f=0,g=0,h=0;b=0;while(1){if((b|0)>=(c[42299]|0))break;a=c[(c[42300]|0)+(b<<2)>>2]|0;do if(((c[(c[a+16>>2]|0)+160>>2]|0)==0?(d=Gw(a)|0,d|0):0)?(f=c[d>>2]&3,f=(c[(c[(c[((f|0)==2?d:d+-48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)-(c[(c[(c[((f|0)==3?d:d+48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)-(e[(c[d+16>>2]|0)+170>>1]|0)|0,(f|0)>=2):0){h=c[a>>2]&3;g=c[((h|0)==3?a:a+48|0)+40>>2]|0;a=c[((h|0)==2?a:a+-48|0)+40>>2]|0;if((c[(c[g+16>>2]|0)+288>>2]|0)<(c[(c[a+16>>2]|0)+288>>2]|0)){Lw(g,f>>>1);break}else{Lw(a,(f|0)/-2|0);break}}while(0);b=b+1|0}Dw();return}function Kw(){var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;i=l;l=l+16|0;h=i;c[h>>2]=0;c[h>>2]=2147483647;c[42297]=-2147483647;b=(c[(c[42298]|0)+16>>2]|0)+192|0;e=b;g=2147483647;f=-2147483647;while(1){d=c[e>>2]|0;if(!d)break;e=c[d+16>>2]|0;if(!(a[e+156>>0]|0)){j=c[e+232>>2]|0;d=(g|0)<(j|0)?g:j;c[h>>2]=d;f=(f|0)>(j|0)?f:j;c[42297]=f}else d=g;e=e+164|0;g=d}if(g|0){while(1){b=c[b>>2]|0;if(!b)break;b=c[b+16>>2]|0;j=b+232|0;c[j>>2]=(c[j>>2]|0)-g;b=b+164|0}c[42297]=f-g;c[h>>2]=0}l=i;return}function Lw(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;f=a+16|0;a=c[f>>2]|0;e=a+232|0;c[e>>2]=(c[e>>2]|0)-b;e=0;while(1){d=c[(c[a+272>>2]|0)+(e<<2)>>2]|0;if(!d){e=0;break}if((d|0)!=(c[a+280>>2]|0)){Lw(c[((c[d>>2]&3|0)==2?d:d+-48|0)+40>>2]|0,b);a=c[f>>2]|0}e=e+1|0}while(1){d=c[(c[a+264>>2]|0)+(e<<2)>>2]|0;if(!d)break;if((d|0)!=(c[a+280>>2]|0)){Lw(c[((c[d>>2]&3|0)==3?d:d+48|0)+40>>2]|0,b);a=c[f>>2]|0}e=e+1|0}return}function Mw(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;g=(e|0)==0&1;h=0-d|0;f=c[(c[b+16>>2]|0)+288>>2]|0;b=a;while(1){a=c[b+16>>2]|0;if((c[a+284>>2]|0)<=(f|0)?(f|0)<=(c[a+288>>2]|0):0)break;a=c[a+280>>2]|0;i=a+48|0;j=(c[a+16>>2]|0)+160|0;c[j>>2]=(((b|0)==(c[((c[a>>2]&3|0)==3?a:i)+40>>2]|0)?e:g)|0?d:h)+(c[j>>2]|0);j=c[a>>2]&3;i=c[((j|0)==3?a:i)+40>>2]|0;a=c[((j|0)==2?a:a+-48|0)+40>>2]|0;b=(c[(c[i+16>>2]|0)+288>>2]|0)>(c[(c[a+16>>2]|0)+288>>2]|0)?i:a}return b|0}function Nw(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;i=a+16|0;e=(c[i>>2]|0)+164|0;c[(c[b+16>>2]|0)+164>>2]=c[e>>2];c[(c[42300]|0)+(c[e>>2]<<2)>>2]=b;c[(c[i>>2]|0)+164>>2]=-1;i=(c[((c[a>>2]&3|0)==3?a:a+48|0)+40>>2]|0)+16|0;e=c[i>>2]|0;g=e+276|0;f=c[g>>2]|0;j=f+-1|0;c[g>>2]=j;g=e+272|0;h=0;while(1){if((h|0)>=(f|0)){k=3;break}d=c[g>>2]|0;if((c[d+(h<<2)>>2]|0)==(a|0))break;h=h+1|0}if((k|0)==3)d=c[e+272>>2]|0;c[d+(h<<2)>>2]=c[d+(j<<2)>>2];c[(c[(c[i>>2]|0)+272>>2]|0)+(j<<2)>>2]=0;i=(c[((c[a>>2]&3|0)==2?a:a+-48|0)+40>>2]|0)+16|0;e=c[i>>2]|0;g=e+268|0;f=c[g>>2]|0;j=f+-1|0;c[g>>2]=j;g=e+264|0;h=0;while(1){if((h|0)>=(f|0)){k=8;break}d=c[g>>2]|0;if((c[d+(h<<2)>>2]|0)==(a|0))break;h=h+1|0}if((k|0)==8)d=c[e+264>>2]|0;c[d+(h<<2)>>2]=c[d+(j<<2)>>2];c[(c[(c[i>>2]|0)+264>>2]|0)+(j<<2)>>2]=0;k=(c[((c[b>>2]&3|0)==3?b:b+48|0)+40>>2]|0)+16|0;a=c[k>>2]|0;j=c[a+272>>2]|0;a=a+276|0;i=c[a>>2]|0;c[a>>2]=i+1;c[j+(i<<2)>>2]=b;k=c[k>>2]|0;c[(c[k+272>>2]|0)+(c[k+276>>2]<<2)>>2]=0;k=(c[((c[b>>2]&3|0)==2?b:b+-48|0)+40>>2]|0)+16|0;i=c[k>>2]|0;j=c[i+264>>2]|0;i=i+268|0;a=c[i>>2]|0;c[i>>2]=a+1;c[j+(a<<2)>>2]=b;k=c[k>>2]|0;c[(c[k+264>>2]|0)+(c[k+268>>2]<<2)>>2]=0;return}function Ow(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;g=a+16|0;a=c[g>>2]|0;c[a+280>>2]=b;c[a+284>>2]=d;f=0;while(1){e=c[(c[a+272>>2]|0)+(f<<2)>>2]|0;if(!e){f=0;break}if((e|0)!=(b|0)){d=Ow(c[((c[e>>2]&3|0)==2?e:e+-48|0)+40>>2]|0,e,d)|0;a=c[g>>2]|0}f=f+1|0}while(1){e=c[(c[a+264>>2]|0)+(f<<2)>>2]|0;if(!e)break;if((e|0)!=(b|0)){d=Ow(c[((c[e>>2]&3|0)==3?e:e+48|0)+40>>2]|0,e,d)|0;a=c[g>>2]|0}f=f+1|0}c[a+288>>2]=d;return d+1|0}function Pw(a){a=a|0;var b=0,d=0,f=0,g=0,h=0,i=0,j=0;i=a+16|0;g=0;while(1){a=c[i>>2]|0;d=c[(c[a+180>>2]|0)+(g<<2)>>2]|0;if(!d){d=0;break}f=c[d+16>>2]|0;if((c[f+164>>2]|0)<0){a=c[d>>2]&3;b=c[(c[((a|0)==2?d:d+-48|0)+40>>2]|0)+16>>2]|0;j=c[b+288>>2]|0;if((c[42303]|0)>(j|0)|(j|0)>(c[42304]|0)?(h=(c[b+232>>2]|0)-(c[(c[(c[((a|0)==3?d:d+48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)-(e[f+170>>1]|0)|0,(h|0)<(c[42302]|0)|(c[42301]|0)==0):0){c[42301]=d;c[42302]=h}}else{b=c[((c[d>>2]&3|0)==2?d:d+-48|0)+40>>2]|0;if((c[(c[b+16>>2]|0)+288>>2]|0)<(c[a+288>>2]|0))Pw(b)}g=g+1|0}while(1){b=c[(c[a+264>>2]|0)+(d<<2)>>2]|0;if(!((b|0)!=0&(c[42302]|0)>0))break;b=c[((c[b>>2]&3|0)==3?b:b+48|0)+40>>2]|0;if((c[(c[b+16>>2]|0)+288>>2]|0)<(c[a+288>>2]|0)){Pw(b);a=c[i>>2]|0}d=d+1|0}return}function Qw(a){a=a|0;var b=0,d=0,f=0,g=0,h=0,i=0,j=0;i=a+16|0;g=0;while(1){a=c[i>>2]|0;d=c[(c[a+172>>2]|0)+(g<<2)>>2]|0;if(!d){d=0;break}f=c[d+16>>2]|0;if((c[f+164>>2]|0)<0){a=c[d>>2]&3;b=c[(c[((a|0)==3?d:d+48|0)+40>>2]|0)+16>>2]|0;j=c[b+288>>2]|0;if((c[42303]|0)>(j|0)|(j|0)>(c[42304]|0)?(h=(c[(c[(c[((a|0)==2?d:d+-48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)-(c[b+232>>2]|0)-(e[f+170>>1]|0)|0,(h|0)<(c[42302]|0)|(c[42301]|0)==0):0){c[42301]=d;c[42302]=h}}else{b=c[((c[d>>2]&3|0)==3?d:d+48|0)+40>>2]|0;if((c[(c[b+16>>2]|0)+288>>2]|0)<(c[a+288>>2]|0))Qw(b)}g=g+1|0}while(1){b=c[(c[a+272>>2]|0)+(d<<2)>>2]|0;if(!((b|0)!=0&(c[42302]|0)>0))break;b=c[((c[b>>2]&3|0)==2?b:b+-48|0)+40>>2]|0;if((c[(c[b+16>>2]|0)+288>>2]|0)<(c[a+288>>2]|0)){Qw(b);a=c[i>>2]|0}d=d+1|0}return}function Rw(a){a=a|0;var b=0;b=vw(16)|0;c[b>>2]=a;c[b+4>>2]=fx(a,b)|0;c[b+12>>2]=b;return b|0}function Sw(a,b){a=a|0;b=b|0;var d=0,e=0;e=vw(8)|0;c[e>>2]=a;c[e+4>>2]=b;d=0;while(1){if((d|0)>=(b|0))break;c[(c[a+(d<<2)>>2]|0)+8>>2]=d;d=d+1|0}d=(b|0)/2|0;while(1){if((d|0)<=-1)break;Xw(e,d);d=d+-1|0}return e|0}function Tw(a){a=a|0;return c[a+4>>2]|0}function Uw(a){a=a|0;var b=0,d=0,e=0,f=0;f=c[a>>2]|0;b=c[f>>2]|0;c[b+8>>2]=-1;d=a+4|0;e=(c[d>>2]|0)+-1|0;c[f>>2]=c[f+(e<<2)>>2];f=c[a>>2]|0;c[(c[f>>2]|0)+8>>2]=0;c[f+(e<<2)>>2]=b;c[d>>2]=e;Xw(a,0);return b|0}function Vw(a){a=a|0;return ex(c[a>>2]|0,0,0)|0}function Ww(a){a=a|0;var b=0,d=0,f=0,g=0,h=0,i=0;b=a+16|0;if((c[(c[b>>2]|0)+164>>2]|0)>-1)ma(87384,87365,463,87398);g=a+48|0;d=ax(c[((c[a>>2]&3|0)==3?a:g)+40>>2]|0)|0;i=a+-48|0;f=ax(c[((c[a>>2]&3|0)==2?a:i)+40>>2]|0)|0;h=c[a>>2]&3;b=(c[(c[(c[((h|0)==2?a:i)+40>>2]|0)+16>>2]|0)+232>>2]|0)-(c[(c[(c[((h|0)==3?a:g)+40>>2]|0)+16>>2]|0)+232>>2]|0)-(e[(c[b>>2]|0)+170>>1]|0)|0;if((c[d+8>>2]|0)==-1)bx(c[d>>2]|0,0,b);else bx(c[f>>2]|0,0,0-b|0);cx(a);return dx(d,f)|0}function Xw(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;h=c[a>>2]|0;g=c[a+4>>2]|0;while(1){a=b<<1;f=a+2|0;a=a|1;if(!((a|0)<(g|0)?(c[(c[h+(a<<2)>>2]|0)+4>>2]|0)<(c[(c[h+(b<<2)>>2]|0)+4>>2]|0):0))a=b;if((f|0)>=(g|0))break;d=h+(f<<2)|0;e=c[d>>2]|0;if((f|0)==(b|0)?1:(c[e+4>>2]|0)>=(c[(c[h+(a<<2)>>2]|0)+4>>2]|0))break;i=h+(b<<2)|0;a=c[i>>2]|0;c[i>>2]=e;c[d>>2]=a;c[(c[i>>2]|0)+8>>2]=b;c[a+8>>2]=f;b=f}return}function Yw(){Ow(c[(c[(c[42298]|0)+16>>2]|0)+192>>2]|0,0,1)|0;Zw(c[(c[(c[42298]|0)+16>>2]|0)+192>>2]|0,0);return}function Zw(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;f=a+16|0;d=0;while(1){a=c[f>>2]|0;e=c[(c[a+272>>2]|0)+(d<<2)>>2]|0;if(!e){e=0;break}if((e|0)!=(b|0))Zw(c[((c[e>>2]&3|0)==2?e:e+-48|0)+40>>2]|0,e);d=d+1|0}while(1){d=c[(c[a+264>>2]|0)+(e<<2)>>2]|0;if(!d)break;if((d|0)!=(b|0)){Zw(c[((c[d>>2]&3|0)==3?d:d+48|0)+40>>2]|0,d);a=c[f>>2]|0}e=e+1|0}if(b|0)_w(b);return}function _w(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0;b=c[a>>2]&3;d=c[((b|0)==3?a:a+48|0)+40>>2]|0;e=c[d+16>>2]|0;if((c[e+280>>2]|0)==(a|0))i=1;else{e=c[((b|0)==2?a:a+-48|0)+40>>2]|0;i=-1;d=e;e=c[e+16>>2]|0}g=c[e+180>>2]|0;b=0;f=0;while(1){h=c[g+(f<<2)>>2]|0;if(!h)break;b=($w(h,d,i)|0)+b|0;f=f+1|0}g=c[e+172>>2]|0;e=0;while(1){f=c[g+(e<<2)>>2]|0;if(!f)break;b=($w(f,d,i)|0)+b|0;e=e+1|0}c[(c[a+16>>2]|0)+160>>2]=b;return}function $w(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;h=c[a>>2]&3;i=(h|0)==3?a:a+48|0;e=c[i+40>>2]|0;if((e|0)==(b|0))e=c[((h|0)==2?a:a+-48|0)+40>>2]|0;g=c[b+16>>2]|0;f=c[(c[e+16>>2]|0)+288>>2]|0;if((c[g+284>>2]|0)<=(f|0)?(f|0)<=(c[g+288>>2]|0):0){f=c[a+16>>2]|0;if((c[f+164>>2]|0)>-1)e=c[f+160>>2]|0;else e=0;g=1;e=e-(c[f+156>>2]|0)|0}else{g=0;e=c[(c[a+16>>2]|0)+156>>2]|0}i=(c[((d|0)>0?((h|0)==2?a:a+-48|0):i)+40>>2]|0)==(b|0)?1:-1;return (((g?i:0-i|0)|0)<0?0-e|0:e)|0}function ax(a){a=a|0;var b=0,d=0;a=c[(c[a+16>>2]|0)+280>>2]|0;while(1){b=a+12|0;d=c[b>>2]|0;if(!((d|0)!=(a|0)&(d|0)!=0))break;a=c[d+12>>2]|0;if(!a){a=d;continue}c[b>>2]=a}return a|0}function bx(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0;h=a+16|0;e=c[h>>2]|0;g=e+232|0;c[g>>2]=(c[g>>2]|0)+d;g=0;while(1){f=c[(c[e+264>>2]|0)+(g<<2)>>2]|0;if(!f){g=0;break}f=c[((c[f>>2]&3|0)==3?f:f+48|0)+40>>2]|0;if((f|0)!=(b|0)){bx(f,a,d);e=c[h>>2]|0}g=g+1|0}while(1){f=c[(c[e+272>>2]|0)+(g<<2)>>2]|0;if(!f)break;f=c[((c[f>>2]&3|0)==2?f:f+-48|0)+40>>2]|0;if((f|0)!=(b|0)){bx(f,a,d);e=c[h>>2]|0}g=g+1|0}return}function cx(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;h=l;l=l+32|0;d=(c[b+16>>2]|0)+164|0;if((c[d>>2]|0)>-1){_l(1,87487,h)|0;Ua(169024,1)}g=c[42299]|0;c[d>>2]=g;d=c[42300]|0;c[42299]=g+1;c[d+(g<<2)>>2]=b;d=c[b>>2]|0;g=b+48|0;e=c[((d&3|0)==3?b:g)+40>>2]|0;if(!(a[(c[e+16>>2]|0)+157>>0]|0)){f=c[42306]|0;d=c[42307]|0;c[42307]=d+1;c[f+(d<<2)>>2]=e;d=c[b>>2]|0}f=b+-48|0;e=c[((d&3|0)==2?b:f)+40>>2]|0;if(!(a[(c[e+16>>2]|0)+157>>0]|0)){i=c[42306]|0;d=c[42307]|0;c[42307]=d+1;c[i+(d<<2)>>2]=e;d=c[b>>2]|0}i=(c[((d&3|0)==3?b:g)+40>>2]|0)+16|0;d=c[i>>2]|0;a[d+157>>0]=1;e=c[d+272>>2]|0;d=d+276|0;g=c[d>>2]|0;c[d>>2]=g+1;c[e+(g<<2)>>2]=b;g=c[i>>2]|0;c[(c[g+272>>2]|0)+(c[g+276>>2]<<2)>>2]=0;i=c[i>>2]|0;if(!(c[(c[i+180>>2]|0)+((c[i+276>>2]|0)+-1<<2)>>2]|0)){_l(1,87521,h+8|0)|0;Ua(169024,1)}i=(c[((c[b>>2]&3|0)==2?b:f)+40>>2]|0)+16|0;e=c[i>>2]|0;a[e+157>>0]=1;f=c[e+264>>2]|0;e=e+268|0;g=c[e>>2]|0;c[e>>2]=g+1;c[f+(g<<2)>>2]=b;b=c[i>>2]|0;c[(c[b+264>>2]|0)+(c[b+268>>2]<<2)>>2]=0;i=c[i>>2]|0;if(!(c[(c[i+172>>2]|0)+((c[i+268>>2]|0)+-1<<2)>>2]|0)){_l(1,87556,h+16|0)|0;Ua(169024,1)}else{l=h;return}}function dx(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0;while(1){g=a+12|0;d=c[g>>2]|0;if((d|0)==0|(d|0)==(a|0))break;else a=d}while(1){f=b+12|0;d=c[f>>2]|0;if((d|0)==0|(d|0)==(b|0))break;else b=d}if((a|0)!=(b|0)){e=c[a+8>>2]|0;d=c[b+8>>2]|0;do if((e|0)>-1)if((d|0)==-1)h=a;else j=10;else if((d|0)>-1)if((e|0)==-1){h=b;break}else{j=10;break}else ma(87410,87365,327,87457);while(0);if((j|0)==10)h=(c[b+4>>2]|0)<(c[a+4>>2]|0)?a:b;c[f>>2]=h;c[g>>2]=h;c[h+4>>2]=(c[b+4>>2]|0)+(c[a+4>>2]|0);if((c[h+8>>2]|0)>-1)i=h;else ma(87468,87365,335,87457)}else i=a;return i|0}function ex(a,b,d){a=a|0;b=b|0;d=d|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;l=ax(a)|0;if(d){k=c[d>>2]&3;if(((c[(c[(c[((k|0)==2?d:d+-48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)-(c[(c[(c[((k|0)==3?d:d+48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)|0)!=(e[(c[d+16>>2]|0)+170>>1]|0|0))f=3}else{d=0;f=3}a:do if((f|0)==3){k=a+16|0;j=0;while(1){f=c[k>>2]|0;i=c[(c[f+180>>2]|0)+(j<<2)>>2]|0;if(!i){j=0;break}f=i+16|0;g=i+-48|0;h=c[((c[i>>2]&3|0)==2?i:g)+40>>2]|0;do if((c[(c[f>>2]|0)+164>>2]|0)>-1){if((h|0)!=(b|0))d=ex(h,a,d)|0}else if((ax(h)|0)!=(l|0)){if(d|0?(m=c[i>>2]&3,h=c[d>>2]&3,((c[(c[(c[((m|0)==2?i:g)+40>>2]|0)+16>>2]|0)+232>>2]|0)-(c[(c[(c[((m|0)==3?i:i+48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)-(e[(c[f>>2]|0)+170>>1]|0)|0)>=((c[(c[(c[((h|0)==2?d:d+-48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)-(c[(c[(c[((h|0)==3?d:d+48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)-(e[(c[d+16>>2]|0)+170>>1]|0)|0)):0)break;d=i}while(0);j=j+1|0}while(1){f=c[(c[f+172>>2]|0)+(j<<2)>>2]|0;if(!f)break a;g=f+16|0;h=f+48|0;i=c[((c[f>>2]&3|0)==3?f:h)+40>>2]|0;do if((c[(c[g>>2]|0)+164>>2]|0)>-1){if((i|0)!=(b|0))d=ex(i,a,d)|0}else if((ax(i)|0)!=(l|0)){if(d|0?(i=c[f>>2]&3,m=c[d>>2]&3,((c[(c[(c[((i|0)==2?f:f+-48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)-(c[(c[(c[((i|0)==3?f:h)+40>>2]|0)+16>>2]|0)+232>>2]|0)-(e[(c[g>>2]|0)+170>>1]|0)|0)>=((c[(c[(c[((m|0)==2?d:d+-48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)-(c[(c[(c[((m|0)==3?d:d+48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)-(e[(c[d+16>>2]|0)+170>>1]|0)|0)):0)break;d=f}while(0);j=j+1|0;f=c[k>>2]|0}}while(0);return d|0}function fx(a,b){a=a|0;b=b|0;var d=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;l=a+16|0;d=c[l>>2]|0;c[d+280>>2]=b;a=1;h=0;while(1){g=c[(c[d+172>>2]|0)+(h<<2)>>2]|0;if(!g){h=0;break}f=c[g+16>>2]|0;if(((c[f+164>>2]|0)<=-1?(i=c[g>>2]&3,j=g+48|0,k=c[(c[((i|0)==3?g:j)+40>>2]|0)+16>>2]|0,(c[k+280>>2]|0)==0):0)?((c[(c[(c[((i|0)==2?g:g+-48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)-(c[k+232>>2]|0)|0)==(e[f+170>>1]|0|0):0){cx(g);a=(fx(c[((c[g>>2]&3|0)==3?g:j)+40>>2]|0,b)|0)+a|0;d=c[l>>2]|0}h=h+1|0}while(1){f=c[(c[d+180>>2]|0)+(h<<2)>>2]|0;if(!f)break;g=c[f+16>>2]|0;if(((c[g+164>>2]|0)<=-1?(m=c[f>>2]&3,n=f+-48|0,o=c[(c[((m|0)==2?f:n)+40>>2]|0)+16>>2]|0,(c[o+280>>2]|0)==0):0)?((c[o+232>>2]|0)-(c[(c[(c[((m|0)==3?f:f+48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)|0)==(e[g+170>>1]|0|0):0){cx(f);a=(fx(c[((c[f>>2]&3|0)==2?f:n)+40>>2]|0,b)|0)+a|0;d=c[l>>2]|0}h=h+1|0}return a|0}function gx(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=Im(a,87620)|0;if(!d)d=30;else d=rM(d)|0;return zw(a,b,c,d)|0}function hx(a){a=+a;return +((c[42183]|0)==0?a:+h[20895]-a)}function ix(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0.0,t=0.0,u=0;r=l;l=l+16|0;q=r;c[42308]=c[(c[(c[d+64>>2]|0)+8>>2]|0)+4>>2];jx(d);i=c[d+16>>2]|0;t=+h[i+32>>3];s=+h[i+40>>3];kx(e,87631,+h[b+352>>3]);kx(e,87638,t*.013888888888888888);kx(e,87638,s*.013888888888888888);lx(e);i=co(d)|0;while(1){if(!i)break;g=i+16|0;if(!(a[(c[g>>2]|0)+118>>0]|0)){mx(e,87640,Wp(Dn(i)|0)|0);p=(c[g>>2]|0)+16|0;c[q>>2]=c[p>>2];c[q+4>>2]=c[p+4>>2];c[q+8>>2]=c[p+8>>2];c[q+12>>2]=c[p+12>>2];nx(e,q);if(!(a[(c[(c[g>>2]|0)+104>>2]|0)+82>>0]|0)){b=ro(i)|0;b=ox(b,c[c[(c[g>>2]|0)+104>>2]>>2]|0)|0}else b=Wp(Jm(i,c[42198]|0)|0)|0;kx(e,87638,+h[(c[g>>2]|0)+32>>3]);kx(e,87638,+h[(c[g>>2]|0)+40>>3]);mx(e,87638,b);mx(e,87638,GA(i,c[42201]|0,95889)|0);mx(e,87638,c[c[(c[g>>2]|0)+8>>2]>>2]|0);mx(e,87638,GA(i,c[42192]|0,122106)|0);b=GA(i,c[42193]|0,174181)|0;if(!(a[b>>0]|0))b=GA(i,c[42192]|0,119592)|0;mx(e,87638,b);lx(e)}i=eo(d,i)|0}o=f<<24>>24==0;n=co(d)|0;while(1){if(!n)break;m=Pm(d,n)|0;while(1){if(!m)break;if(o){f=174181;j=174181}else{j=Im(m,96242)|0;f=Im(m,96251)|0;f=f|0?f:174181;j=j|0?j:174181}p=m+16|0;b=c[p>>2]|0;k=c[b+8>>2]|0;a:do if(k){i=c[k+4>>2]|0;b=0;g=0;while(1){if((b|0)>=(i|0))break;u=(c[(c[k>>2]|0)+(b*48|0)+4>>2]|0)+g|0;b=b+1|0;g=u}mx(e,0,96237);px(e,c[((c[m>>2]&3|0)==3?m:m+48|0)+40>>2]|0,j);px(e,c[((c[m>>2]&3|0)==2?m:m+-48|0)+40>>2]|0,f);qx(e,g);f=0;while(1){b=c[p>>2]|0;g=c[b+8>>2]|0;if((f|0)>=(c[g+4>>2]|0))break a;i=c[g>>2]|0;g=c[i+(f*48|0)>>2]|0;i=c[i+(f*48|0)+4>>2]|0;b=0;while(1){if((b|0)>=(i|0))break;u=g+(b<<4)|0;c[q>>2]=c[u>>2];c[q+4>>2]=c[u+4>>2];c[q+8>>2]=c[u+8>>2];c[q+12>>2]=c[u+12>>2];nx(e,q);b=b+1|0}f=f+1|0}}while(0);if(c[b+96>>2]|0){u=ro(c[((c[m>>2]&3|0)==3?m:m+48|0)+40>>2]|0)|0;mx(e,87638,ox(u,c[c[(c[p>>2]|0)+96>>2]>>2]|0)|0);u=(c[(c[p>>2]|0)+96>>2]|0)+56|0;c[q>>2]=c[u>>2];c[q+4>>2]=c[u+4>>2];c[q+8>>2]=c[u+8>>2];c[q+12>>2]=c[u+12>>2];nx(e,q)}mx(e,87638,GA(m,c[42229]|0,95889)|0);mx(e,87638,GA(m,c[42220]|0,122106)|0);lx(e);m=Rm(d,m)|0}n=eo(d,n)|0}rx(87646,e);l=r;return}function jx(a){a=a|0;var b=0.0;if(c[42183]|0){a=c[a+16>>2]|0;b=+h[a+24>>3]+ +h[a+40>>3];h[20895]=b;h[20896]=b*.013888888888888888}return}function kx(a,b,c){a=a|0;b=b|0;c=+c;var d=0,e=0,f=0;f=l;l=l+1040|0;e=f;d=f+8|0;if(b|0)rx(b,a);h[e>>3]=c;pL(d,87652,e)|0;rx(d,a);l=f;return}function lx(b){b=b|0;a[174077]=10;ab[c[42308]&63](b,174077)|0;return}function mx(a,b,c){a=a|0;b=b|0;c=c|0;if(b|0)rx(b,a);rx(c,a);return}function nx(a,b){a=a|0;b=b|0;var d=0.0;kx(a,87638,+h[b>>3]*.013888888888888888);if(!(c[42183]|0))d=+h[b+8>>3];else d=+h[20895]-+h[b+8>>3];kx(a,87638,d*.013888888888888888);return}function ox(a,b){a=a|0;b=b|0;var c=0;c=$o(a,b)|0;b=Wp(c)|0;bp(a,c)|0;return b|0}function px(b,d,e){b=b|0;d=d|0;e=e|0;var f=0;if(!(a[(c[d+16>>2]|0)+118>>0]|0))d=Wp(Dn(d)|0)|0;else{f=ro(d)|0;d=ox(f,(WJ(Dn(d)|0,58)|0)+1|0)|0}mx(b,87638,d);if(e|0?a[e>>0]|0:0)mx(b,93017,Wp(e)|0);return}function qx(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=l;l=l+1040|0;f=d;e=d+8|0;rx(87638,a);c[f>>2]=b;pL(e,122187,f)|0;rx(e,a);l=d;return}function rx(a,b){a=a|0;b=b|0;ab[c[42308]&63](b,a)|0;return} +function EB(a,b){a=a|0;b=b|0;if((+h[a+16>>3]>=+h[b>>3]?+h[b+16>>3]>=+h[a>>3]:0)?+h[a+24>>3]>=+h[b+8>>3]:0)a=+h[b+24>>3]>=+h[a+8>>3]&1;else a=0;return a|0}function FB(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0;n=l;l=l+96|0;k=n+64|0;j=n+48|0;i=n+32|0;f=n+16|0;g=n;m=a+4|0;d=c[m>>2]|0;if(!d)ma(94759,92694,1637,94767);e=c[a>>2]|0;c[g>>2]=c[e>>2];c[g+4>>2]=c[e+4>>2];c[g+8>>2]=c[e+8>>2];c[g+12>>2]=c[e+12>>2];e=1;while(1){if((e|0)>=(d|0)){h=7;break}d=(c[a>>2]|0)+(e<<4)|0;c[f>>2]=c[d>>2];c[f+4>>2]=c[d+4>>2];c[f+8>>2]=c[d+8>>2];c[f+12>>2]=c[d+12>>2];c[i>>2]=c[d>>2];c[i+4>>2]=c[d+4>>2];c[i+8>>2]=c[d+8>>2];c[i+12>>2]=c[d+12>>2];c[j>>2]=c[g>>2];c[j+4>>2]=c[g+4>>2];c[j+8>>2]=c[g+8>>2];c[j+12>>2]=c[g+12>>2];c[k>>2]=c[b>>2];c[k+4>>2]=c[b+4>>2];c[k+8>>2]=c[b+8>>2];c[k+12>>2]=c[b+12>>2];c[k+16>>2]=c[b+16>>2];c[k+20>>2]=c[b+20>>2];c[k+24>>2]=c[b+24>>2];c[k+28>>2]=c[b+28>>2];if((Yv(i,j,k)|0)!=-1){d=1;break};c[g>>2]=c[f>>2];c[g+4>>2]=c[f+4>>2];c[g+8>>2]=c[f+8>>2];c[g+12>>2]=c[f+12>>2];e=e+1|0;d=c[m>>2]|0}do if((h|0)==7){d=c[a+8>>2]|0;if(d|0?(g=a+16|0,h=c[a>>2]|0,c[i>>2]=c[g>>2],c[i+4>>2]=c[g+4>>2],c[i+8>>2]=c[g+8>>2],c[i+12>>2]=c[g+12>>2],c[j>>2]=c[h>>2],c[j+4>>2]=c[h+4>>2],c[j+8>>2]=c[h+8>>2],c[j+12>>2]=c[h+12>>2],c[k>>2]=c[b>>2],c[k+4>>2]=c[b+4>>2],c[k+8>>2]=c[b+8>>2],c[k+12>>2]=c[b+12>>2],c[k+16>>2]=c[b+16>>2],c[k+20>>2]=c[b+20>>2],c[k+24>>2]=c[b+24>>2],c[k+28>>2]=c[b+28>>2],(GB(i,j,d,k)|0)<<24>>24):0){d=1;break}d=c[a+12>>2]|0;if(d|0?(h=a+32|0,m=(c[a>>2]|0)+((c[m>>2]|0)+-1<<4)|0,c[i>>2]=c[h>>2],c[i+4>>2]=c[h+4>>2],c[i+8>>2]=c[h+8>>2],c[i+12>>2]=c[h+12>>2],c[j>>2]=c[m>>2],c[j+4>>2]=c[m+4>>2],c[j+8>>2]=c[m+8>>2],c[j+12>>2]=c[m+12>>2],c[k>>2]=c[b>>2],c[k+4>>2]=c[b+4>>2],c[k+8>>2]=c[b+8>>2],c[k+12>>2]=c[b+12>>2],c[k+16>>2]=c[b+16>>2],c[k+20>>2]=c[b+20>>2],c[k+24>>2]=c[b+24>>2],c[k+28>>2]=c[b+28>>2],(GB(i,j,d,k)|0)<<24>>24):0){d=1;break}d=0}while(0);l=n;return d|0}function GB(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0.0;m=l;l=l+160|0;g=m+144|0;f=m+128|0;n=m+96|0;i=m+64|0;j=m+32|0;k=m;o=+h[e+16>>3];c[f>>2]=c[a>>2];c[f+4>>2]=c[a+4>>2];c[f+8>>2]=c[a+8>>2];c[f+12>>2]=c[a+12>>2];c[g>>2]=c[b>>2];c[g+4>>2]=c[b+4>>2];c[g+8>>2]=c[b+8>>2];c[g+12>>2]=c[b+12>>2];Rt(n,f,g,1.0,d);if(((o>=+h[n>>3]?(c[f>>2]=c[a>>2],c[f+4>>2]=c[a+4>>2],c[f+8>>2]=c[a+8>>2],c[f+12>>2]=c[a+12>>2],c[g>>2]=c[b>>2],c[g+4>>2]=c[b+4>>2],c[g+8>>2]=c[b+8>>2],c[g+12>>2]=c[b+12>>2],Rt(i,f,g,1.0,d),+h[i+16>>3]>=+h[e>>3]):0)?(o=+h[e+24>>3],c[f>>2]=c[a>>2],c[f+4>>2]=c[a+4>>2],c[f+8>>2]=c[a+8>>2],c[f+12>>2]=c[a+12>>2],c[g>>2]=c[b>>2],c[g+4>>2]=c[b+4>>2],c[g+8>>2]=c[b+8>>2],c[g+12>>2]=c[b+12>>2],Rt(j,f,g,1.0,d),o>=+h[j+8>>3]):0)?(c[f>>2]=c[a>>2],c[f+4>>2]=c[a+4>>2],c[f+8>>2]=c[a+8>>2],c[f+12>>2]=c[a+12>>2],c[g>>2]=c[b>>2],c[g+4>>2]=c[b+4>>2],c[g+8>>2]=c[b+8>>2],c[g+12>>2]=c[b+12>>2],Rt(k,f,g,1.0,d),+h[k+24>>3]>=+h[e+8>>3]):0)f=1;else f=0;l=m;return f|0}function HB(b,d){b=b|0;d=d|0;var e=0,f=0,g=0;g=l;l=l+16|0;f=g;a:do if((b|0)!=0?(e=a[b>>0]|0,e<<24>>24!=0):0){do switch(e<<24>>24|0){case 48:{d=2;break a}case 57:case 56:case 55:case 54:case 53:case 52:case 51:case 50:case 49:{d=10;break a}case 67:case 99:{e=b+1|0;if(!(iK(e,94782)|0)){d=4;break a}if(!(iK(e,94788)|0)){d=12;break a}break}case 70:case 102:{if(!(iK(b+1|0,94796)|0)){d=2;break a}break}case 76:case 108:{if(!(iK(b+1|0,94801)|0)){d=2;break a}break}case 78:case 110:{e=b+1|0;if(!(iK(e,94805)|0)){d=0;break a}if(!(iK(e,94809)|0)){d=2;break a}break}case 79:case 111:{if(!(iK(b+1|0,94811)|0)){d=8;break a}break}case 80:case 112:{if(!(iK(b+1|0,94816)|0)){d=6;break a}break}case 83:case 115:{if(!(iK(b+1|0,94824)|0)){d=10;break a}break}case 84:case 116:{if(!(iK(b+1|0,94830)|0)){d=10;break a}break}case 89:case 121:{if(!(iK(b+1|0,94834)|0)){d=10;break a}break}default:{}}while(0);c[f>>2]=b;_l(0,94837,f)|0}while(0);l=g;return d|0}function IB(d,f){d=d|0;f=f|0;var g=0;g=Im(d,94878)|0;if(g)if(!(a[g>>0]|0))f=0;else f=HB(g,f)|0;d=(c[d+16>>2]|0)+136|0;b[d>>1]=f|e[d>>1];return}function JB(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=+d;e=e|0;var f=0.0,g=0.0,i=0.0,j=0.0,k=0.0,m=0,n=0,o=0.0,p=0,q=0.0,r=0,s=0.0,t=0,u=0,v=0,w=0;v=l;l=l+32|0;p=v+16|0;r=v;t=e&1;u=e&2;a:do if((c|0)==2){s=+h[a+16>>3];f=+h[a>>3];j=+h[a+24>>3];i=+h[a+8>>3];f=f-(s-f);h[p>>3]=f;h[r>>3]=s;i=i-(j-i);h[p+8>>3]=i;h[r+8>>3]=j}else{g=+h[a>>3];h[r>>3]=g;h[p>>3]=g;j=+h[a+8>>3];m=r+8|0;h[m>>3]=j;n=p+8|0;h[n>>3]=j;e=0;f=g;i=j;while(1){if((e|0)>=(c|0)){s=g;break a}w=a+(e<<4)|0;q=+h[w>>3];k=+h[(q>3];h[p>>3]=k;s=+h[a+(e<<4)+8>>3];o=+h[(s>3];h[n>>3]=o;q=+h[(q>g?w:r)>>3];h[r>>3]=q;s=+h[(s>j?w:r)+8>>3];h[m>>3]=s;e=e+1|0;f=k;i=o;g=q;j=s}}while(0);g=(s-f)*.5;q=g+f;o=(j-i)*.5;k=o+i;if(!t){f=j-k;j=d;i=+F(+j);j=+E(+j);if(!u){g=i*f-k;f=-k-o*i}else{f=i*f;g=k-f;f=f+k}h[b+8>>3]=g;h[b+24>>3]=f;d=j*(s-q);h[b>>3]=q-d;h[b+16>>3]=d+q}else{d=+C(+(o*o+g*g));h[b+8>>3]=u|0?k:-k;h[b>>3]=q;h[b+16>>3]=d*.25;h[b+24>>3]=d}l=v;return}function KB(a,b){a=a|0;b=b|0;var d=0.0,e=0,f=0;e=a+16|0;f=c[e>>2]|0;if(!(b<<24>>24)){d=+h[f+32>>3]*36.0;h[f+88>>3]=d;a=f+40|0}else{d=+h[f+40>>3]*36.0;h[f+88>>3]=d;a=f+32|0}h[f+96>>3]=d;h[(c[e>>2]|0)+80>>3]=+h[a>>3]*72.0;return}function LB(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,A=0;y=l;l=l+16|0;j=y+8|0;x=4;w=ZI(40)|0;c[w>>2]=0;s=y;o=0;e=_(22,b|0)|0;f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,w|0,x|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;a:do if((g|0)!=1){o=0;v=_(23,e<<3|0)|0;f=o;o=0;if((f|0)!=0&(p|0)!=0){e=SN(c[f>>2]|0,w|0,x|0)|0;if(!e)Ua(f|0,p|0);z=p}else e=-1;if((e|0)!=1){if(!(a[174076]|0))t=0;else{o=0;e=Z(2)|0;f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,w|0,x|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)==1){n=0;k=0;m=0;j=0;i=0;d=v;h=v;e=z;g=0;u=74;break}t=e}o=0;e=$(31,b|0,94886)|0;f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,w|0,x|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)!=1){c[42366]=0;b:do if(e|0?(i=a[e>>0]|0,i<<24>>24):0){h=e;f=i;g=0;while(1){i=h+1|0;if(!(f<<24>>24))break b;switch(f<<24>>24|0){case 99:{e=8;u=16;break}case 105:{e=18;u=16;break}case 109:{e=1;u=16;break}case 114:{e=4;u=16;break}case 115:{e=2;u=16;break}default:e=g}if((u|0)==16){u=0;e=g|e;c[42366]=e}h=i;f=a[i>>0]|0;g=e}}while(0);if(d|0){o=0;aa(11,0,94890,j|0)|0;e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,w|0,x|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){n=0;k=t;m=0;j=0;i=0;d=v;h=v;e=z;g=0;u=74;break}}o=0;r=$(32,b|0,0)|0;e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,w|0,x|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)!=1){m=c[r+16>>2]|0;if(c[42366]&2|0){o=0;ga(25,c[13918]|0,m|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,w|0,x|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){n=0;k=t;m=0;j=0;i=r;d=v;h=v;e=z;g=0;u=74;break}}o=0;g=_(24,b|0)|0;e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,w|0,x|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)!=1){n=0;while(1){if(!g)break;o=0;e=$(33,b|0,g|0)|0;f=o;o=0;if((f|0)!=0&(p|0)!=0){h=SN(c[f>>2]|0,w|0,x|0)|0;if(!h)Ua(f|0,p|0);z=p}else h=-1;if((h|0)==1){k=t;m=0;j=0;i=r;d=v;h=v;e=z;g=0;u=74;break a}i=n;while(1){if(!e)break;if(!(0==2?(c[(c[e+16>>2]|0)+8>>2]|0)!=0:0))u=32;c:do if((u|0)==32){u=0;do if(a[174076]|0){k=c[e>>2]&3;j=(c[c[((k|0)==3?e:e+48|0)+40>>2]>>2]|0)>>>4;k=(c[c[((k|0)==2?e:e+-48|0)+40>>2]>>2]|0)>>>4;if(j>>>0>k>>>0){o=0;f=aa(15,t|0,k|0,j|0)|0;h=o;o=0;if((h|0)!=0&(p|0)!=0){d=SN(c[h>>2]|0,w|0,x|0)|0;if(!d)Ua(h|0,p|0);z=p}else d=-1;if((d|0)==1){k=t;m=0;j=0;i=r;d=v;h=v;e=z;g=0;u=74;break a}if(f|0)break c;o=0;ha(59,t|0,k|0,j|0);f=o;o=0;if((f|0)!=0&(p|0)!=0){h=SN(c[f>>2]|0,w|0,x|0)|0;if(!h)Ua(f|0,p|0);z=p}else h=-1;if((h|0)==1){k=t;m=0;j=0;i=r;d=v;h=v;e=z;g=0;u=74;break a}break}else{o=0;f=aa(15,t|0,j|0,k|0)|0;h=o;o=0;if((h|0)!=0&(p|0)!=0){d=SN(c[h>>2]|0,w|0,x|0)|0;if(!d)Ua(h|0,p|0);z=p}else d=-1;if((d|0)==1){k=t;m=0;j=0;i=r;d=v;h=v;e=z;g=0;u=74;break a}if(f|0)break c;o=0;ha(59,t|0,j|0,k|0);f=o;o=0;if((f|0)!=0&(p|0)!=0){h=SN(c[f>>2]|0,w|0,x|0)|0;if(!h)Ua(f|0,p|0);z=p}else h=-1;if((h|0)==1){k=t;m=0;j=0;i=r;d=v;h=v;e=z;g=0;u=74;break a}break}}while(0);c[v+(i<<3)+4>>2]=e;o=0;h=_(25,e|0)|0;d=o;o=0;if((d|0)!=0&(p|0)!=0){f=SN(c[d>>2]|0,w|0,x|0)|0;if(!f)Ua(d|0,p|0);z=p}else f=-1;if((f|0)==1){k=t;m=0;j=0;i=r;d=v;h=v;e=z;g=0;u=74;break a}c[v+(i<<3)>>2]=h;i=i+1|0}while(0);o=0;e=$(34,b|0,e|0)|0;f=o;o=0;if((f|0)!=0&(p|0)!=0){h=SN(c[f>>2]|0,w|0,x|0)|0;if(!h)Ua(f|0,p|0);z=p}else h=-1;if((h|0)==1){k=t;m=0;j=0;i=r;d=v;h=v;e=z;g=0;u=74;break a}}o=0;g=$(35,b|0,g|0)|0;e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,w|0,x|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){k=t;m=0;j=0;i=r;d=v;h=v;e=z;g=0;u=74;break a}n=i}o=0;j=_(26,n<<3|0)|0;e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,w|0,x|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)!=1){o=0;ja(25,v|0,n|0,8,36);e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,w|0,x|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)!=1){g=c[m>>2]|0;o=0;fa(87,g+2|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,w|0,x|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)!=1){i=c[m+16>>2]|0;d=i+(g*40|0)|0;i=i+((g+1|0)*40|0)|0;q=c[13918]|0;h=0;while(1){if((h|0)>=(n|0))break;if((h|0)>0?c[42366]&16|0:0){o=0;ga(25,q|0,m|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,w|0,x|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){k=t;m=j;i=r;d=v;h=v;e=z;g=q;u=74;break a}}e=c[v+(h<<3)+4>>2]|0;k=c[e>>2]&3;g=c[(c[(c[((k|0)==3?e:e+48|0)+40>>2]|0)+16>>2]|0)+112>>2]|0;e=c[(c[(c[((k|0)==2?e:e+-48|0)+40>>2]|0)+16>>2]|0)+112>>2]|0;if((g|0)==(e|0)){o=0;ja(26,m|0,g|0,i|0,d|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,w|0,x|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){k=t;m=j;i=r;d=v;h=v;e=z;g=q;u=74;break a}}else{o=0;ha(60,m|0,e|0,i|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,w|0,x|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){k=t;m=j;i=r;d=v;h=v;e=z;g=q;u=74;break a}o=0;ha(60,m|0,g|0,d|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,w|0,x|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){k=t;m=j;i=r;d=v;h=v;e=z;g=q;u=74;break a}}o=0;e=aa(16,m|0,i|0,d|0)|0;f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,w|0,x|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)==1){k=t;m=j;i=r;d=v;h=v;e=z;g=q;u=74;break a}if(e|0){k=t;m=j;i=r;d=v;h=v;break a}e=j+(h<<3)|0;o=0;ja(27,s|0,m|0,d|0,i|0);f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,w|0,x|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)==1){k=t;m=j;i=r;d=v;h=v;e=z;g=q;u=74;break a}g=s;k=c[g+4>>2]|0;c[e>>2]=c[g>>2];c[e+4>>2]=k;o=0;fa(88,m|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,w|0,x|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){k=t;m=j;i=r;d=v;h=v;e=z;g=q;u=74;break a}h=h+1|0}o=0;ea(8);e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,w|0,x|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)!=1){o=0;e=_(27,r|0)|0;f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,w|0,x|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)!=1){c[r+20>>2]=e;o=0;e=_(28,r|0)|0;f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,w|0,x|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)!=1){c[r+24>>2]=e;o=0;ha(61,n|0,j|0,r|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,w|0,x|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)!=1){w=RN(169468,1,w|0,x|0)|0;x=z;o=0;e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,w|0,x|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)!=1){k=t;m=j;i=r;d=v;h=v;e=0;g=q;u=74}else{k=t;m=j;i=r;d=v;h=v;e=z;g=q;u=74}}else{k=t;m=j;i=r;d=v;h=v;e=z;g=q;u=74}}else{k=t;m=j;i=r;d=v;h=v;e=z;g=q;u=74}}else{k=t;m=j;i=r;d=v;h=v;e=z;g=q;u=74}}else{k=t;m=j;i=r;d=v;h=v;e=z;g=q;u=74}}else{k=t;m=j;i=r;d=v;h=v;e=z;g=0;u=74}}else{k=t;m=j;i=r;d=v;h=v;e=z;g=0;u=74}}else{k=t;m=0;i=r;d=v;h=v;e=z;g=0;u=74}}else{n=0;k=t;m=0;j=0;i=r;d=v;h=v;e=z;g=0;u=74}}else{n=0;k=t;m=0;j=0;i=r;d=v;h=v;e=z;g=0;u=74}}else{n=0;k=t;m=0;j=0;i=0;d=v;h=v;e=z;g=0;u=74}}else{n=0;k=0;m=0;j=0;i=0;d=0;h=v;e=z;g=0;u=74}}else{n=0;k=0;m=0;j=0;i=0;d=0;h=0;e=z;g=0;u=74}while(0);d:while(1){if((u|0)==74){u=0;if(e|0){q=g;continue}o=0;fa(89,i|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,w|0,x|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){A=g;f=h;q=d;r=i;s=j;t=m;v=k;u=n;e=z;g=A;h=f;d=q;i=r;j=s;m=t;k=v;n=u;u=74;continue}if(c[42366]&4|0){o=0;ka(7,g|0,i|0,n|0,m|0,d|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,w|0,x|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){f=g;q=h;r=d;s=i;t=j;v=m;A=k;u=n;e=z;g=f;h=q;d=r;i=s;j=t;m=v;k=A;n=u;u=74;continue}}o=0;la(10,b|0,i|0,n|0,m|0,d|0,0);e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,w|0,x|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){f=g;q=h;r=d;s=i;t=j;v=m;A=k;u=n;e=z;g=f;h=q;d=r;i=s;j=t;m=v;k=A;n=u;u=74;continue}q=g}if(!(a[174076]|0))e=0;else{o=0;fa(90,k|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,w|0,x|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){e=z;g=q;u=74;continue}e=0}while(1){if((e|0)>=(n|0))break;o=0;fa(91,c[m+(e<<3)+4>>2]|0);f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,w|0,x|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)==1){e=z;g=q;u=74;continue d}e=e+1|0}o=0;fa(91,j|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,w|0,x|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){e=z;g=q;u=74;continue}o=0;fa(92,i|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,w|0,x|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){e=z;g=q;u=74;continue}o=0;fa(91,h|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,w|0,x|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){e=z;g=q;u=74}else break}_I(w|0);l=y;return}function MB(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0.0;q=l;l=l+64|0;p=q+32|0;o=q+16|0;j=q;k=q+48|0;WL(95757,a)|0;WL(95768,a)|0;m=b+16|0;n=j+8|0;i=k+4|0;g=0;while(1){if((g|0)>=(c[b>>2]|0))break;d=c[m>>2]|0;e=c[d+(g*40|0)+20>>2]|0;f=c[d+(g*40|0)+24>>2]|0;if((e|0)==(f|0)){FC(j,e);d=~~+h[j>>3];e=~~+h[n>>3]}else{HC(k,(c[e>>2]&1|0)==0?e:f,d+(g*40|0)|0);d=c[k>>2]|0;e=c[i>>2]|0}c[o>>2]=g;c[o+4>>2]=d;c[o+8>>2]=e;zL(a,95788,o)|0;g=g+1|0}f=b+4|0;e=b+20|0;d=0;while(1){if((d|0)>=(c[f>>2]|0))break;o=c[e>>2]|0;b=c[o+(d*24|0)+16>>2]|0;r=+h[o+(d*24|0)>>3];c[p>>2]=c[o+(d*24|0)+12>>2];c[p+4>>2]=b;h[p+8>>3]=r;zL(a,95808,p)|0;d=d+1|0}WL(95830,a)|0;l=q;return}function NB(a){a=a|0;var b=0.0,d=0.0,e=0,f=0;f=c[a>>2]&3;e=c[(c[((f|0)==3?a:a+48|0)+40>>2]|0)+16>>2]|0;a=c[(c[((f|0)==2?a:a+-48|0)+40>>2]|0)+16>>2]|0;b=+h[e+16>>3]-+h[a+16>>3];d=+h[e+24>>3]-+h[a+24>>3];return ~~(d*d+b*b)|0}function OB(a,b){a=a|0;b=b|0;return (c[a>>2]|0)-(c[b>>2]|0)|0}function PB(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,m=0,n=0;n=l;l=l+32|0;j=n;FC(n+16|0,d);k=d+32|0;m=d+36|0;g=0;while(1){if((g|0)>=(c[k>>2]|0))break;h=c[(c[m>>2]|0)+(g<<2)>>2]|0;do if(!(a[h+36>>0]|0)){i=c[h+20>>2]|0;if((i|0)==(d|0)){DC(j,h,c[h+24>>2]|0);YC(b,f,h,0.0)|0;break}else{DC(j,h,i);YC(b,e,h,0.0)|0;break}}while(0);g=g+1|0}c[b>>2]=(c[b>>2]|0)+2;l=n;return}function QB(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0;k=l;l=l+32|0;h=k;FC(k+16|0,b);i=b+32|0;j=b+36|0;f=0;while(1){if((f|0)>=(c[i>>2]|0))break;g=c[(c[j>>2]|0)+(f<<2)>>2]|0;e=c[g+20>>2]|0;if((e|0)==(b|0))e=c[g+24>>2]|0;DC(h,g,e);YC(a,d,g,0.0)|0;f=f+1|0}c[a>>2]=(c[a>>2]|0)+1;c[d+24>>2]=b;c[d+20>>2]=b;l=k;return}function RB(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,i=0,j=0,k=0.0,m=0.0,n=0,o=0.0,p=0.0,q=0,r=0,s=0,t=0,u=0,v=0,w=0.0,x=0.0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;H=l;l=l+128|0;C=H+64|0;n=H+48|0;D=H+32|0;E=H+16|0;F=H;g=0;i=e;while(1){if(!i)break;g=g+1|0;i=c[i+8>>2]|0}B=vw((g*56|0)+-112|0)|0;c[C+52>>2]=0;c[C+48>>2]=0;A=e+8|0;e=c[A>>2]|0;i=c[e+8>>2]|0;g=c[e+20>>2]|0;if(c[g>>2]&1)g=c[e+24>>2]|0;DC(n,e,g);j=e;q=e;p=0.0;o=+h[n>>3];z=0;m=0.0;x=+h[n+8>>3];while(1){y=i+8|0;if(!(c[y>>2]|0))break;v=EC(j,i)|0;uG(d,v,c[q+12>>2]|0);t=q+36|0;u=i+36|0;if((a[t>>0]|0)==(a[u>>0]|0))if((c[y>>2]|0)==(f|0)){DC(E,i,v);e=E;G=12}else{j=q;e=z;k=x}else{FC(D,v);e=D;G=12}if((G|0)==12){G=0;w=+h[e>>3];k=+h[e+8>>3];e=a[t>>0]|0;s=e<<24>>24==0;r=(q|0)==(c[A>>2]|0);if(s){if(!(a[u>>0]|0))e=0;else e=(c[i+20>>2]|0)==(v|0)?4:2;n=v+48|0;q=g+48|0;j=g+40|0;g=r?0:p>o?4:2}else{if(e<<24>>24==(a[u>>0]|0))e=0;else e=(c[i+20>>2]|0)==(v|0)?1:3;n=v+40|0;q=g+40|0;j=g+48|0;g=r?0:m>x?1:3}GC(C,s&1,+h[j>>3],+h[q>>3],+h[n>>3],g,e);q=z+1|0;g=B+(z*56|0)|0;e=C;j=g+56|0;do{c[g>>2]=c[e>>2];g=g+4|0;e=e+4|0}while((g|0)<(j|0));if((a[t>>0]|0)!=(a[u>>0]|0)?(c[y>>2]|0)==(f|0):0){DC(F,i,v);n=(a[u>>0]|0)==0;e=v+40|0;g=v+48|0;p=+h[(n?g:e)>>3];GC(C,n&1,+h[(n?e:g)>>3],p,p,n?(o>w?4:2):x>k?1:3,0);n=z+2|0;g=B+(q*56|0)|0;e=C;j=g+56|0;do{c[g>>2]=c[e>>2];g=g+4|0;e=e+4|0}while((g|0)<(j|0));g=v;j=i;p=o;o=w;e=n;m=x}else{g=v;j=i;p=o;o=w;e=q;m=x}}v=i;i=c[y>>2]|0;q=j;z=e;x=k;j=v}i=aJ(B,z*56|0)|0;e=z+-1|0;g=0;while(1){if((g|0)>=(z|0))break;if((g|0)>0)c[i+(g*56|0)+48>>2]=i+((g+-1|0)*56|0);if((g|0)<(e|0)){G=g+1|0;c[i+(g*56|0)+52>>2]=i+(G*56|0);g=G;continue}else{g=g+1|0;continue}}c[b>>2]=z;c[b+4>>2]=i;l=H;return}function SB(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,i=0,j=0,k=0;j=Ql(24676,c[4345]|0)|0;k=a+8|0;i=0;while(1){if((i|0)>=(c[a>>2]|0))break;b=(c[k>>2]|0)+(i*72|0)|0;if(!(c[b>>2]&4)){while(1){d=c[(c[b+36>>2]|0)+8>>2]|0;if(!d)break;d=c[d+20>>2]|0;if(!d)break;if(!(c[d>>2]&1))b=d;else break}g=vw(40)|0;c[g+36>>2]=b;h[g+8>>3]=+h[b+40>>3];f=b;d=c[b>>2]|0;while(1){c[f>>2]=d|4;d=c[c[f+36>>2]>>2]|0;if(!d)break;e=c[d+24>>2]|0;if(!e)break;d=c[e>>2]|0;if(d&1|0)break;else f=e}h[g+16>>3]=+h[f+56>>3];yC(j,g,+h[b+48>>3])}i=i+1|0}return j|0}function TB(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,i=0,j=0,k=0;j=Ql(24676,c[4345]|0)|0;k=a+8|0;i=0;while(1){if((i|0)>=(c[a>>2]|0))break;b=(c[k>>2]|0)+(i*72|0)|0;if(!(c[b>>2]&2)){while(1){d=c[(c[b+36>>2]|0)+12>>2]|0;if(!d)break;d=c[d+20>>2]|0;if(!d)break;if(!(c[d>>2]&1))b=d;else break}g=vw(40)|0;c[g+36>>2]=b;h[g+8>>3]=+h[b+48>>3];f=b;d=c[b>>2]|0;while(1){c[f>>2]=d|2;d=c[(c[f+36>>2]|0)+4>>2]|0;if(!d)break;e=c[d+24>>2]|0;if(!e)break;d=c[e>>2]|0;if(d&1|0)break;else f=e}h[g+16>>3]=+h[f+64>>3];yC(j,g,+h[b+40>>3])}i=i+1|0}return j|0}function UB(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0;j=e+20|0;i=e+24|0;e=0;while(1){if((e|0)>=(b|0))break;g=c[d+(e<<3)>>2]|0;h=c[d+(e<<3)+4>>2]|0;f=0;while(1){if((f|0)>=(g|0))break;k=h+(f*56|0)|0;xC(bC(c[((a[k>>0]|0)==0?j:i)>>2]|0,k)|0,k);f=f+1|0}e=e+1|0}return}function VB(a){a=a|0;var b=0,d=0;d=a+20|0;dC(c[d>>2]|0);b=a+24|0;dC(c[b>>2]|0);eC(c[d>>2]|0);eC(c[b>>2]|0);fC(c[d>>2]|0,a);fC(c[b>>2]|0,a);gC(c[d>>2]|0);gC(c[b>>2]|0);return}function WB(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0.0,B=0.0,C=0.0,D=0,E=0.0;z=l;l=l+224|0;n=z+176|0;m=z+208|0;x=z+160|0;y=z+128|0;k=z+96|0;t=z+64|0;u=z;o=z+32|0;v=u+8|0;h[v>>3]=1797693134862315708145274.0e284;h[u>>3]=1797693134862315708145274.0e284;w=u+24|0;h[w>>3]=-1797693134862315708145274.0e284;p=u+16|0;h[p>>3]=-1797693134862315708145274.0e284;WL(95005,a)|0;c[n>>2]=10;c[n+4>>2]=10;zL(a,95411,n)|0;WL(123076,a)|0;i=b+4|0;j=b+12|0;q=t+8|0;r=t+16|0;s=t+24|0;g=0;while(1){if((g|0)>=(c[i>>2]|0))break;D=(c[j>>2]|0)+(g*72|0)+40|0;c[t>>2]=c[D>>2];c[t+4>>2]=c[D+4>>2];c[t+8>>2]=c[D+8>>2];c[t+12>>2]=c[D+12>>2];c[t+16>>2]=c[D+16>>2];c[t+20>>2]=c[D+20>>2];c[t+24>>2]=c[D+24>>2];c[t+28>>2]=c[D+28>>2];C=+h[q>>3];B=+h[r>>3];A=+h[s>>3];h[k>>3]=+h[t>>3];h[k+8>>3]=C;h[k+16>>3]=B;h[k+24>>3]=A;zL(a,123095,k)|0;g=g+1|0}g=0;while(1){if((g|0)>=(d|0))break;D=c[f+(g<<3)+4>>2]|0;k=e+(g<<3)|0;c[m>>2]=c[k>>2];c[m+4>>2]=c[k+4>>2];c[n>>2]=c[u>>2];c[n+4>>2]=c[u+4>>2];c[n+8>>2]=c[u+8>>2];c[n+12>>2]=c[u+12>>2];c[n+16>>2]=c[u+16>>2];c[n+20>>2]=c[u+20>>2];c[n+24>>2]=c[u+24>>2];c[n+28>>2]=c[u+28>>2];cC(o,a,D,m,b,n);c[u>>2]=c[o>>2];c[u+4>>2]=c[o+4>>2];c[u+8>>2]=c[o+8>>2];c[u+12>>2]=c[o+12>>2];c[u+16>>2]=c[o+16>>2];c[u+20>>2]=c[o+20>>2];c[u+24>>2]=c[o+24>>2];c[u+28>>2]=c[o+28>>2];g=g+1|0}WL(95428,a)|0;i=b+8|0;g=0;while(1){if((g|0)>=(c[b>>2]|0))break;D=(c[i>>2]|0)+(g*72|0)+40|0;c[t>>2]=c[D>>2];c[t+4>>2]=c[D+4>>2];c[t+8>>2]=c[D+8>>2];c[t+12>>2]=c[D+12>>2];c[t+16>>2]=c[D+16>>2];c[t+20>>2]=c[D+20>>2];c[t+24>>2]=c[D+24>>2];c[t+28>>2]=c[D+28>>2];E=+h[t>>3];A=+h[q>>3];B=+h[r>>3];C=+h[s>>3];h[y>>3]=E;h[y+8>>3]=A;h[y+16>>3]=B;h[y+24>>3]=C;zL(a,123132,y)|0;h[u>>3]=+h[(+h[u>>3]>3];h[v>>3]=+h[(+h[v>>3]>3];h[p>>3]=+h[(+h[p>>3]>B?u:t)+16>>3];h[w>>3]=+h[(+h[w>>3]>C?u:t)+24>>3];g=g+1|0}v=~~(+h[v>>3]+10.0);y=~~(+h[p>>3]+10.0);D=~~(+h[w>>3]+10.0);c[x>>2]=~~(+h[u>>3]+10.0);c[x+4>>2]=v;c[x+8>>2]=y;c[x+12>>2]=D;zL(a,95453,x)|0;l=z;return}function XB(b,d,e,f,g,i){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;i=i|0;var j=0.0,k=0.0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0;N=l;l=l+112|0;F=N+88|0;E=N+72|0;M=N+32|0;I=N+16|0;J=N;K=N+56|0;L=N+40|0;G=c[13918]|0;w=(i|0)==0;x=J+8|0;y=I+8|0;v=0;m=0;n=0;o=0;p=0;i=0;while(1){if((v|0)>=(e|0))break;z=c[g+(v<<3)+4>>2]|0;A=z+48|0;u=(c[(c[((c[z>>2]&3|0)==3?z:A)+40>>2]|0)+16>>2]|0)+16|0;B=z+16|0;C=(c[B>>2]|0)+16|0;c[E>>2]=c[u>>2];c[E+4>>2]=c[u+4>>2];c[E+8>>2]=c[u+8>>2];c[E+12>>2]=c[u+12>>2];c[F>>2]=c[C>>2];c[F+4>>2]=c[C+4>>2];c[F+8>>2]=c[C+8>>2];c[F+12>>2]=c[C+12>>2];YB(K,E,F);c[I>>2]=c[K>>2];c[I+4>>2]=c[K+4>>2];c[I+8>>2]=c[K+8>>2];c[I+12>>2]=c[K+12>>2];C=z+-48|0;u=(c[(c[((c[z>>2]&3|0)==2?z:C)+40>>2]|0)+16>>2]|0)+16|0;t=(c[B>>2]|0)+56|0;c[E>>2]=c[u>>2];c[E+4>>2]=c[u+4>>2];c[E+8>>2]=c[u+8>>2];c[E+12>>2]=c[u+12>>2];c[F>>2]=c[t>>2];c[F+4>>2]=c[t+4>>2];c[F+8>>2]=c[t+8>>2];c[F+12>>2]=c[t+12>>2];YB(L,E,F);c[J>>2]=c[L>>2];c[J+4>>2]=c[L+4>>2];c[J+8>>2]=c[L+8>>2];c[J+12>>2]=c[L+12>>2];t=c[f+(v<<3)>>2]|0;u=c[f+(v<<3)+4>>2]|0;s=t*3|0;D=s+1|0;if((s|0)>=(n|0)){if(m|0)_I(i);p=ww(D<<4)|0;m=p;n=D;o=p;i=p}if(!(a[u>>0]|0)){k=+(_B(u,d)|0);j=+h[I>>3]}else{j=+ZB(u,d);k=+h[y>>3]}r=m+16|0;h[m+16>>3]=j;h[m+24>>3]=k;c[p>>2]=c[r>>2];c[p+4>>2]=c[r+4>>2];c[p+8>>2]=c[r+8>>2];c[p+12>>2]=c[r+12>>2];r=1;q=u;s=2;while(1){if((r|0)>=(t|0))break;q=u+(r*56|0)|0;if(!(a[q>>0]|0))k=+(_B(q,d)|0);else j=+ZB(q,d);O=m+(s+2<<4)|0;Q=m+(s+1<<4)|0;P=m+(s<<4)|0;h[P>>3]=j;h[m+(s<<4)+8>>3]=k;c[Q>>2]=c[P>>2];c[Q+4>>2]=c[P+4>>2];c[Q+8>>2]=c[P+8>>2];c[Q+12>>2]=c[P+12>>2];c[O>>2]=c[P>>2];c[O+4>>2]=c[P+4>>2];c[O+8>>2]=c[P+8>>2];c[O+12>>2]=c[P+12>>2];r=r+1|0;s=s+3|0}if(!(a[q>>0]|0)){k=+(_B(q,d)|0);j=+h[J>>3]}else{j=+ZB(q,d);k=+h[x>>3]}Q=m+(s<<4)|0;O=s+1|0;P=m+(O<<4)|0;h[P>>3]=j;h[m+(O<<4)+8>>3]=k;c[Q>>2]=c[P>>2];c[Q+4>>2]=c[P+4>>2];c[Q+8>>2]=c[P+8>>2];c[Q+12>>2]=c[P+12>>2];if(0>1){P=Dn(c[((c[z>>2]&3|0)==3?z:A)+40>>2]|0)|0;Q=Dn(c[((c[z>>2]&3|0)==2?z:C)+40>>2]|0)|0;c[M>>2]=P;c[M+4>>2]=Q;zL(G,94964,M)|0}Jz(z,c[((c[z>>2]&3|0)==2?z:C)+40>>2]|0,m,D,24664);if((!w?(H=c[(c[B>>2]|0)+96>>2]|0,H|0):0)?(a[H+81>>0]|0)==0:0){c[E>>2]=c[I>>2];c[E+4>>2]=c[I+4>>2];c[E+8>>2]=c[I+8>>2];c[E+12>>2]=c[I+12>>2];c[F>>2]=c[J>>2];c[F+4>>2]=c[J+4>>2];c[F+8>>2]=c[J+8>>2];c[F+12>>2]=c[J+12>>2];cA(b,z,E,F)}v=v+1|0}_I(o);l=N;return}function YB(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;h[b>>3]=+h[b>>3]+ +h[d>>3];e=b+8|0;h[e>>3]=+h[e>>3]+ +h[d+8>>3];c[a>>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];c[a+12>>2]=c[b+12>>2];return}function ZB(a,b){a=a|0;b=b|0;var d=0.0,e=0;b=bC(c[b+24>>2]|0,a)|0;e=c[b+36>>2]|0;d=+h[e+40>>3];return +((+h[e+56>>3]-d)*(+(c[a+44>>2]|0)/+((c[b+24>>2]|0)+1|0))+d)}function _B(a,b){a=a|0;b=b|0;var d=0.0,e=0;e=bC(c[b+20>>2]|0,a)|0;b=c[e+36>>2]|0;d=+h[b+48>>3];return ~~((1.0-+(c[a+44>>2]|0)/+((c[e+24>>2]|0)+1|0))*(+h[b+64>>3]-d)+d)|0}function $B(a){a=a|0;return 0}function aC(a){a=a|0;return 0}function bC(a,b){a=a|0;b=b|0;a=bb[c[a>>2]&31](a,b+8|0,512)|0;if(!a)ma(94977,94983,423,94991);a=c[a+16>>2]|0;a=bb[c[a>>2]&31](a,b+16|0,512)|0;if(!a)ma(95002,94983,425,94991);else return a|0;return 0}function cC(b,d,e,f,g,i){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;i=i|0;var j=0,k=0.0,m=0,n=0,o=0,p=0.0,q=0.0,r=0.0,s=0.0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0.0,C=0.0,D=0.0;z=l;l=l+32|0;y=z+16|0;u=z+8|0;m=z;j=c[(c[(c[((c[e>>2]&3|0)==3?e:e+48|0)+40>>2]|0)+16>>2]|0)+112>>2]|0;t=c[f+4>>2]|0;if(!(a[t>>0]|0)){k=+h[j+56>>3];s=+h[j+40>>3];j=_B(t,g)|0;k=(s+k)*.5}else{k=+h[j+64>>3];s=+h[j+48>>3];j=~~((s+k)*.5);k=+ZB(t,g)}A=~~k;p=+h[i>>3];r=+(A|0);p=p>3]=p;v=i+8|0;q=+h[v>>3];s=+(j|0);q=q>3]=q;w=i+16|0;k=+h[w>>3];r=k>r?k:r;h[w>>3]=r;x=i+24|0;k=+h[x>>3];s=k>s?k:s;h[x>>3]=s;c[m>>2]=A;c[m+4>>2]=j;zL(d,95504,m)|0;o=c[f>>2]|0;m=t;n=1;f=A;while(1){if((n|0)>=(o|0))break;m=t+(n*56|0)|0;if(!(a[m>>0]|0))j=_B(m,g)|0;else f=~~+ZB(m,g);B=+(f|0);D=p>3]=D;k=+(j|0);C=q>3]=C;B=r>B?r:B;h[w>>3]=B;k=s>k?s:k;h[x>>3]=k;c[u>>2]=f;c[u+4>>2]=j;zL(d,95526,u)|0;n=n+1|0;p=D;q=C;r=B;s=k}j=c[(c[(c[((c[e>>2]&3|0)==2?e:e+-48|0)+40>>2]|0)+16>>2]|0)+112>>2]|0;if(!(a[m>>0]|0)){k=+h[j+56>>3];D=+h[j+40>>3];j=_B(m,g)|0;k=(D+k)*.5}else{k=+h[j+64>>3];D=+h[j+48>>3];j=~~((D+k)*.5);k=+ZB(m,g)}A=~~k;C=+(A|0);h[i>>3]=p>3]=q>3]=r>C?r:C;h[x>>3]=s>D?s:D;c[y>>2]=A;c[y+4>>2]=j;zL(d,95540,y)|0;c[b>>2]=c[i>>2];c[b+4>>2]=c[i+4>>2];c[b+8>>2]=c[i+8>>2];c[b+12>>2]=c[i+12>>2];c[b+16>>2]=c[i+16>>2];c[b+20>>2]=c[i+20>>2];c[b+24>>2]=c[i+24>>2];c[b+28>>2]=c[i+28>>2];l=z;return}function dC(a){a=a|0;var b=0;a=Ol(a)|0;while(1){if(!a)break;b=Ol(c[a+16>>2]|0)|0;while(1){if(!b)break;c[b+32>>2]=IC(c[b+24>>2]|0)|0;b=c[b>>2]|0}a=c[a>>2]|0}return}function eC(a){a=a|0;var b=0;a=Ol(a)|0;while(1){if(!a)break;b=Ol(c[a+16>>2]|0)|0;while(1){if(!b)break;if(c[b+24>>2]|0)wC(b);b=c[b>>2]|0}a=c[a>>2]|0}return}function fC(a,b){a=a|0;b=b|0;var d=0;d=Ol(a)|0;while(1){if(!d)break;a=Ol(c[d+16>>2]|0)|0;while(1){if(!a)break;kC(a,b);a=c[a>>2]|0}d=c[d>>2]|0}return}function gC(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,i=0;e=Ol(a)|0;while(1){if(!e)break;i=e+8|0;f=Ol(c[e+16>>2]|0)|0;while(1){if(!f)break;a=f+24|0;a:do if(c[a>>2]|0){if(c[42366]&8|0)hC(f,~~+h[i>>3]);g=f+32|0;NC(c[g>>2]|0);b=c[a>>2]|0;d=f+28|0;a=0;while(1){if((a|0)>=(b|0))break a;c[(c[(c[d>>2]|0)+(a<<2)>>2]|0)+44>>2]=(c[(c[(c[g>>2]|0)+4>>2]|0)+(a*12|0)+4>>2]|0)+1;a=a+1|0}}while(0);f=c[f>>2]|0}e=c[e>>2]|0}return}function hC(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0,k=0.0,m=0.0;j=l;l=l+32|0;d=j;g=a+24|0;a:do if((c[g>>2]|0)>=2){i=c[13918]|0;m=+h[a+8>>3];k=+h[a+16>>3];c[d>>2]=b;h[d+8>>3]=m;h[d+16>>3]=k;zL(i,95561,d)|0;f=a+32|0;a=a+28|0;b=0;while(1){if((b|0)>=(c[g>>2]|0))break a;e=c[(c[(c[f>>2]|0)+4>>2]|0)+(b*12|0)+8>>2]|0;b:do if(Sl(e)|0){iC(i,c[(c[a>>2]|0)+(b<<2)>>2]|0);WL(95581,i)|0;d=bb[c[e>>2]&31](e,0,128)|0;while(1){if(!d)break b;WL(95586,i)|0;iC(i,c[(c[a>>2]|0)+(c[d>>2]<<2)>>2]|0);WL(134901,i)|0;d=bb[c[e>>2]&31](e,d,8)|0}}while(0);b=b+1|0}}while(0);l=j;return}function iC(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,i=0,j=0.0,k=0.0,m=0.0;g=l;l=l+80|0;f=g+40|0;e=g;if(!(a[d>>0]|0)){m=+h[d+16>>3];j=+h[d+8>>3];k=+h[d+24>>3];i=jC(c[d+32>>2]|0)|0;e=jC(c[d+36>>2]|0)|0;h[f>>3]=m;h[f+8>>3]=j;h[f+16>>3]=k;h[f+24>>3]=j;c[f+32>>2]=i;c[f+36>>2]=e;zL(b,95592,f)|0}else{k=+h[d+8>>3];j=+h[d+16>>3];m=+h[d+24>>3];f=jC(c[d+32>>2]|0)|0;i=jC(c[d+36>>2]|0)|0;h[e>>3]=k;h[e+8>>3]=j;h[e+16>>3]=k;h[e+24>>3]=m;c[e+32>>2]=f;c[e+36>>2]=i;zL(b,95592,e)|0}l=g;return}function jC(a){a=a|0;switch(a|0){case 0:{a=95643;break}case 1:{a=95638;break}case 2:{a=95631;break}case 3:{a=95624;break}case 4:{a=95616;break}default:a=0}return a|0}function kC(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;w=l;l=l+16|0;r=w+8|0;t=w;u=c[a+32>>2]|0;v=c[a+28>>2]|0;p=a+24|0;m=r+4|0;n=t+4|0;j=0;a=c[p>>2]|0;a:while(1){q=j+1|0;if((q|0)>=(a|0))break;o=v+(j<<2)|0;k=q;while(1){if((k|0)>=(a|0)){j=q;continue a}b:do if(((MC(u,j,k)|0)==0?(MC(u,k,j)|0)==0:0)?(s=v+(k<<2)|0,lC(c[o>>2]|0,c[s>>2]|0)|0):0){f=c[o>>2]|0;a=c[f+48>>2]|0;i=c[s>>2]|0;d=c[i+48>>2]|0;e=(d|0)==0;if(a)if(e)a=1;else a=+h[a+8>>3]!=+h[d+8>>3];else a=e^1;g=a&1;mC(r,f,i,0,g);a=c[r>>2]|0;i=c[m>>2]|0;f=g^1;mC(t,c[o>>2]|0,c[s>>2]|0,1,f);d=c[t>>2]|0;e=c[n>>2]|0;switch(i|0){case -1:{nC(c[s>>2]|0,c[o>>2]|0,g,0,a,b);nC(c[s>>2]|0,c[o>>2]|0,f,1,d,b);if((e|0)!=1)break b;oC(c[o>>2]|0,c[s>>2]|0,f,b);break b}case 0:switch(e|0){case -1:{nC(c[s>>2]|0,c[o>>2]|0,g,0,a,b);nC(c[s>>2]|0,c[o>>2]|0,f,1,d,b);break b}case 0:{nC(c[o>>2]|0,c[s>>2]|0,0,g,a,b);nC(c[o>>2]|0,c[s>>2]|0,1,f,d,b);break b}case 1:{nC(c[o>>2]|0,c[s>>2]|0,0,g,a,b);nC(c[o>>2]|0,c[s>>2]|0,1,f,d,b);break b}default:break b}case 1:{nC(c[o>>2]|0,c[s>>2]|0,0,g,a,b);nC(c[o>>2]|0,c[s>>2]|0,1,f,d,b);if((e|0)!=-1)break b;oC(c[o>>2]|0,c[s>>2]|0,f,b);break b}default:break b}}while(0);k=k+1|0;a=c[p>>2]|0}}l=w;return}function lC(a,b){a=a|0;b=b|0;if(!(+h[a+8>>3]==+h[b+8>>3]))ma(95714,94983,843,95745);if((+h[a+16>>3]==+h[b+16>>3]?+h[a+24>>3]==+h[b+24>>3]:0)?(c[a+32>>2]|0)==(c[b+32>>2]|0):0)a=(c[a+36>>2]|0)==(c[b+36>>2]|0)&1;else a=0;return a|0}function mC(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0;g=0;while(1){b=pC(b,e)|0;if(!b){h=0;break}d=pC(d,f)|0;if(!d){i=6;break}if(!(lC(b,d)|0)){i=7;break}g=g+1|0}if((i|0)==6)ma(123205,94983,871,95663);else if((i|0)==7)h=rC(b,qC(b,d)|0,g+1|0,1-e|0)|0;c[a>>2]=g;c[a+4>>2]=h;return}function nC(b,d,e,f,g,i){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0;o=i+20|0;n=i+24|0;i=bC(c[((a[b>>0]|0)==0?o:n)>>2]|0,b)|0;KC(c[i+32>>2]|0,c[b+40>>2]|0,c[d+40>>2]|0);k=1;while(1){if((k|0)>(g|0))break;l=pC(b,e)|0;m=pC(d,f)|0;do if(!(a[b>>0]|0)){j=bC(c[n>>2]|0,l)|0;if(+h[l+8>>3]==+h[b+16>>3]){p=(c[b+32>>2]|0)==1;i=(MC(c[i+32>>2]|0,c[b+40>>2]|0,c[d+40>>2]|0)|0)!=0;b=c[j+32>>2]|0;if(p)if(i){KC(b,c[m+40>>2]|0,c[l+40>>2]|0);i=j;break}else{KC(b,c[l+40>>2]|0,c[m+40>>2]|0);i=j;break}else if(i){KC(b,c[l+40>>2]|0,c[m+40>>2]|0);i=j;break}else{KC(b,c[m+40>>2]|0,c[l+40>>2]|0);i=j;break}}else{p=(c[b+36>>2]|0)==1;i=(MC(c[i+32>>2]|0,c[b+40>>2]|0,c[d+40>>2]|0)|0)!=0;b=c[j+32>>2]|0;if(p)if(i){KC(b,c[l+40>>2]|0,c[m+40>>2]|0);i=j;break}else{KC(b,c[m+40>>2]|0,c[l+40>>2]|0);i=j;break}else if(i){KC(b,c[m+40>>2]|0,c[l+40>>2]|0);i=j;break}else{KC(b,c[l+40>>2]|0,c[m+40>>2]|0);i=j;break}}}else{j=bC(c[o>>2]|0,l)|0;if(+h[l+8>>3]==+h[b+16>>3]){p=(c[b+32>>2]|0)==2;i=(MC(c[i+32>>2]|0,c[b+40>>2]|0,c[d+40>>2]|0)|0)!=0;b=c[j+32>>2]|0;if(p)if(i){KC(b,c[l+40>>2]|0,c[m+40>>2]|0);i=j;break}else{KC(b,c[m+40>>2]|0,c[l+40>>2]|0);i=j;break}else if(i){KC(b,c[m+40>>2]|0,c[l+40>>2]|0);i=j;break}else{KC(b,c[l+40>>2]|0,c[m+40>>2]|0);i=j;break}}else{p=(c[b+36>>2]|0)==2;i=(MC(c[i+32>>2]|0,c[b+40>>2]|0,c[d+40>>2]|0)|0)!=0;b=c[j+32>>2]|0;if(p)if(i){KC(b,c[m+40>>2]|0,c[l+40>>2]|0);i=j;break}else{KC(b,c[l+40>>2]|0,c[m+40>>2]|0);i=j;break}else if(i){KC(b,c[l+40>>2]|0,c[m+40>>2]|0);i=j;break}else{KC(b,c[m+40>>2]|0,c[l+40>>2]|0);i=j;break}}}while(0);b=l;d=m;k=k+1|0}return}function oC(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0;while(1){if(!(lC(b,d)|0))break;g=pC(b,1)|0;d=pC(d,e)|0;b=g}g=c[(bC(c[((a[b>>0]|0)==0?f+20|0:f+24|0)>>2]|0,b)|0)+32>>2]|0;LC(g,c[b+40>>2]|0,c[d+40>>2]|0);return}function pC(a,b){a=a|0;b=b|0;if(!a)ma(95650,94983,798,95654);else return c[((b|0)==0?a+48|0:a+52|0)>>2]|0;return 0}function qC(b,c){b=b|0;c=c|0;var d=0,e=0,f=0;f=l;l=l+16|0;e=f;d=a[b>>0]|0;if(d<<24>>24==(a[c>>0]|0)?!(+h[b+8>>3]!=+h[c+8>>3]):0){if(!(d<<24>>24))b=sC(b,c,3,1)|0;else b=sC(b,c,4,2)|0;l=f;return b|0}_l(1,95676,e)|0;Ua(169468,1);return 0}function rC(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,i=0,j=0;j=1;while(1){if((j|0)>(e|0))break;i=pC(b,f)|0;g=+h[i+8>>3]==+h[b+16>>3];do if(!(a[b>>0]|0))if(g){g=(c[b+32>>2]|0)==1;break}else{g=(c[b+36>>2]|0)==3;break}else if(g){g=(c[b+32>>2]|0)==4;break}else{g=(c[b+36>>2]|0)==2;break}while(0);b=i;j=j+1|0;d=g?0-d|0:d}return d|0}function sC(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0.0,i=0.0,j=0.0,k=0.0,l=0,m=0,n=0,o=0;j=+h[a+24>>3];k=+h[b+16>>3];do if(!(j>3],i=+h[b+24>>3],!(g>i)):0){if(k>2]|0;return ((d|0)==(c[b+32>>2]|0)?0:(d|0)==(e|0)?1:-1)|0}else{d=c[a+32>>2]|0;b=(d|0)==(c[b+36>>2]|0)?0:(d|0)==(e|0)?1:-1;break}if(!(j==i))if(j>2]|0)==(d|0);d=vC(c[b+32>>2]|0,c[a+32>>2]|0,d,e)|0;return (o?d:0-d|0)|0}else{o=(c[b+36>>2]|0)==(e|0);b=vC(c[a+32>>2]|0,c[b+32>>2]|0,d,e)|0;b=o?b:0-b|0;break}o=c[a+32>>2]|0;n=c[b+32>>2]|0;if((o|0)==(n|0)){b=c[b+36>>2]|0;if((c[a+36>>2]|0)==(b|0)){b=0;break}}else b=c[b+36>>2]|0;m=(n|0)==(d|0);if((n|0)==(b|0)){if(m){b=1;break}if((n|0)==(e|0)){b=-1;break}if((o|0)!=(d|0)?(c[a+36>>2]|0)!=(d|0):0){b=1;break}if((o|0)!=(e|0)?(c[a+36>>2]|0)!=(e|0):0){b=-1;break}b=0;break}f=(b|0)==(e|0);if(m&f){b=(c[a+36>>2]|0)==(e|0);if((o|0)==(d|0)){if(!b){b=-1;break}}else if(b){b=1;break}b=0;break}l=(b|0)==(d|0);if((n|0)==(e|0)&l){b=(o|0)==(e|0);if((c[a+36>>2]|0)==(d|0)){if(!b){b=-1;break}}else if(b){b=1;break}b=0;break}if(!n){if(l){b=uC(o,c[a+36>>2]|0,d)|0;break}if(f){b=0-(uC(o,c[a+36>>2]|0,e)|0)|0;break}}f=c[a+36>>2]|0;if(m&(b|0)==0){b=uC(f,o,d)|0;break}else{b=0-(uC(f,o,e)|0)|0;break}}else b=0;while(0);return b|0}function tC(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0.0,j=0.0;i=+h[a+24>>3];j=+h[b+24>>3];do if(i>2]|0;if((a|0)==(d|0)?(c[b+32>>2]|0)==(e|0):0){a=-1;break}if((a|0)==(e|0)?(c[b+32>>2]|0)==(d|0):0){a=1;break}a=0}else{f=c[b+32>>2]|0;g=(f|0)==(e|0);if(i==j)if(g){a=vC(c[a+36>>2]|0,c[b+36>>2]|0,d,e)|0;break}else{a=0-(vC(c[b+36>>2]|0,c[a+36>>2]|0,d,e)|0)|0;break}if(g?(c[b+36>>2]|0)==(e|0):0){a=-1;break}if((f|0)==(d|0)?(c[b+36>>2]|0)==(d|0):0){a=1;break}a=0}while(0);return a|0}function uC(a,b,c){a=a|0;b=b|0;c=c|0;return ((a|0)==(c|0)?((b|0)==(c|0))<<31>>31:1)|0}function vC(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;if((a|0)==(d|0)){b=(a|0)==0;if(b)return 0;else b=b&1}return ((a|0)!=0|(b|0)!=(c|0))<<31>>31|0}function wC(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0;g=c[a+28>>2]|0;h=c[a+24>>2]|0;d=c[a+32>>2]|0;a=0;a:while(1){e=a+1|0;if((e|0)>=(h|0))break;f=g+(a<<2)|0;b=e;while(1){if((b|0)==(h|0)){a=e;continue a}switch(qC(c[f>>2]|0,c[g+(b<<2)>>2]|0)|0){case 1:{KC(d,a,b);break}case -1:{KC(d,b,a);break}default:{}}b=b+1|0}}return}function xC(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;f=a+24|0;e=c[f>>2]|0;d=e+1|0;c[f>>2]=d;c[b+40>>2]=e;e=a+28|0;a=c[e>>2]|0;if(!a)a=ww(d<<2)|0;else a=yw(a,d<<2)|0;c[e>>2]=a;c[a+((c[f>>2]|0)+-1<<2)>>2]=b;return}function yC(a,b,d){a=a|0;b=b|0;d=+d;var e=0,f=0,g=0;g=l;l=l+16|0;f=g;h[f>>3]=d;e=bb[c[a>>2]&31](a,f,512)|0;if(!e){e=vw(24)|0;h[e+8>>3]=+h[f>>3];c[e+16>>2]=Ql(24712,c[4345]|0)|0;bb[c[a>>2]&31](a,e,1)|0}f=c[e+16>>2]|0;bb[c[f>>2]&31](f,b,1)|0;l=g;return}function zC(a,b,d){a=a|0;b=b|0;d=d|0;JC(c[b+32>>2]|0);_I(c[b+28>>2]|0);_I(b);return}function AC(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0.0,f=0.0;e=+h[b>>3];f=+h[c>>3];if(!(e>f))if(e>3]>=+h[c+8>>3])<<31>>31;else a=0;else a=!(+h[b+8>>3]<=+h[c+8>>3])&1;return a|0}function BC(a,b,d){a=a|0;b=b|0;d=d|0;Kl(c[b+16>>2]|0)|0;_I(b);return}function CC(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0.0,f=0.0;f=+h[b>>3];e=+h[c>>3];return (f>e?1:(f>31)|0}function DC(b,d,e){b=b|0;d=d|0;e=e|0;var f=0.0,g=0.0,i=0,j=0;i=(a[d+36>>0]|0)!=0;j=e+40|0;do if((c[d+24>>2]|0)==(e|0)){f=+h[j>>3];if(i){g=(+h[e+64>>3]+ +h[e+48>>3])*.5;break}else{g=+h[e+48>>3];f=(+h[e+56>>3]+f)*.5;break}}else if(i){g=(+h[e+64>>3]+ +h[e+48>>3])*.5;f=+h[e+56>>3];break}else{g=+h[e+64>>3];f=(+h[e+56>>3]+ +h[j>>3])*.5;break}while(0);h[b>>3]=f;h[b+8>>3]=g;return}function EC(a,b){a=a|0;b=b|0;var d=0;d=c[a+20>>2]|0;if((d|0)!=(c[b+20>>2]|0)?(d|0)!=(c[b+24>>2]|0):0)d=c[a+24>>2]|0;return d|0}function FC(a,b){a=a|0;b=b|0;var c=0.0;c=(+h[b+64>>3]+ +h[b+48>>3])*.5;h[a>>3]=(+h[b+56>>3]+ +h[b+40>>3])*.5;h[a+8>>3]=c;return}function GC(b,d,e,f,g,i,j){b=b|0;d=d|0;e=+e;f=+f;g=+g;i=i|0;j=j|0;var k=0,l=0;a[b>>0]=d;h[b+8>>3]=e;if(f>3]=f;h[b+16>>3]=e;c[b+36>>2]=d;c[b+32>>2]=l;a[b+1>>0]=k;return}function HC(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=c[b+36>>2]|0;do if((c[e+4>>2]|0)!=(d|0)){if((c[e+12>>2]|0)==(d|0)){e=~~((+h[b+56>>3]+ +h[b+40>>3])*.5);d=~~+h[b+48>>3];break}if((c[e+8>>2]|0)==(d|0)){e=~~+h[b+40>>3];d=~~((+h[b+64>>3]+ +h[b+48>>3])*.5);break}if((c[e>>2]|0)==(d|0)){e=~~+h[b+56>>3];d=~~((+h[b+64>>3]+ +h[b+48>>3])*.5)}else{e=0;d=0}}else{e=~~((+h[b+56>>3]+ +h[b+40>>3])*.5);d=~~+h[b+64>>3]}while(0);c[a>>2]=e;c[a+4>>2]=d;return}function IC(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;d=vw(8)|0;c[d>>2]=a;e=d+4|0;c[e>>2]=vw(a*12|0)|0;b=0;while(1){if((b|0)>=(a|0))break;g=fG()|0;f=c[e>>2]|0;c[f+(b*12|0)+8>>2]=g;c[f+(b*12|0)>>2]=0;b=b+1|0}return d|0}function JC(a){a=a|0;var b=0,d=0,e=0;d=a+4|0;b=0;while(1){e=c[d>>2]|0;if((b|0)>=(c[a>>2]|0))break;Kl(c[e+(b*12|0)+8>>2]|0)|0;b=b+1|0}_I(e);_I(a);return}function KC(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=l;l=l+16|0;f=e;c[f>>2]=d;d=c[(c[a+4>>2]|0)+(b*12|0)+8>>2]|0;bb[c[d>>2]&31](d,f,1)|0;l=e;return}function LC(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;e=l;l=l+16|0;f=e;c[f>>2]=d;a=a+4|0;g=c[(c[a>>2]|0)+(b*12|0)+8>>2]|0;bb[c[g>>2]&31](g,f,2)|0;c[f>>2]=b;d=c[(c[a>>2]|0)+(d*12|0)+8>>2]|0;bb[c[d>>2]&31](d,f,2)|0;l=e;return}function MC(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=l;l=l+16|0;f=e;c[f>>2]=d;d=c[(c[a+4>>2]|0)+(b*12|0)+8>>2]|0;d=(bb[c[d>>2]&31](d,f,512)|0)!=0&1;l=e;return d|0}function NC(a){a=a|0;var b=0,d=0,e=0,f=0;b=c[a>>2]|0;switch(b|0){case 0:break;case 1:{c[(c[a+4>>2]|0)+4>>2]=0;break}default:{e=OC(b)|0;f=a+4|0;d=0;b=0;while(1){if((d|0)>=(c[a>>2]|0)){b=0;break}if(!(c[(c[f>>2]|0)+(d*12|0)>>2]|0))b=PC(a,d,b,e)|0;d=d+1|0}while(1){d=QC(e)|0;if((d|0)<=-1)break;c[(c[f>>2]|0)+(d*12|0)+4>>2]=b;b=b+1|0}RC(e)}}return}function OC(a){a=a|0;var b=0;b=vw(8)|0;c[b+4>>2]=vw(a<<2)|0;c[b>>2]=-1;return b|0}function PC(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;i=a+4|0;g=c[i>>2]|0;j=g+(b*12|0)|0;c[j>>2]=1;g=c[g+(b*12|0)+8>>2]|0;h=g+4|0;d=d+1|0;g=Ol(g)|0;while(1){if(!g)break;f=c[(c[h>>2]|0)+8>>2]|0;if((f|0)<0)f=c[g+8>>2]|0;else f=g+(0-f)|0;f=c[f>>2]|0;if(!(c[(c[i>>2]|0)+(f*12|0)>>2]|0))d=PC(a,f,d,e)|0;g=c[g>>2]|0}c[j>>2]=2;SC(e,b);return d+1|0}function QC(a){a=a|0;var b=0,d=0;b=c[a>>2]|0;if((b|0)==-1)a=-1;else{d=c[(c[a+4>>2]|0)+(b<<2)>>2]|0;c[a>>2]=b+-1;a=d}return a|0}function RC(a){a=a|0;_I(c[a+4>>2]|0);_I(a);return}function SC(a,b){a=a|0;b=b|0;var d=0;d=(c[a>>2]|0)+1|0;c[a>>2]=d;c[(c[a+4>>2]|0)+(d<<2)>>2]=b;return}function TC(a){a=a|0;var d=0,e=0,f=0;e=c[a>>2]|0;c[a+8>>2]=e;c[a+12>>2]=c[a+4>>2];d=a+16|0;a=0;while(1){if((a|0)>=(e|0))break;f=c[d>>2]|0;b[f+(a*40|0)+18>>1]=b[f+(a*40|0)+16>>1]|0;a=a+1|0}return}function UC(a){a=a|0;var d=0,e=0,f=0;d=c[a+8>>2]|0;c[a>>2]=d;c[a+4>>2]=c[a+12>>2];e=a+16|0;a=0;while(1){if((a|0)>=(d|0))break;f=c[e>>2]|0;b[f+(a*40|0)+16>>1]=b[f+(a*40|0)+18>>1]|0;a=a+1|0}d=d+2|0;while(1){if((a|0)>=(d|0))break;b[(c[e>>2]|0)+(a*40|0)+16>>1]=0;a=a+1|0}return}function VC(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=vw(((c[a>>2]|0)*6|0)+(b<<1)<<2)|0;c[a+20>>2]=vw((((c[a>>2]|0)*3|0)+b|0)*24|0)|0;e=c[a>>2]|0;f=a+16|0;a=0;while(1){if((a|0)>=(e|0))break;c[(c[f>>2]|0)+(a*40|0)+28>>2]=d;d=d+24|0;a=a+1|0}e=e+2|0;while(1){if((a|0)>=(e|0))break;c[(c[f>>2]|0)+(a*40|0)+28>>2]=d;d=d+(b<<2)|0;a=a+1|0}return}function WC(a){a=a|0;var b=0;b=vw(24)|0;c[b>>2]=0;c[b+16>>2]=vw(a*40|0)|0;return b|0}function XC(a){a=a|0;var b=0,d=0;d=c[a+16>>2]|0;b=c[a>>2]|0;c[d+(b*40|0)+32>>2]=b;c[a>>2]=b+1;return d+(b*40|0)|0}function YC(a,b,d,e){a=a|0;b=b|0;d=d|0;e=+e;var f=0,g=0;g=a+4|0;f=c[g>>2]|0;c[g>>2]=f+1;g=c[a+20>>2]|0;a=g+(f*24|0)|0;c[g+(f*24|0)+12>>2]=c[b+32>>2];c[g+(f*24|0)+16>>2]=c[d+32>>2];h[a>>3]=e;c[g+(f*24|0)+8>>2]=0;ZC(b,f);ZC(d,f);return a|0}function ZC(a,d){a=a|0;d=d|0;var e=0,f=0;e=a+16|0;f=b[e>>1]|0;c[(c[a+28>>2]|0)+(f<<16>>16<<2)>>2]=d;b[e>>1]=f+1<<16>>16;return}function _C(a){a=a|0;var b=0;b=a+16|0;_I(c[(c[b>>2]|0)+28>>2]|0);_I(c[b>>2]|0);_I(c[a+20>>2]|0);_I(a);return}function $C(a,d,e){a=a|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0;g=c[a>>2]|0;i=a+16|0;f=0;while(1){if((f|0)>=(g|0))break;c[(c[i>>2]|0)+(f*40|0)>>2]=-2147483648;f=f+1|0}nG();a:do if(!(qG(d)|0)){c[d+8>>2]=0;c[d>>2]=0;d=a+20|0;b:while(1){g=sG()|0;if(!g){f=0;break a}c[g>>2]=0-(c[g>>2]|0);if((g|0)==(e|0)){f=0;break a}i=g+16|0;j=g+28|0;f=0;while(1){if((f|0)>=(b[i>>1]|0))continue b;k=(c[d>>2]|0)+((c[(c[j>>2]|0)+(f<<2)>>2]|0)*24|0)|0;l=aD(a,k,g)|0;m=c[l>>2]|0;do if((m|0)<0){n=~~-(+h[k>>3]+ +(c[g>>2]|0));if((m|0)==-2147483648){c[l>>2]=n;if(qG(l)|0){f=1;break a}c[l+8>>2]=g;c[l+12>>2]=k;break}else{if((m|0)>=(n|0))break;tG(l,n);c[l+8>>2]=g;c[l+12>>2]=k;break}}while(0);f=f+1|0}}}else f=1;while(0);return f|0}function aD(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=c[b+12>>2]|0;if((e|0)==(c[d+32>>2]|0))e=c[b+16>>2]|0;return (c[a+16>>2]|0)+(e*40|0)|0}function bD(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;g=c[a>>2]|0;Jr(g,3,b)|0;b=c[g+92>>2]|0;do if(b){d=c[b+16>>2]|0;h=c[d+12>>2]|0;c[a+76>>2]=h;e=c[d+16>>2]|0;c[a+84>>2]=e;f=a+80|0;c[f>>2]=c[d>>2];c[a+88>>2]=c[b+4>>2];d=a+152|0;e=c[d>>2]|c[e>>2];c[d>>2]=e;b=c[g+80>>2]|0;if(!b){c[a+60>>2]=0;b=999;break}else{g=c[b+16>>2]|0;c[a+60>>2]=c[g+12>>2];i=c[g+16>>2]|0;c[a+68>>2]=i;c[a+72>>2]=c[b+4>>2];c[d>>2]=e|c[i>>2];c[a+64>>2]=c[((h|0)==0?f:g)>>2];b=300;break}}else b=999;while(0);return b|0}function cD(a){a=a|0;var b=0,d=0;b=c[a+60>>2]|0;if(!(ir(a)|0))if((b|0)!=0?(d=c[b>>2]|0,(d|0)!=0):0){gb[d&127](a);a=0}else a=0;else a=1;return a|0}function dD(a){a=a|0;var b=0,d=0;b=c[a+60>>2]|0;if(b|0?(d=c[b+4>>2]|0,d|0):0)gb[d&127](a);c[(c[a>>2]|0)+24>>2]=0;qr(a);return}function eD(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0,g=0.0,i=0.0;e=+h[b+504>>3];f=+h[b+512>>3];i=+h[b+352>>3];if(!(c[b+360>>2]|0)){g=+h[d>>3]+e;d=d+8|0;e=f}else g=-(f+ +h[d+8>>3]);f=+h[b+528>>3]*i*(+h[d>>3]+e);h[a>>3]=+h[b+520>>3]*i*g;h[a+8>>3]=f;return}function fD(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,g=0.0,i=0.0,j=0.0,k=0.0;f=+h[a+504>>3];g=+h[a+512>>3];i=+h[a+352>>3];j=+h[a+520>>3]*i;i=+h[a+528>>3]*i;a:do if(!(c[a+360>>2]|0)){a=0;while(1){if((a|0)>=(e|0))break a;h[d+(a<<4)>>3]=(+h[b+(a<<4)>>3]+f)*j;h[d+(a<<4)+8>>3]=(+h[b+(a<<4)+8>>3]+g)*i;a=a+1|0}}else{a=0;while(1){if((a|0)>=(e|0))break a;k=-(j*(+h[b+(a<<4)+8>>3]+g));h[d+(a<<4)+8>>3]=(+h[b+(a<<4)>>3]+f)*i;h[d+(a<<4)>>3]=k;a=a+1|0}}while(0);return d|0}function gD(a,b){a=a|0;b=b|0;var d=0;b=c[a+60>>2]|0;if(b|0?(d=c[b+8>>2]|0,d|0):0)gb[d&127](a);return}function hD(a){a=a|0;var b=0,d=0;b=c[a+60>>2]|0;if(b|0?(d=c[b+12>>2]|0,d|0):0)gb[d&127](a);pr(a);return}function iD(a){a=a|0;var b=0,d=0;b=c[a+60>>2]|0;if(b|0?(d=c[b+24>>2]|0,d|0):0)gb[d&127](a);return}function jD(a){a=a|0;var b=0,d=0;b=c[a+60>>2]|0;if(b|0?(d=c[b+28>>2]|0,d|0):0)gb[d&127](a);return}function kD(a){a=a|0;var b=0,d=0;b=c[a+60>>2]|0;if(b|0?(d=c[b+16>>2]|0,d|0):0){b=c[a+160>>2]|0;kb[d&31](a,c[(c[(c[a>>2]|0)+308>>2]|0)+(b<<2)>>2]|0,b,c[a+156>>2]|0)}return}function lD(a){a=a|0;var b=0,d=0;b=c[a+60>>2]|0;if(b|0?(d=c[b+20>>2]|0,d|0):0)gb[d&127](a);return}function mD(a,b){a=a|0;b=b|0;var d=0;b=c[a+60>>2]|0;if(b|0?(d=c[b+32>>2]|0,d|0):0)gb[d&127](a);return}function nD(a,b){a=a|0;b=b|0;var d=0;b=c[a+60>>2]|0;if(b|0?(d=c[b+36>>2]|0,d|0):0)gb[d&127](a);return}function oD(a){a=a|0;var b=0,d=0;b=c[a+60>>2]|0;if(b|0?(d=c[b+40>>2]|0,d|0):0)gb[d&127](a);return}function pD(a){a=a|0;var b=0,d=0;b=c[a+60>>2]|0;if(b|0?(d=c[b+44>>2]|0,d|0):0)gb[d&127](a);return}function qD(a){a=a|0;var b=0,d=0;b=c[a+60>>2]|0;if(b|0?(d=c[b+48>>2]|0,d|0):0)gb[d&127](a);return}function rD(a){a=a|0;var b=0,d=0;b=c[a+60>>2]|0;if(b|0?(d=c[b+52>>2]|0,d|0):0)gb[d&127](a);return}function sD(a,b){a=a|0;b=b|0;var d=0;b=c[a+60>>2]|0;if(b|0?(d=c[b+56>>2]|0,d|0):0)gb[d&127](a);return}function tD(a){a=a|0;var b=0,d=0;b=c[a+60>>2]|0;if(b|0?(d=c[b+60>>2]|0,d|0):0)gb[d&127](a);return}function uD(a,b){a=a|0;b=b|0;var d=0;b=c[a+60>>2]|0;if(b|0?(d=c[b+64>>2]|0,d|0):0)gb[d&127](a);return}function vD(a){a=a|0;var b=0,d=0;b=c[a+60>>2]|0;if(b|0?(d=c[b+68>>2]|0,d|0):0)gb[d&127](a);return}function wD(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0;g=c[a+60>>2]|0;if(g|0?(h=c[g+72>>2]|0,h|0):0)lb[h&7](a,b,d,e,f);return}function xD(a){a=a|0;var b=0,d=0;b=c[a+60>>2]|0;if(b|0?(d=c[b+76>>2]|0,d|0):0)gb[d&127](a);return}function yD(a,b){a=a|0;b=b|0;var d=0,e=0;d=c[a+60>>2]|0;if(d|0?(e=c[d+80>>2]|0,e|0):0)hb[e&31](a,b);return}function zD(a){a=a|0;var b=0,d=0;b=c[a+60>>2]|0;if(b|0?(d=c[b+84>>2]|0,d|0):0)gb[d&127](a);return}function AD(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0;k=l;l=l+48|0;f=k+32|0;h=k;i=k+16|0;j=c[b+60>>2]|0;m=c[e>>2]|0;do if(m|0?a[m>>0]|0:0){m=c[b+16>>2]|0;if(m|0?(c[m+144>>2]|0)==0:0)break;if(!(c[b+152>>2]&8192)){c[f>>2]=c[d>>2];c[f+4>>2]=c[d+4>>2];c[f+8>>2]=c[d+8>>2];c[f+12>>2]=c[d+12>>2];eD(i,b,f);c[h>>2]=c[i>>2];c[h+4>>2]=c[i+4>>2];c[h+8>>2]=c[i+8>>2];c[h+12>>2]=c[i+12>>2]}else{c[h>>2]=c[d>>2];c[h+4>>2]=c[d+4>>2];c[h+8>>2]=c[d+8>>2];c[h+12>>2]=c[d+12>>2]}if(j|0?(g=c[j+88>>2]|0,g|0):0){c[f>>2]=c[h>>2];c[f+4>>2]=c[h+4>>2];c[f+8>>2]=c[h+8>>2];c[f+12>>2]=c[h+12>>2];ib[g&127](b,f,e)}}while(0);l=k;return}function BD(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;f=c[b+60>>2]|0;g=(c[b+16>>2]|0)+16|0;i=WJ(d,58)|0;h=(i|0)!=0;if(h)a[i>>0]=0;if(f|0?(CD(c[b+68>>2]|0,d,g),e=c[f+92>>2]|0,e|0):0)hb[e&31](b,g);if(h)a[i>>0]=58;return}function CD(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0;k=l;l=l+32|0;g=k+16|0;j=k+8|0;i=k;c[d>>2]=b;c[d+32>>2]=5;e=RE(b)|0;f=c[a+16>>2]|0;if(!((f|0)!=0?(vM(e,f,c[a+20>>2]|0,4,37)|0)!=0:0))h=3;a:do if((h|0)==3){switch(SE(b,d,c[a+24>>2]|0)|0){case 0:break a;case 1:break;default:{_l(1,95868,g)|0;break a}}a=ww((rJ(b)|0)+16|0)|0;c[i>>2]=b;pL(a,95833,i)|0;if(Dv(a)|0){c[j>>2]=b;_l(0,95842,j)|0}_I(a)}while(0);l=k;return}function DD(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;f=c[b+60>>2]|0;g=(c[b+16>>2]|0)+56|0;i=WJ(d,58)|0;h=(i|0)!=0;if(h)a[i>>0]=0;if(f|0?(CD(c[b+68>>2]|0,d,g),e=c[f+92>>2]|0,e|0):0)hb[e&31](b,g);if(h)a[i>>0]=58;return}function ED(a,b,d,e){a=a|0;b=b|0;d=d|0;e=+e;var f=0,h=0,i=0,j=0;h=c[a+60>>2]|0;i=a+16|0;j=(c[i>>2]|0)+96|0;if(h|0?(CD(c[a+68>>2]|0,b,j),f=c[h+92>>2]|0,f|0):0)hb[f&31](a,j);j=c[i>>2]|0;c[j+136>>2]=d;g[j+140>>2]=e;return}function FD(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,i=0,j=0,k=0,m=0;m=l;l=l+16|0;k=m;j=c[b+60>>2]|0;b=c[b+16>>2]|0;c[b+160>>2]=d;a:do if((d|0)!=0&(j|0)!=0){j=b+144|0;i=b+152|0;g=b+148|0;b=d;b:while(1){f=b+4|0;b=c[b>>2]|0;if(!b)break a;c:do switch(a[b>>0]|0){case 115:{if(!(xJ(b,95889)|0)){c[j>>2]=3;b=f;continue b}if(!(xJ(b,95910)|0)){e=115;while(1){d=b+1|0;if(!(e<<24>>24))break;b=d;e=a[d>>0]|0}h[i>>3]=+sM(d);b=f;continue b}break}case 100:{if(!(xJ(b,122119)|0)){c[j>>2]=1;b=f;continue b}if(!(xJ(b,122112)|0)){c[j>>2]=2;b=f;continue b}break}case 105:{if(xJ(b,119127)|0?xJ(b,95895)|0:0)break c;c[j>>2]=0;b=f;continue b}case 98:{if(!(xJ(b,95905)|0)){h[i>>3]=2.0;b=f;continue b}break}case 102:{if(!(xJ(b,95923)|0)){c[g>>2]=1;b=f;continue b}break}case 117:{if(!(xJ(b,95930)|0)){c[g>>2]=0;b=f;continue b}break}case 116:{if(!(xJ(b,95939)|0)){b=f;continue b}break}default:{}}while(0);c[k>>2]=b;_l(0,95947,k)|0;b=f}}while(0);l=m;return}function GD(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0;j=l;l=l+32|0;g=j;d=c[a+60>>2]|0;if((d|0?(i=d+96|0,f=c[i>>2]|0,f|0):0)?c[(c[a+16>>2]|0)+144>>2]|0:0){d=b+16|0;h[g>>3]=(+h[d>>3]+ +h[b>>3])*.5;h[g+8>>3]=(+h[b+24>>3]+ +h[b+8>>3])*.5;b=g+16|0;c[b>>2]=c[d>>2];c[b+4>>2]=c[d+4>>2];c[b+8>>2]=c[d+8>>2];c[b+12>>2]=c[d+12>>2];if(!(c[a+152>>2]&8192)){fD(a,g,g,2)|0;f=c[i>>2]|0}ib[f&127](a,g,e)}l=j;return}function HD(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0;o=l;l=l+48|0;m=o;f=c[a+60>>2]|0;if((f|0?(n=f+100|0,c[n>>2]|0):0)?(k=a+16|0,j=c[k>>2]|0,c[j+144>>2]|0):0){if(!(e&4)){f=e;g=0}else{f=e&-5;e=j+16|0;g=m;h=e;i=g+40|0;do{c[g>>2]=c[h>>2];g=g+4|0;h=h+4|0}while((g|0)<(i|0));g=e;h=j+56|0;i=g+40|0;do{c[g>>2]=c[h>>2];g=g+4|0;h=h+4|0}while((g|0)<(i|0));g=1}if(!(c[a+152>>2]&8192)){e=d+10|0;if((c[42406]|0)<(d|0)){c[42406]=e;e=yw(c[42407]|0,e<<4)|0;c[42407]=e}else e=c[42407]|0;fD(a,b,e,d)|0;kb[c[n>>2]&31](a,e,d,f)}else kb[c[n>>2]&31](a,b,d,f);if(g|0){g=(c[k>>2]|0)+16|0;h=m;i=g+40|0;do{c[g>>2]=c[h>>2];g=g+4|0;h=h+4|0}while((g|0)<(i|0))}}l=o;return}function ID(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;e=l;l=l+64|0;f=e;c[f>>2]=c[b>>2];c[f+4>>2]=c[b+4>>2];c[f+8>>2]=c[b+8>>2];c[f+12>>2]=c[b+12>>2];g=f+32|0;b=b+16|0;c[g>>2]=c[b>>2];c[g+4>>2]=c[b+4>>2];c[g+8>>2]=c[b+8>>2];c[g+12>>2]=c[b+12>>2];h[f+16>>3]=+h[f>>3];h[f+24>>3]=+h[f+40>>3];h[f+48>>3]=+h[g>>3];h[f+56>>3]=+h[f+8>>3];HD(a,f,4,d);l=e;return}function JD(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0;i=c[a+60>>2]|0;do if((i|0?(j=i+104|0,h=c[j>>2]|0,h|0):0)?c[(c[a+16>>2]|0)+144>>2]|0:0){if(c[a+152>>2]&8192|0){mb[h&15](a,b,d,e,f,g&255);break}h=d+10|0;if((c[42406]|0)<(d|0)){c[42406]=h;h=yw(c[42407]|0,h<<4)|0;c[42407]=h}else h=c[42407]|0;fD(a,b,h,d)|0;mb[c[j>>2]&15](a,h,d,e,f,g&255)}while(0);return}function KD(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;e=c[a+60>>2]|0;do if((e|0?(g=e+108|0,f=c[g>>2]|0,f|0):0)?c[(c[a+16>>2]|0)+144>>2]|0:0){if(c[a+152>>2]&8192|0){ib[f&127](a,b,d);break}e=d+10|0;if((c[42406]|0)<(d|0)){c[42406]=e;e=yw(c[42407]|0,e<<4)|0;c[42407]=e}else e=c[42407]|0;fD(a,b,e,d)|0;ib[c[g>>2]&127](a,e,d)}while(0);return}function LD(b,d){b=b|0;d=d|0;var e=0,f=0;e=c[b+60>>2]|0;if((d|0?!((e|0)==0|(a[d>>0]|0)==0):0)?(f=c[e+112>>2]|0,f|0):0)hb[f&31](b,d);return}function MD(b,d,e,f,g,i){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;i=i|0;var j=0.0,k=0.0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0,t=0.0,u=0.0,v=0.0,w=0.0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;F=l;l=l+112|0;B=F+64|0;E=F;n=F+96|0;x=F+48|0;y=F+32|0;C=c[b+60>>2]|0;if(!b)ma(96061,96e3,691,96011);if(!d)ma(96030,96e3,692,96011);if(!(a[d>>0]|0))ma(96035,96e3,693,96011);D=Lr(d)|0;if(!D){if((C|0)!=0&(Py(d)|0)!=0?(m=c[C+116>>2]|0,m|0):0)lb[m&7](b,d,e,f,g&255)}else{s=b+432|0;c[B>>2]=c[s>>2];c[B+4>>2]=c[s+4>>2];c[B+8>>2]=c[s+8>>2];c[B+12>>2]=c[s+12>>2];Or(n,D,B);s=c[n>>2]|0;m=c[n+4>>2]|0;if(!((s|0)<1&(m|0)<1)){n=E+16|0;c[n>>2]=c[e>>2];c[n+4>>2]=c[e+4>>2];c[n+8>>2]=c[e+8>>2];c[n+12>>2]=c[e+12>>2];c[E>>2]=c[e>>2];c[E+4>>2]=c[e+4>>2];c[E+8>>2]=c[e+8>>2];c[E+12>>2]=c[e+12>>2];z=E+8|0;A=E+24|0;d=1;while(1){if((d|0)>=(f|0))break;G=e+(d<<4)|0;v=+h[G>>3];h[E>>3]=+h[(+h[E>>3]>3];w=+h[e+(d<<4)+8>>3];h[z>>3]=+h[(+h[z>>3]>3];h[n>>3]=+h[(+h[n>>3]>v?n:G)>>3];h[A>>3]=+h[(+h[A>>3]>w?n:G)+8>>3];d=d+1|0}k=+h[n>>3];j=+h[E>>3];t=k-j;u=+h[A>>3];v=+h[z>>3];w=u-v;o=+(m|0);p=+(s|0);q=t/p;r=w/o;a:do switch(ND(i)|0){case 1:if(q>3]=j;k=k-t;h[n>>3]=k}if(o>3]=v+w;h[A>>3]=u-w}if(!(c[b+152>>2]&8192)){c[B>>2]=c[E>>2];c[B+4>>2]=c[E+4>>2];c[B+8>>2]=c[E+8>>2];c[B+12>>2]=c[E+12>>2];eD(x,b,B);c[E>>2]=c[x>>2];c[E+4>>2]=c[x+4>>2];c[E+8>>2]=c[x+8>>2];c[E+12>>2]=c[x+12>>2];c[B>>2]=c[n>>2];c[B+4>>2]=c[n+4>>2];c[B+8>>2]=c[n+8>>2];c[B+12>>2]=c[n+12>>2];eD(y,b,B);c[n>>2]=c[y>>2];c[n+4>>2]=c[y+4>>2];c[n+8>>2]=c[y+8>>2];c[n+12>>2]=c[y+12>>2];k=+h[n>>3];j=+h[E>>3]}if(j>k){h[E>>3]=k;h[n>>3]=j}j=+h[z>>3];k=+h[A>>3];if(j>k){h[z>>3]=k;h[A>>3]=j}if(C|0){G=c[b+72>>2]|0;c[B>>2]=c[E>>2];c[B+4>>2]=c[E+4>>2];c[B+8>>2]=c[E+8>>2];c[B+12>>2]=c[E+12>>2];c[B+16>>2]=c[E+16>>2];c[B+20>>2]=c[E+20>>2];c[B+24>>2]=c[E+24>>2];c[B+28>>2]=c[E+28>>2];PD(b,D,B,g,G)}}}l=F;return}function ND(b){b=b|0;if(a[b>>0]|0)if(iK(b,96043)|0)if(iK(b,96049)|0)if(!(iK(b,96056)|0))b=4;else b=(IA(b)|0)<<24>>24!=0&1;else b=3;else b=2;else b=0;return b|0}function OD(a,b){a=a|0;b=+b;if(c[a+60>>2]|0)h[(c[a+16>>2]|0)+152>>3]=b;return}function PD(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,m=0,n=0;n=l;l=l+176|0;k=n+8|0;j=n;h=n+40|0;if(!b)ma(96061,96065,52,96079);if(!d)ma(96091,96065,53,96079);i=c[d+8>>2]|0;if(!i)ma(96094,96065,54,96079);if(!(a[i>>0]|0))ma(96103,96065,55,96079);xK(h,c[d+28>>2]|0)|0;i=h+(rJ(h)|0)|0;a[i>>0]=58;a[i+1>>0]=0;IL(h,g)|0;if((QD(b,h)|0)==999){c[j>>2]=h;_l(0,96115,j)|0}g=c[b+92>>2]|0;if(g|0?(m=c[g>>2]|0,m|0):0){c[k>>2]=c[e>>2];c[k+4>>2]=c[e+4>>2];c[k+8>>2]=c[e+8>>2];c[k+12>>2]=c[e+12>>2];c[k+16>>2]=c[e+16>>2];c[k+20>>2]=c[e+20>>2];c[k+24>>2]=c[e+24>>2];c[k+28>>2]=c[e+28>>2];kb[m&31](b,d,k,f)}l=n;return}function QD(a,b){a=a|0;b=b|0;b=Jr(c[a>>2]|0,4,b)|0;if(!b)b=999;else{b=c[b+16>>2]|0;c[a+92>>2]=c[b+12>>2];c[a+96>>2]=c[b>>2];b=300}return b|0}function RD(a){a=a|0;return 1}function SD(b){b=b|0;var c=0;a[b+536>>0]=0;c=b+336|0;h[c>>3]=+h[c>>3]+10.0/+h[b+352>>3];a[b+537>>0]=1;return 0}function TD(b){b=b|0;var c=0;a[b+536>>0]=0;c=b+336|0;h[c>>3]=+h[c>>3]-10.0/+h[b+352>>3];a[b+537>>0]=1;return 0}function UD(b){b=b|0;var c=0;a[b+536>>0]=0;c=b+344|0;h[c>>3]=+h[c>>3]-10.0/+h[b+352>>3];a[b+537>>0]=1;return 0}function VD(b){b=b|0;var c=0;a[b+536>>0]=0;c=b+344|0;h[c>>3]=+h[c>>3]+10.0/+h[b+352>>3];a[b+537>>0]=1;return 0}function WD(b){b=b|0;var c=0;a[b+536>>0]=0;c=b+352|0;h[c>>3]=+h[c>>3]*1.1;a[b+537>>0]=1;return 0}function XD(b){b=b|0;var c=0;a[b+536>>0]=0;c=b+352|0;h[c>>3]=+h[c>>3]*.9090909090909091;a[b+537>>0]=1;return 0}function YD(b){b=b|0;var d=0,e=0,f=0,g=0.0,i=0.0;e=b+536|0;d=(a[e>>0]|0)==0;a[e>>0]=d&1;if(d){d=c[b+448>>2]|0;e=c[b+452>>2]|0;i=+(d>>>0);g=+(e>>>0);f=i/+(d|0)>3]=(f?i:g)/+((f?d:e)|0);e=b+336|0;c[e>>2]=0;c[e+4>>2]=0;c[e+8>>2]=0;c[e+12>>2]=0;a[b+537>>0]=1}return 0}function ZD(b){b=b|0;var d=0,e=0;d=c[(c[b>>2]|0)+168>>2]|0;e=b+580|0;if(!(c[e>>2]|0)){c[e>>2]=d;e=(c[d+16>>2]|0)+112|0;a[e>>0]=a[e>>0]|2;nE(b,d)}gu(b,d);a[b+540>>0]=1;return}function _D(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0.0,i=0.0,j=0,k=0;k=l;l=l+16|0;f=k;switch(d|0){case 1:{c[f>>2]=c[e>>2];c[f+4>>2]=c[e+4>>2];c[f+8>>2]=c[e+8>>2];c[f+12>>2]=c[e+12>>2];gE(b,f);mE(b);a[b+538>>0]=1;a[b+541>>0]=1;j=13;break}case 2:{a[b+538>>0]=1;a[b+541>>0]=2;j=13;break}case 3:{c[f>>2]=c[e>>2];c[f+4>>2]=c[e+4>>2];c[f+8>>2]=c[e+8>>2];c[f+12>>2]=c[e+12>>2];gE(b,f);a[b+538>>0]=1;a[b+541>>0]=3;j=13;break}case 4:{a[b+536>>0]=0;if(!(c[b+360>>2]|0)){f=b+352|0;i=+h[f>>3];d=b+336|0;h[d>>3]=(+h[e>>3]-+((c[b+448>>2]|0)>>>0)*.5)*.10000000000000009/(+h[b+520>>3]*i)+ +h[d>>3];g=+h[e+8>>3]-+((c[b+452>>2]|0)>>>0)*.5;d=b+528|0}else{f=b+352|0;i=+h[f>>3];d=b+336|0;h[d>>3]=+h[d>>3]-(+h[e+8>>3]-+((c[b+452>>2]|0)>>>0)*.5)*.10000000000000009/(+h[b+528>>3]*i);g=+h[e>>3]-+((c[b+448>>2]|0)>>>0)*.5;d=b+520|0}j=b+344|0;h[j>>3]=g*.10000000000000009/(+h[d>>3]*i)+ +h[j>>3];h[f>>3]=i*1.1;j=13;break}case 5:{a[b+536>>0]=0;j=b+352|0;i=+h[j>>3]*.9090909090909091;h[j>>3]=i;if(!(c[b+360>>2]|0)){f=b+336|0;h[f>>3]=+h[f>>3]-(+h[e>>3]-+((c[b+448>>2]|0)>>>0)*.5)*.10000000000000009/(+h[b+520>>3]*i);g=+h[e+8>>3]-+((c[b+452>>2]|0)>>>0)*.5;f=b+528|0}else{f=b+336|0;h[f>>3]=(+h[e+8>>3]-+((c[b+452>>2]|0)>>>0)*.5)*.10000000000000009/(+h[b+528>>3]*i)+ +h[f>>3];g=+h[e>>3]-+((c[b+448>>2]|0)>>>0)*.5;f=b+520|0}j=b+344|0;h[j>>3]=+h[j>>3]-g*.10000000000000009/(+h[f>>3]*i);j=13;break}default:{}}if((j|0)==13)a[b+537>>0]=1;b=b+560|0;c[b>>2]=c[e>>2];c[b+4>>2]=c[e+4>>2];c[b+8>>2]=c[e+8>>2];c[b+12>>2]=c[e+12>>2];l=k;return}function $D(b,c,d){b=b|0;c=c|0;d=d|0;a[b+538>>0]=0;a[b+541>>0]=0;return}function aE(b,d){b=b|0;d=d|0;var e=0,f=0.0,g=0.0,i=0,j=0.0,k=0;k=l;l=l+16|0;e=k;i=b+560|0;j=(+h[d>>3]-+h[i>>3])/+h[b+520>>3];g=(+h[d+8>>3]-+h[b+568>>3])/+h[b+528>>3];if(!(+B(+j)<.0001&+B(+g)<.0001)){switch(a[b+541>>0]|0){case 0:{c[e>>2]=c[d>>2];c[e+4>>2]=c[d+4>>2];c[e+8>>2]=c[d+8>>2];c[e+12>>2]=c[d+12>>2];gE(b,e);break}case 2:{f=+h[b+352>>3];if(!(c[b+360>>2]|0)){e=b+336|0;h[e>>3]=+h[e>>3]-j/f;e=b+344|0;h[e>>3]=+h[e>>3]-g/f}else{e=b+336|0;h[e>>3]=+h[e>>3]-g/f;e=b+344|0;h[e>>3]=+h[e>>3]+j/f}a[b+537>>0]=1;break}default:{}}c[i>>2]=c[d>>2];c[i+4>>2]=c[d+4>>2];c[i+8>>2]=c[d+8>>2];c[i+12>>2]=c[d+12>>2]}l=k;return}function bE(a,b,c){a=a|0;b=b|0;c=c|0;return}function cE(a){a=a|0;return}function dE(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;j=c[b>>2]|0;if(d){d=aM(d,123632)|0;if(d|0){i=er(d,0)|0;LL(d)|0;f=5}}else{i=er(c[13853]|0,0)|0;f=5}if((f|0)==5?i|0:0){g=j+168|0;d=c[g>>2]|0;if(d|0){f=c[j+172>>2]|0;if((f|0)!=0?(h=c[f+4>>2]|0,(h|0)!=0):0){gb[h&127](d);d=c[g>>2]|0}iw(d);ln(c[g>>2]|0)|0}So(i,0,122277,280,1);So(i,1,122241,304,1);So(i,2,122254,176,1);c[g>>2]=i;c[(c[i+16>>2]|0)+144>>2]=j;if((ls(j,i,e)|0)!=-1){c[b+580>>2]=0;c[b+576>>2]=0;a[b+537>>0]=1}}return}function eE(a,b){a=a|0;b=b|0;a=c[a>>2]|0;ls(a,c[a+168>>2]|0,b)|0;return}function fE(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;g=c[a>>2]|0;f=g+160|0;e=c[f>>2]|0;if((e|0)!=0?(c[g+164>>2]|0)==0:0){i=g+192|0;h=c[i>>2]|0;c[f>>2]=0;c[i>>2]=0;f=h}else{f=0;e=0}ns(g,c[g+168>>2]|0,b,d)|0;if(e|0){i=c[a>>2]|0;c[i+160>>2]=e;c[i+192>>2]=f}return}function gE(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,i=0.0,j=0.0,k=0.0,m=0;f=l;l=l+80|0;e=f+48|0;g=f;m=f+32|0;c[e>>2]=c[d>>2];c[e+4>>2]=c[d+4>>2];c[e+8>>2]=c[d+8>>2];c[e+12>>2]=c[d+12>>2];hE(m,b,e);k=+h[m>>3];j=+h[m+8>>3];i=1.0/+h[b+352>>3];h[g+16>>3]=i+k;h[g+24>>3]=i+j;h[g>>3]=k-i;h[g+8>>3]=j-i;d=c[(c[b>>2]|0)+168>>2]|0;c[e>>2]=c[g>>2];c[e+4>>2]=c[g+4>>2];c[e+8>>2]=c[g+8>>2];c[e+12>>2]=c[g+12>>2];c[e+16>>2]=c[g+16>>2];c[e+20>>2]=c[g+20>>2];c[e+24>>2]=c[g+24>>2];c[e+28>>2]=c[g+28>>2];d=iE(d,e)|0;e=b+576|0;if((d|0)!=(c[e>>2]|0)){jE(b);c[e>>2]=d;kE(b);a[b+537>>0]=1}l=f;return}function hE(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0,g=0.0,i=0;if(!(c[b+360>>2]|0)){e=+h[b+352>>3];f=+h[d+8>>3];g=e;i=b+528|0;e=+h[d>>3]/(+h[b+520>>3]*e)-+h[b+504>>3]}else{e=+h[b+352>>3];f=-+h[d>>3];g=e;i=b+520|0;e=+h[d+8>>3]/(+h[b+528>>3]*e)-+h[b+504>>3]}g=f/(+h[i>>3]*g)-+h[b+512>>3];h[a>>3]=e;h[a+8>>3]=g;return}function iE(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;g=l;l=l+32|0;f=g;e=co(a)|0;a:while(1){if(!e){e=9;break}d=Pm(a,e)|0;while(1){if(!d)break;c[f>>2]=c[b>>2];c[f+4>>2]=c[b+4>>2];c[f+8>>2]=c[b+8>>2];c[f+12>>2]=c[b+12>>2];c[f+16>>2]=c[b+16>>2];c[f+20>>2]=c[b+20>>2];c[f+24>>2]=c[b+24>>2];c[f+28>>2]=c[b+28>>2];if((DB(d,f)|0)<<24>>24){e=6;break a}d=Rm(a,d)|0}e=eo(a,e)|0}do if((e|0)!=6)if((e|0)==9){d=fo(a)|0;while(1){if(!d)break;c[f>>2]=c[b>>2];c[f+4>>2]=c[b+4>>2];c[f+8>>2]=c[b+8>>2];c[f+12>>2]=c[b+12>>2];c[f+16>>2]=c[b+16>>2];c[f+20>>2]=c[b+20>>2];c[f+24>>2]=c[b+24>>2];c[f+28>>2]=c[b+28>>2];if((AB(d,f)|0)<<24>>24){e=12;break}d=go(a,d)|0}if((e|0)==12)break;c[f>>2]=c[b>>2];c[f+4>>2]=c[b+4>>2];c[f+8>>2]=c[b+8>>2];c[f+12>>2]=c[b+12>>2];c[f+16>>2]=c[b+16>>2];c[f+20>>2]=c[b+20>>2];c[f+24>>2]=c[b+24>>2];c[f+28>>2]=c[b+28>>2];d=lE(a,f)|0;if(!d){d=a;break}else break}while(0);l=g;return d|0}function jE(b){b=b|0;var d=0;d=c[b+576>>2]|0;a:do if(d|0)switch(Co(d)|0){case 0:{d=(c[d+16>>2]|0)+112|0;a[d>>0]=a[d>>0]&-2;break a}case 1:{d=(c[d+16>>2]|0)+117|0;a[d>>0]=a[d>>0]&-2;break a}case 2:{d=(c[d+16>>2]|0)+115|0;a[d>>0]=a[d>>0]&-2;break a}default:break a}while(0);c[b+584>>2]=0;return}function kE(b){b=b|0;var d=0,e=0;e=b+584|0;d=c[e>>2]|0;if(d|0){_I(d);c[e>>2]=0}d=c[b+576>>2]|0;a:do if(d|0)switch(Co(d)|0){case 0:{b=(c[d+16>>2]|0)+112|0;a[b>>0]=a[b>>0]|1;b=ym(d,0,96229,0)|0;if(!b)break a;c[e>>2]=qw(Jm(d,b)|0,d)|0;break a}case 1:{b=(c[d+16>>2]|0)+117|0;a[b>>0]=a[b>>0]|1;b=ym(ro(d)|0,1,96229,0)|0;if(!b)break a;c[e>>2]=qw(Jm(d,b)|0,d)|0;break a}case 2:{b=(c[d+16>>2]|0)+115|0;a[b>>0]=a[b>>0]|1;b=ym(ro(c[((c[d>>2]&3|0)==2?d:d+-48|0)+40>>2]|0)|0,2,96229,0)|0;if(!b)break a;c[e>>2]=qw(Jm(d,b)|0,d)|0;break a}default:break a}while(0);return}function lE(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0,k=0,m=0,n=0.0,o=0.0;m=l;l=l+32|0;e=m;g=c[a+16>>2]|0;i=c[g+180>>2]|0;j=g+184|0;d=1;while(1){if((d|0)>(i|0)){k=4;break}f=c[(c[j>>2]|0)+(d<<2)>>2]|0;c[e>>2]=c[b>>2];c[e+4>>2]=c[b+4>>2];c[e+8>>2]=c[b+8>>2];c[e+12>>2]=c[b+12>>2];c[e+16>>2]=c[b+16>>2];c[e+20>>2]=c[b+20>>2];c[e+24>>2]=c[b+24>>2];c[e+28>>2]=c[b+28>>2];f=lE(f,e)|0;if(!f)d=d+1|0;else{a=f;break}}do if((k|0)==4){o=+h[g+24>>3];n=+h[g+40>>3];if(((+h[b+16>>3]>=+h[g+16>>3]?+h[g+32>>3]>=+h[b>>3]:0)?+h[b+24>>3]>=o:0)?n>=+h[b+8>>3]:0)break;a=0}while(0);l=m;return a|0}function mE(b){b=b|0;var d=0,e=0,f=0;f=b+580|0;d=c[f>>2]|0;a:do if(d|0)switch(Co(d)|0){case 0:{e=(c[d+16>>2]|0)+112|0;a[e>>0]=a[e>>0]&-7|4;break a}case 1:{e=(c[d+16>>2]|0)+117|0;a[e>>0]=a[e>>0]&-7|4;break a}case 2:{e=(c[d+16>>2]|0)+115|0;a[e>>0]=a[e>>0]&-7|4;break a}default:break a}while(0);d=b+588|0;e=c[d>>2]|0;if(e|0){_I(e);c[d>>2]=0}d=c[b+576>>2]|0;c[f>>2]=d;b:do if(d|0)switch(Co(d)|0){case 0:{f=(c[d+16>>2]|0)+112|0;a[f>>0]=a[f>>0]|2;nE(b,d);break b}case 1:{f=(c[d+16>>2]|0)+117|0;a[f>>0]=a[f>>0]|2;oE(b,d);break b}case 2:{f=(c[d+16>>2]|0)+115|0;a[f>>0]=a[f>>0]|2;pE(b,d);break b}default:break b}while(0);return}function nE(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;d=a+592|0;do if((so(b)|0)==(b|0))if(!(qn(b)|0)){Er(d,0,96286);break}else{Er(d,0,96278);break}else Er(d,0,96292);while(0);Er(d,1,Dn(b)|0);c[a+596>>2]=2;f=a+604|0;d=0;e=2;while(1){d=Dm(b,0,d)|0;if(!d)break;Er(f,e,c[d+8>>2]|0);Er(f,e+1|0,Jm(b,d)|0);Er(f,e+2|0,0);e=e+3|0}c[a+608>>2]=e;d=ym(b,0,96264,0)|0;if(!d){d=ym(b,0,96269,0)|0;if(d|0)g=11}else g=11;if((g|0)==11)c[a+588>>2]=qw(Jm(b,d)|0,b)|0;return}function oE(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;f=a+592|0;Er(f,0,96273);Er(f,1,Dn(b)|0);c[a+596>>2]=2;f=a+604|0;g=so(ro(b)|0)|0;e=2;d=0;while(1){d=Dm(g,1,d)|0;if(!d)break;Er(f,e,c[d+8>>2]|0);Er(f,e|1,Jm(b,d)|0);e=e+2|0}c[a+608>>2]=e;d=ym(ro(b)|0,1,96264,0)|0;if(!d){d=ym(ro(b)|0,1,96269,0)|0;if(d|0)h=6}else h=6;if((h|0)==6)c[a+588>>2]=qw(Jm(b,d)|0,b)|0;return}function pE(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;h=a+592|0;Er(h,0,96237);k=b+48|0;Er(h,1,Dn(c[((c[b>>2]&3|0)==3?b:k)+40>>2]|0)|0);k=(qn(ro(c[((c[b>>2]&3|0)==3?b:k)+40>>2]|0)|0)|0)!=0;Er(h,3,k?122546:122549);k=b+-48|0;Er(h,4,Dn(c[((c[b>>2]&3|0)==2?b:k)+40>>2]|0)|0);c[a+596>>2]=7;i=a+604|0;j=so(ro(c[((c[b>>2]&3|0)==2?b:k)+40>>2]|0)|0)|0;g=7;d=0;a:while(1){while(1){d=Dm(j,2,d)|0;if(!d)break a;e=d+8|0;f=c[e>>2]|0;if(!(xJ(f,96242)|0)){l=5;break}if(!(xJ(f,96251)|0)){l=7;break}if(xJ(f,96260)|0)break;Er(h,6,Jm(b,d)|0)}if((l|0)==5){l=0;Er(h,2,Jm(b,d)|0)}else if((l|0)==7){l=0;Er(h,5,Jm(b,d)|0)}Er(i,g,c[e>>2]|0);Er(i,g+1|0,Jm(b,d)|0);g=g+2|0}c[a+608>>2]=g;d=ym(ro(c[((c[b>>2]&3|0)==2?b:k)+40>>2]|0)|0,2,96264,0)|0;if(!d){d=ym(ro(c[((c[b>>2]&3|0)==2?b:k)+40>>2]|0)|0,2,96269,0)|0;if(d|0)l=13}else l=13;if((l|0)==13)c[a+588>>2]=qw(Jm(b,d)|0,b)|0;return}function qE(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;g=rE(a,b,c[d>>2]|0)|0;d=c[d+4>>2]|0;while(1){f=c[d+4>>2]|0;if(!f)break;b=0;while(1){e=c[f+(b*20|0)+4>>2]|0;if(!e)break;Hr(a,c[d>>2]|0,e,c[f+(b*20|0)+8>>2]|0,g,f+(b*20|0)|0)|0;b=b+1|0}d=d+8|0}return}function rE(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=ww(12)|0;if(!b)b=0;else b=GL(b)|0;c[e+4>>2]=b;c[e+8>>2]=GL(d)|0;d=a+100|0;c[e>>2]=c[d>>2];c[d>>2]=e;return e|0}function sE(b,c){b=b|0;c=c|0;tE(b);a[b+44>>0]=0;uE(b)|0;tA(b)|0;return}function tE(b){b=b|0;var d=0,e=0;d=c[b+32>>2]|0;a:do if(d|0)while(1){e=c[d>>2]|0;if(!e)break a;if((a[e>>0]|0)==103?hL(e,96301)|0:0)qE(b,0,c[d+4>>2]|0);d=d+8|0}while(0);return}function uE(a){a=a|0;var b=0;b=Jr(a,2,96314)|0;if(!b)a=999;else{c[a+148>>2]=c[(c[b+16>>2]|0)+12>>2];a=300}return a|0}function vE(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;a=c[a+148>>2]|0;if((a|0)!=0?(e=c[a>>2]|0,(e|0)!=0):0)a=ab[e&63](b,d)|0;else a=0;return a|0}function wE(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;return (c[b>>2]|0)-(c[d>>2]|0)|0}function xE(a){a=a|0;var b=0.0,d=0.0;a=c[a+16>>2]|0;d=+h[a+16>>3];b=+h[a+24>>3];return (yE(~~(d>b?d:b)>>>0)|0)+1|0}function yE(a){a=a|0;var b=0,c=0;if(!a)a=-1;else{c=a>>>0>65535;a=c?a>>>16:a;c=c?16:0;b=a>>>0>255;a=b?a>>>8:a;c=b?c|8:c;b=a>>>0>15;a=b?a>>>4:a;c=b?c|4:c;b=a>>>0>3;a=(b?c|2:c)+((b?a>>>2:a)>>>0>1&1)|0}return a|0}function zE(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var i=0.0,j=0.0,k=0,m=0,n=0,o=0,p=0,q=0,r=0;r=l;l=l+32|0;q=r;p=AE(b,d,e,f,g)|0;e=BE(p)|0;if((e|0)>=0){n=q+16|0;o=q+24|0;m=q+8|0;k=g+32|0;e=0;g=0;while(1){if((g|0)>=(d|0))break;f=b+(g*40|0)+32|0;do if(c[f>>2]|0){CE(q,p,b+(g*40|0)|0);i=+h[n>>3];j=+h[o>>3];if(!(c[q>>2]|0)){a[(c[f>>2]|0)+36>>0]=1;break}if(+h[m>>3]==0.0){f=c[f>>2]|0;h[f+16>>3]=i;h[f+24>>3]=j;a[f+36>>0]=1;break}if((a[k>>0]|0)==1){f=c[f>>2]|0;h[f+16>>3]=i;h[f+24>>3]=j;a[f+36>>0]=1}else e=1}while(0);g=g+1|0}DE(p)}l=r;return e|0}function AE(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0;g=vw(28)|0;j=Ql(24896,c[4348]|0)|0;h=g+20|0;c[h>>2]=j;do if(j){j=jH()|0;c[g+24>>2]=j;if(!j){XL(96532,14,1,c[13918]|0)|0;i=6;break}else{c[g>>2]=a;c[g+4>>2]=b;c[g+8>>2]=d;c[g+12>>2]=e;c[g+16>>2]=f;break}}else{XL(96532,14,1,c[13918]|0)|0;i=6}while(0);if((i|0)==6){a=c[h>>2]|0;if(a|0)Kl(a)|0;a=c[g+24>>2]|0;if(a|0)lH(a)|0;_I(g);g=0}return g|0}function BE(a){a=a|0;var b=0;b=ME(a)|0;if((b|0)>=0){NE(a);OE(a);b=Kl(c[a+20>>2]|0)|0}return b|0}function CE(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0,g=0,i=0.0,j=0,k=0.0,m=0,n=0,o=0,p=0,q=0.0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0.0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0.0,L=0,M=0;M=l;l=l+464|0;J=M+416|0;L=M+400|0;G=M+384|0;m=M+352|0;n=M+320|0;o=M+288|0;p=M+256|0;r=M+224|0;s=M+192|0;t=M+160|0;u=M+128|0;v=M+96|0;x=M+64|0;y=M+32|0;H=M;z=c[d+32>>2]|0;e=+h[z>>3];C=d+16|0;A=(e*2.0+ +h[C>>3])*.125;D=z+8|0;I=d+24|0;i=+h[I>>3];K=(+h[D>>3]*2.0+i)*.5;if(!z)ma(96325,96335,445,96345);f=J;g=f+36|0;do{c[f>>2]=0;f=f+4|0}while((f|0)<(g|0));B=z+16|0;h[B>>3]=+h[d>>3]-e;E=d+8|0;F=z+24|0;h[F>>3]=i+ +h[E>>3];EE(m,b,d,J);j=c[m>>2]|0;f=c[m+4>>2]|0;e=+h[m+8>>3];m=m+16|0;c[L>>2]=c[m>>2];c[L+4>>2]=c[m+4>>2];c[L+8>>2]=c[m+8>>2];c[L+12>>2]=c[m+12>>2];a:do if(!j){c[a>>2]=0;c[a+4>>2]=f;h[a+8>>3]=e;a=a+16|0;c[a>>2]=c[L>>2];c[a+4>>2]=c[L+4>>2];c[a+8>>2]=c[L+8>>2];c[a+12>>2]=c[L+12>>2]}else{h[F>>3]=+h[E>>3];EE(n,b,d,J);g=c[n>>2]|0;m=c[n+4>>2]|0;i=+h[n+8>>3];n=n+16|0;c[G>>2]=c[n>>2];c[G+4>>2]=c[n+4>>2];c[G+8>>2]=c[n+8>>2];c[G+12>>2]=c[n+12>>2];if(!g){c[a>>2]=0;c[a+4>>2]=m;h[a+8>>3]=i;a=a+16|0;c[a>>2]=c[G>>2];c[a+4>>2]=c[G+4>>2];c[a+8>>2]=c[G+8>>2];c[a+12>>2]=c[G+12>>2];break}if(i>2]=c[G>>2];c[L+4>>2]=c[G+4>>2];c[L+8>>2]=c[G+8>>2];c[L+12>>2]=c[G+12>>2];f=m;e=i}else g=j;h[F>>3]=+h[E>>3]-+h[D>>3];EE(o,b,d,J);m=c[o>>2]|0;j=c[o+4>>2]|0;i=+h[o+8>>3];o=o+16|0;c[G>>2]=c[o>>2];c[G+4>>2]=c[o+4>>2];c[G+8>>2]=c[o+8>>2];c[G+12>>2]=c[o+12>>2];if(!m){c[a>>2]=0;c[a+4>>2]=j;h[a+8>>3]=i;a=a+16|0;c[a>>2]=c[G>>2];c[a+4>>2]=c[G+4>>2];c[a+8>>2]=c[G+8>>2];c[a+12>>2]=c[G+12>>2];break}if(i>2]=c[G>>2];c[L+4>>2]=c[G+4>>2];c[L+8>>2]=c[G+8>>2];c[L+12>>2]=c[G+12>>2];f=j;e=i}else m=g;h[B>>3]=+h[d>>3];h[F>>3]=+h[I>>3]+ +h[E>>3];EE(p,b,d,J);g=c[p>>2]|0;j=c[p+4>>2]|0;i=+h[p+8>>3];p=p+16|0;c[G>>2]=c[p>>2];c[G+4>>2]=c[p+4>>2];c[G+8>>2]=c[p+8>>2];c[G+12>>2]=c[p+12>>2];if(!g){c[a>>2]=0;c[a+4>>2]=j;h[a+8>>3]=i;a=a+16|0;c[a>>2]=c[G>>2];c[a+4>>2]=c[G+4>>2];c[a+8>>2]=c[G+8>>2];c[a+12>>2]=c[G+12>>2];break}if(i>2]=c[G>>2];c[L+4>>2]=c[G+4>>2];c[L+8>>2]=c[G+8>>2];c[L+12>>2]=c[G+12>>2];m=g;f=j;e=i}h[F>>3]=+h[E>>3]-+h[D>>3];EE(r,b,d,J);g=c[r>>2]|0;j=c[r+4>>2]|0;i=+h[r+8>>3];r=r+16|0;c[G>>2]=c[r>>2];c[G+4>>2]=c[r+4>>2];c[G+8>>2]=c[r+8>>2];c[G+12>>2]=c[r+12>>2];if(!g){c[a>>2]=0;c[a+4>>2]=j;h[a+8>>3]=i;a=a+16|0;c[a>>2]=c[G>>2];c[a+4>>2]=c[G+4>>2];c[a+8>>2]=c[G+8>>2];c[a+12>>2]=c[G+12>>2];break}if(i>2]=c[G>>2];c[L+4>>2]=c[G+4>>2];c[L+8>>2]=c[G+8>>2];c[L+12>>2]=c[G+12>>2];m=g;f=j;e=i}h[B>>3]=+h[C>>3]+ +h[d>>3];h[F>>3]=+h[I>>3]+ +h[E>>3];EE(s,b,d,J);g=c[s>>2]|0;j=c[s+4>>2]|0;i=+h[s+8>>3];s=s+16|0;c[G>>2]=c[s>>2];c[G+4>>2]=c[s+4>>2];c[G+8>>2]=c[s+8>>2];c[G+12>>2]=c[s+12>>2];if(!g){c[a>>2]=0;c[a+4>>2]=j;h[a+8>>3]=i;a=a+16|0;c[a>>2]=c[G>>2];c[a+4>>2]=c[G+4>>2];c[a+8>>2]=c[G+8>>2];c[a+12>>2]=c[G+12>>2];break}if(i>2]=c[G>>2];c[L+4>>2]=c[G+4>>2];c[L+8>>2]=c[G+8>>2];c[L+12>>2]=c[G+12>>2];m=g;f=j;e=i}h[F>>3]=+h[E>>3];EE(t,b,d,J);g=c[t>>2]|0;j=c[t+4>>2]|0;i=+h[t+8>>3];t=t+16|0;c[G>>2]=c[t>>2];c[G+4>>2]=c[t+4>>2];c[G+8>>2]=c[t+8>>2];c[G+12>>2]=c[t+12>>2];if(!g){c[a>>2]=0;c[a+4>>2]=j;h[a+8>>3]=i;a=a+16|0;c[a>>2]=c[G>>2];c[a+4>>2]=c[G+4>>2];c[a+8>>2]=c[G+8>>2];c[a+12>>2]=c[G+12>>2];break}if(i>2]=c[G>>2];c[L+4>>2]=c[G+4>>2];c[L+8>>2]=c[G+8>>2];c[L+12>>2]=c[G+12>>2];m=g;f=j;e=i}h[F>>3]=+h[E>>3]-+h[D>>3];EE(u,b,d,J);g=c[u>>2]|0;j=c[u+4>>2]|0;i=+h[u+8>>3];u=u+16|0;c[G>>2]=c[u>>2];c[G+4>>2]=c[u+4>>2];c[G+8>>2]=c[u+8>>2];c[G+12>>2]=c[u+12>>2];if(!g){c[a>>2]=0;c[a+4>>2]=j;h[a+8>>3]=i;a=a+16|0;c[a>>2]=c[G>>2];c[a+4>>2]=c[G+4>>2];c[a+8>>2]=c[G+8>>2];c[a+12>>2]=c[G+12>>2];break}if(i>2]=c[G>>2];c[L+4>>2]=c[G+4>>2];c[L+8>>2]=c[G+8>>2];c[L+12>>2]=c[G+12>>2];f=j;e=i}else g=m;j=(c[J+28>>2]|0)==0;do if(!(c[J+24>>2]|0))if(j){if(c[J+32>>2]|0){w=38;break}if(!((c[J+12>>2]|0)==0&(c[J>>2]|0)==0))w=38}else w=46;else if(j)w=38;else w=46;while(0);b:do if((w|0)==38)if(!(c[J+32>>2]|0)){h[B>>3]=+h[d>>3]-+h[z>>3];p=v+4|0;r=v+8|0;s=v+16|0;m=F;j=E;i=+h[I>>3];c:while(1){while(1){h[m>>3]=+h[j>>3]+i;if(!(+h[B>>3]<=+h[C>>3]+ +h[d>>3])){w=46;break b}EE(v,b,d,J);n=c[v>>2]|0;o=c[p>>2]|0;k=+h[r>>3];c[G>>2]=c[s>>2];c[G+4>>2]=c[s+4>>2];c[G+8>>2]=c[s+8>>2];c[G+12>>2]=c[s+12>>2];if(!n)break c;if(k>2]=c[G>>2];c[L+4>>2]=c[G+4>>2];c[L+8>>2]=c[G+8>>2];c[L+12>>2]=c[G+12>>2];m=B;j=B;i=A;g=n;f=o;e=k}c[a>>2]=0;c[a+4>>2]=o;h[a+8>>3]=k;a=a+16|0;c[a>>2]=c[G>>2];c[a+4>>2]=c[G+4>>2];c[a+8>>2]=c[G+8>>2];c[a+12>>2]=c[G+12>>2];break a}else w=46;while(0);d:do if((w|0)==46)if((c[J+12>>2]|0)==0&(c[J>>2]|0)==0){h[B>>3]=+h[d>>3]-+h[z>>3];k=+h[E>>3];n=x+4|0;o=x+8|0;p=x+16|0;i=k;k=+h[I>>3]+k;while(1){h[F>>3]=k;if(!(k>=i-+h[D>>3]))break d;EE(x,b,d,J);j=c[x>>2]|0;m=c[n>>2]|0;i=+h[o>>3];c[G>>2]=c[p>>2];c[G+4>>2]=c[p+4>>2];c[G+8>>2]=c[p+8>>2];c[G+12>>2]=c[p+12>>2];if(!j)break;if(i>2]=c[G>>2];c[L+4>>2]=c[G+4>>2];c[L+8>>2]=c[G+8>>2];c[L+12>>2]=c[G+12>>2];g=j;f=m;e=i}i=+h[E>>3];k=+h[F>>3]-K}c[a>>2]=0;c[a+4>>2]=m;h[a+8>>3]=i;a=a+16|0;c[a>>2]=c[G>>2];c[a+4>>2]=c[G+4>>2];c[a+8>>2]=c[G+8>>2];c[a+12>>2]=c[G+12>>2];break a}while(0);i=+h[d>>3];k=+h[C>>3]+i;h[B>>3]=k;q=+h[D>>3];h[F>>3]=+h[E>>3]-q;j=c[J+4>>2]|0;do if(!(c[J+8>>2]|0)){m=c[J>>2]|0;if(!((j|0)==0&(m|0)==0)){w=59;break}if(c[J+20>>2]|0){j=0;m=0;w=59;break}if(c[J+32>>2]|0){j=0;m=0;w=59}}else{m=c[J>>2]|0;w=59}while(0);e:do if((w|0)==59){f:do if((j|0)==0&(m|0)==0){h[B>>3]=k;p=y+4|0;r=y+8|0;s=y+16|0;m=F;j=E;i=q;g:while(1){while(1){h[m>>3]=+h[j>>3]-i;i=+h[d>>3];if(!(+h[B>>3]>=i-+h[z>>3]))break f;EE(y,b,d,J);n=c[y>>2]|0;o=c[p>>2]|0;k=+h[r>>3];c[G>>2]=c[s>>2];c[G+4>>2]=c[s+4>>2];c[G+8>>2]=c[s+8>>2];c[G+12>>2]=c[s+12>>2];if(!n)break g;if(k>2]=c[G>>2];c[L+4>>2]=c[G+4>>2];c[L+8>>2]=c[G+8>>2];c[L+12>>2]=c[G+12>>2];m=B;j=B;i=A;g=n;f=o;e=k}c[a>>2]=0;c[a+4>>2]=o;h[a+8>>3]=k;a=a+16|0;c[a>>2]=c[G>>2];c[a+4>>2]=c[G+4>>2];c[a+8>>2]=c[G+8>>2];c[a+12>>2]=c[G+12>>2];break a}while(0);if(c[J+20>>2]|0)break;if(c[J+32>>2]|0)break;h[B>>3]=+h[C>>3]+i;i=+h[E>>3];n=H+4|0;o=H+8|0;p=H+16|0;k=i;i=i-+h[D>>3];while(1){h[F>>3]=i;if(!(i<=+h[I>>3]+k))break e;EE(H,b,d,J);j=c[H>>2]|0;m=c[n>>2]|0;i=+h[o>>3];c[G>>2]=c[p>>2];c[G+4>>2]=c[p+4>>2];c[G+8>>2]=c[p+8>>2];c[G+12>>2]=c[p+12>>2];if(!j)break;if(i>2]=c[G>>2];c[L+4>>2]=c[G+4>>2];c[L+8>>2]=c[G+8>>2];c[L+12>>2]=c[G+12>>2];g=j;f=m;e=i}k=+h[E>>3];i=+h[F>>3]+K}c[a>>2]=0;c[a+4>>2]=m;h[a+8>>3]=i;a=a+16|0;c[a>>2]=c[G>>2];c[a+4>>2]=c[G+4>>2];c[a+8>>2]=c[G+8>>2];c[a+12>>2]=c[G+12>>2];break a}while(0);c[a>>2]=g;c[a+4>>2]=f;h[a+8>>3]=e;a=a+16|0;c[a>>2]=c[L>>2];c[a+4>>2]=c[L+4>>2];c[a+8>>2]=c[L+8>>2];c[a+12>>2]=c[L+12>>2]}while(0);l=M;return}function DE(a){a=a|0;lH(c[a+24>>2]|0)|0;_I(a);return}function EE(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,i=0.0,j=0,k=0,m=0,n=0.0,o=0,p=0,q=0,r=0.0,s=0,t=0;t=l;l=l+48|0;q=t+32|0;s=t+16|0;p=t;g=c[e+32>>2]|0;if(!g)ma(96325,96335,382,96354);o=g+16|0;c[p>>2]=c[o>>2];c[p+4>>2]=c[o+4>>2];c[p+8>>2]=c[o+8>>2];c[p+12>>2]=c[o+12>>2];o=d+4|0;m=0;g=0;while(1){if((m|0)>=(c[o>>2]|0))break;j=c[d>>2]|0;k=j+(m*40|0)|0;do if((k|0)!=(e|0)){if(+h[j+(m*40|0)+16>>3]>0.0?+h[j+(m*40|0)+24>>3]>0.0:0)break;g=g+((FE(e,k)|0)!=0&1)|0}while(0);m=m+1|0}GE(e,q);m=c[d+24>>2]|0;m=nH(m,c[m>>2]|0,q)|0;if(!m){c[b>>2]=g;h[b+8>>3]=0.0;s=b+16|0;c[s>>2]=c[p>>2];c[s+4>>2]=c[p+4>>2];c[s+8>>2]=c[p+8>>2];c[s+12>>2]=c[p+12>>2]}else{k=m;i=0.0;while(1){if(!k)break;j=c[(c[k+4>>2]|0)+16>>2]|0;if((j|0)!=(e|0)){HE(j,s);n=+IE(q,s);if(n>0.0){g=g+1|0;i=+JE(e,j,q,n,f)+i}d=c[j+32>>2]|0;if(((d|0)!=0?(a[d+36>>0]|0)!=0:0)?(GE(j,s),r=+IE(q,s),r>0.0):0){g=g+1|0;i=+KE(e,j,q,r,f)+i}}k=c[k>>2]|0}iH(m);c[b>>2]=g;h[b+8>>3]=i;s=b+16|0;c[s>>2]=c[p>>2];c[s+4>>2]=c[p+4>>2];c[s+8>>2]=c[p+8>>2];c[s+12>>2]=c[p+12>>2]}l=t;return}function FE(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,g=0.0;a=c[a+32>>2]|0;if(+h[b+16>>3]==0.0?+h[b+24>>3]==0.0:0){if((((a|0)!=0?(d=+h[b>>3],e=+h[a+16>>3],d>e):0)?d<+h[a>>3]+e:0)?(f=+h[b+8>>3],g=+h[a+24>>3],f>g):0)a=f<+h[a+8>>3]+g&1;else a=0;return a|0}ma(96391,96335,219,96428);return 0}function GE(a,b){a=a|0;b=b|0;var d=0.0,e=0.0;a=c[a+32>>2]|0;e=+h[a+16>>3];c[b>>2]=~~e;d=+h[a+24>>3];c[b+4>>2]=~~d;c[b+8>>2]=~~(+h[a>>3]+e);c[b+12>>2]=~~(+h[a+8>>3]+d);return}function HE(a,b){a=a|0;b=b|0;var d=0.0,e=0.0;e=+h[a>>3];c[b>>2]=~~e;d=+h[a+8>>3];c[b+4>>2]=~~d;c[b+8>>2]=~~(+h[a+16>>3]+e);c[b+12>>2]=~~(+h[a+24>>3]+d);return}function IE(a,b){a=a|0;b=b|0;var d=0.0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;i=c[a+8>>2]|0;j=c[b>>2]|0;if((((i|0)>=(j|0)?(k=c[a>>2]|0,l=c[b+8>>2]|0,(k|0)<=(l|0)):0)?(e=c[a+12>>2]|0,f=c[b+4>>2]|0,(e|0)>=(f|0)):0)?(g=c[a+4>>2]|0,h=c[b+12>>2]|0,(g|0)<=(h|0)):0)d=(+(c[((e|0)<(h|0)?a:b)+12>>2]|0)-+(c[((g|0)>(f|0)?a:b)+4>>2]|0))*(+(c[((i|0)<(l|0)?a:b)+8>>2]|0)-+(c[((k|0)>(j|0)?a:b)>>2]|0));else d=0.0;return +d}function JE(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=+e;f=f|0;var g=0.0,h=0.0,i=0,j=0;j=l;l=l+16|0;i=j;a=LE(a,b)|0;f=f+(((a|0)<0?5:a)<<2)|0;a=c[f>>2]|0;if(!a){c[f>>2]=b;g=e}else{HE(a,i);g=+IE(d,i);g=g>e?g:0.0;a=c[f>>2]|0;if((c[a+32>>2]|0)!=0?(GE(a,i),h=+IE(d,i),h>e):0)g=h>g?h:g;if(!(g>0.0)){c[f>>2]=b;g=e}}l=j;return +g}function KE(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=+e;f=f|0;var g=0.0,h=0.0,i=0,j=0;j=l;l=l+16|0;i=j;a=LE(a,b)|0;f=f+(((a|0)<0?5:a)<<2)|0;a=c[f>>2]|0;if(!a){c[f>>2]=b;g=e}else{HE(a,i);g=+IE(d,i);g=g>e?g:0.0;a=c[f>>2]|0;if((c[a+32>>2]|0)!=0?(GE(a,i),h=+IE(d,i),h>e):0)g=h>g?h:g;if(!(g>0.0)){c[f>>2]=b;g=e}}l=j;return +g}function LE(b,d){b=b|0;d=d|0;var e=0,f=0,g=0.0,i=0.0,j=0.0,k=0.0;e=c[b+32>>2]|0;f=c[d+32>>2]|0;if((e|0)==(f|0))ma(96370,96335,276,96380);do if((a[e+36>>0]|0)!=0?(a[f+36>>0]|0)!=0:0){j=+h[b>>3];if(j==0.0?+h[b+8>>3]==0.0:0){e=-1;break}k=+h[d>>3];i=+h[d+8>>3];if(!(k==0.0&i==0.0)){g=+h[b+8>>3];if(ij?2:1;break}e=kg){if(e){e=6;break}e=k>j?8:7;break}if(!e)if(k>j)e=5;else e=-1;else e=3}else e=-1}else e=-1;while(0);return e|0}function ME(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0;k=l;l=l+32|0;d=k+24|0;e=k+16|0;f=k;g=xE(a)|0;h=a+4|0;i=e+4|0;j=a+20|0;b=0;while(1){if((b|0)>=(c[h>>2]|0)){b=0;break}m=vw(32)|0;o=(c[a>>2]|0)+(b*40|0)|0;n=m+12|0;c[m+28>>2]=o;PE(f,o);c[n>>2]=c[f>>2];c[n+4>>2]=c[f+4>>2];c[n+8>>2]=c[f+8>>2];c[n+12>>2]=c[f+12>>2];n=c[n>>2]|0;c[e>>2]=(((c[m+20>>2]|0)-n|0)/2|0)+n;n=c[m+16>>2]|0;c[i>>2]=(((c[m+24>>2]|0)-n|0)/2|0)+n;c[d>>2]=c[e>>2];c[d+4>>2]=c[e+4>>2];c[m+8>>2]=QE(d,g)|0;n=c[j>>2]|0;if(!(bb[c[n>>2]&31](n,m,1)|0)){b=-1;break}else b=b+1|0}l=k;return b|0}function NE(a){a=a|0;var b=0,d=0,e=0;d=a+20|0;e=c[d>>2]|0;b=a+24|0;a=bb[c[e>>2]&31](e,0,128)|0;while(1){if(!a)break;e=c[b>>2]|0;oH(e,a+12|0,c[a+28>>2]|0,e,0)|0;e=c[d>>2]|0;a=bb[c[e>>2]&31](e,a,8)|0}return}function OE(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0;e=a+20|0;f=Sl(c[e>>2]|0)|0;d=0;while(1){if(!(Sl(c[e>>2]|0)|0))break;g=c[e>>2]|0;a=c[(c[g+8>>2]|0)+4>>2]|0;if(!a){h=8;break}b=c[(c[g+4>>2]|0)+8>>2]|0;if((b|0)<0)a=c[a+8>>2]|0;else a=a+(0-b)|0;if(!a){h=8;break}bb[c[g>>2]&31](g,a,4096)|0;_I(a);d=d+1|0}if((h|0)==8)ma(96441,96335,616,96444);if((f|0)==(d|0))return;else ma(96456,96335,623,96444)}function PE(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,g=0.0,i=0,j=0,k=0,l=0.0;d=c[b+32>>2]|0;if(!d){e=0.0;f=0.0}else{e=+h[d>>3];f=+h[d+8>>3]}l=+h[b>>3];k=~~+A(+(l-e));g=+h[b+8>>3];j=~~+A(+(g-f));i=~~+N(+(l+e+ +h[b+16>>3]));if((i|0)==2147483647)ma(96468,96335,264,96495);d=~~+N(+(g+f+ +h[b+24>>3]));if((d|0)==2147483647)ma(96505,96335,266,96495);else{c[a>>2]=k;c[a+4>>2]=j;c[a+8>>2]=i;c[a+12>>2]=d;return}}function QE(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;f=0;e=c[a>>2]|0;d=c[a+4>>2]|0;while(1){a=b+-1|0;if((b|0)<=0)break;i=e>>>a&1;b=d>>>a&1;g=b+-1|0;h=g&(e^d);g=g&0-i;f=i<<1|f<<2|i^b;b=a;e=h^e^g;d=h^d^g}return f|0}function RE(b){b=b|0;var d=0,e=0,f=0,g=0;d=rJ(b)|0;if(d>>>0>=(c[42408]|0)>>>0){d=d+11|0;c[42408]=d;d=yw(c[42409]|0,d)|0;c[42409]=d;if(!d)d=0;else e=4}else{d=c[42409]|0;e=4}if((e|0)==4){g=d;while(1){e=a[b>>0]|0;if(!(e<<24>>24))break;f=e&255;if(kK(f)|0)e=(jK(f)|0)&255;a[g>>0]=e;g=g+1|0;b=b+1|0}a[g>>0]=0}return d|0}function SE(b,e,f){b=b|0;e=e|0;f=f|0;var g=0.0,i=0,j=0.0,k=0.0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0.0;F=l;l=l+144|0;s=F+96|0;p=F+80|0;v=F+124|0;t=F+72|0;w=F+64|0;x=F+56|0;C=F+48|0;D=F+40|0;E=F+32|0;y=F+24|0;z=F+16|0;A=F+8|0;B=F;i=F+120|0;m=F+116|0;n=F+112|0;o=F+108|0;c[e+32>>2]=f;r=b;while(1)if((a[r>>0]|0)==32)r=r+1|0;else break;c[o>>2]=255;b=a[r>>0]|0;a:do if(b<<24>>24==35){c[p>>2]=i;c[p+4>>2]=m;c[p+8>>2]=n;c[p+12>>2]=o;if((cM(r,96547,p)|0)<=2){b=a[r>>0]|0;q=12;break}switch(f|0){case 0:{G=+((c[i>>2]|0)>>>0)*.00392156862745098;h[C>>3]=G;g=+((c[m>>2]|0)>>>0)*.00392156862745098;h[D>>3]=g;j=+((c[n>>2]|0)>>>0)*.00392156862745098;h[E>>3]=j;k=+((c[o>>2]|0)>>>0)*.00392156862745098;TE(G,g,j,t,w,x);h[e>>3]=+h[t>>3];h[e+8>>3]=+h[w>>3];h[e+16>>3]=+h[x>>3];h[e+24>>3]=k;b=0;break a}case 1:{a[e>>0]=c[i>>2];a[e+1>>0]=c[m>>2];a[e+2>>0]=c[n>>2];a[e+3>>0]=c[o>>2];b=0;break a}case 3:{j=+((c[i>>2]|0)>>>0)*.00392156862745098;h[C>>3]=j;k=+((c[m>>2]|0)>>>0)*.00392156862745098;h[D>>3]=k;G=+((c[n>>2]|0)>>>0)*.00392156862745098;h[E>>3]=G;UE(j,k,G,y,z,A,B);a[e>>0]=~~+h[y>>3]*255;a[e+1>>0]=~~+h[z>>3]*255;a[e+2>>0]=~~+h[A>>3]*255;a[e+3>>0]=~~+h[B>>3]*255;b=0;break a}case 2:{c[e>>2]=(((c[i>>2]|0)*65535|0)>>>0)/255|0;c[e+4>>2]=(((c[m>>2]|0)*65535|0)>>>0)/255|0;c[e+8>>2]=(((c[n>>2]|0)*65535|0)>>>0)/255|0;c[e+12>>2]=(((c[o>>2]|0)*65535|0)>>>0)/255|0;b=0;break a}case 4:{h[e>>3]=+((c[i>>2]|0)>>>0)*.00392156862745098;h[e+8>>3]=+((c[m>>2]|0)>>>0)*.00392156862745098;h[e+16>>3]=+((c[n>>2]|0)>>>0)*.00392156862745098;h[e+24>>3]=+((c[o>>2]|0)>>>0)*.00392156862745098;b=0;break a}default:{b=0;break a}}}else q=12;while(0);b:do if((q|0)==12){if(!(b<<24>>24!=46?((b&255)+-48|0)>>>0>=10:0)){b=rJ(r)|0;if(b>>>0>=(c[42410]|0)>>>0){b=b+11|0;c[42410]=b;b=yw(c[42411]|0,b)|0;c[42411]=b;if(!b){b=-1;break}}else b=c[42411]|0;m=b;i=r;c:while(1){n=i+1|0;i=a[i>>0]|0;switch(i<<24>>24){case 0:break c;case 44:{i=32;break}default:{}}a[m>>0]=i;m=m+1|0;i=n}a[m>>0]=0;c[s>>2]=t;c[s+4>>2]=w;c[s+8>>2]=x;if((cM(b,96561,s)|0)==3){k=+h[t>>3];k=k<1.0?k:1.0;k=k>0.0?k:0.0;h[t>>3]=k;j=+h[w>>3];j=j<1.0?j:1.0;j=j>0.0?j:0.0;h[w>>3]=j;g=+h[x>>3];g=g<1.0?g:1.0;g=g>0.0?g:0.0;h[x>>3]=g;switch(f|0){case 0:{h[e>>3]=k;h[e+8>>3]=j;h[e+16>>3]=g;h[e+24>>3]=1.0;b=0;break b}case 1:{VE(k,j,g,C,D,E);a[e>>0]=~~(+h[C>>3]*255.0);a[e+1>>0]=~~(+h[D>>3]*255.0);a[e+2>>0]=~~(+h[E>>3]*255.0);a[e+3>>0]=-1;b=0;break b}case 3:{VE(k,j,g,C,D,E);UE(+h[C>>3],+h[D>>3],+h[E>>3],y,z,A,B);a[e>>0]=~~+h[y>>3]*255;a[e+1>>0]=~~+h[z>>3]*255;a[e+2>>0]=~~+h[A>>3]*255;a[e+3>>0]=~~+h[B>>3]*255;b=0;break b}case 2:{VE(k,j,g,C,D,E);c[e>>2]=~~(+h[C>>3]*65535.0);c[e+4>>2]=~~(+h[D>>3]*65535.0);c[e+8>>2]=~~(+h[E>>3]*65535.0);c[e+12>>2]=65535;b=0;break b}case 4:{VE(k,j,g,C,D,E);h[e>>3]=+h[C>>3];h[e+8>>3]=+h[D>>3];h[e+16>>3]=+h[E>>3];h[e+24>>3]=1.0;b=0;break b}default:{b=0;break b}}}}i=WE(r)|0;c[v>>2]=i;if(!i)b=-1;else{b=c[42412]|0;if(!(((b|0)!=0?(u=c[b>>2]|0,(a[u>>0]|0)==(a[i>>0]|0)):0)?(xJ(u,i)|0)==0:0)){b=vM(v,24932,2491,12,38)|0;c[42412]=b;if(!b)switch(f|0){case 0:{c[e>>2]=0;c[e+4>>2]=0;c[e+8>>2]=0;c[e+12>>2]=0;c[e+16>>2]=0;c[e+20>>2]=0;h[e+24>>3]=1.0;b=1;break b}case 1:{a[e+2>>0]=0;a[e+1>>0]=0;a[e>>0]=0;a[e+3>>0]=-1;b=1;break b}case 3:{c[e>>2]=0;b=1;break b}case 2:{c[e+8>>2]=0;c[e+4>>2]=0;c[e>>2]=0;c[e+12>>2]=65535;b=1;break b}case 4:{c[e>>2]=0;c[e+4>>2]=0;c[e+8>>2]=0;c[e+12>>2]=0;c[e+16>>2]=0;c[e+20>>2]=0;h[e+24>>3]=1.0;b=1;break b}default:{b=1;break b}}}switch(f|0){case 0:{h[e>>3]=+(d[b+4>>0]|0)*.00392156862745098;h[e+8>>3]=+(d[b+5>>0]|0)*.00392156862745098;h[e+16>>3]=+(d[b+6>>0]|0)*.00392156862745098;h[e+24>>3]=+(d[b+10>>0]|0)*.00392156862745098;b=0;break b}case 1:{a[e>>0]=a[b+7>>0]|0;a[e+1>>0]=a[b+8>>0]|0;a[e+2>>0]=a[b+9>>0]|0;a[e+3>>0]=a[b+10>>0]|0;b=0;break b}case 3:{j=+(d[b+7>>0]|0)*.00392156862745098;h[C>>3]=j;k=+(d[b+8>>0]|0)*.00392156862745098;h[D>>3]=k;G=+(d[b+9>>0]|0)*.00392156862745098;h[E>>3]=G;UE(j,k,G,y,z,A,B);a[e>>0]=~~+h[y>>3]*255;a[e+1>>0]=~~+h[z>>3]*255;a[e+2>>0]=~~+h[A>>3]*255;a[e+3>>0]=~~+h[B>>3]*255;b=0;break b}case 2:{c[e>>2]=(d[b+7>>0]|0)*257;c[e+4>>2]=(d[b+8>>0]|0)*257;c[e+8>>2]=(d[b+9>>0]|0)*257;c[e+12>>2]=(d[b+10>>0]|0)*257;b=0;break b}case 4:{h[e>>3]=+(d[b+7>>0]|0)*.00392156862745098;h[e+8>>3]=+(d[b+8>>0]|0)*.00392156862745098;h[e+16>>3]=+(d[b+9>>0]|0)*.00392156862745098;h[e+24>>3]=+(d[b+10>>0]|0)*.00392156862745098;b=0;break b}default:{b=0;break b}}}}while(0);l=F;return b|0}function TE(a,b,c,d,e,f){a=+a;b=+b;c=+c;d=d|0;e=e|0;f=f|0;var g=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0;i=bc?b:c;m=ma?a:i);g=i/m;if(m>0.0)if(g>0.0){j=(m-a)/i;k=(m-b)/i;l=(m-c)/i;do if(!(m==a)){if(m==b){a=j+2.0-l;break}if(m==c)a=k+4.0-j;else a=0.0}else a=(b-c)/i;while(0);a=a*60.0;if(a<0.0)a=a+360.0}else a=0.0;else{g=0.0;a=0.0}h[d>>3]=a*.002777777777777778;h[f>>3]=m;h[e>>3]=g;return}function UE(a,b,c,d,e,f,g){a=+a;b=+b;c=+c;d=d|0;e=e|0;f=f|0;g=g|0;h[d>>3]=1.0-a;h[e>>3]=1.0-b;h[f>>3]=1.0-c;b=+h[d>>3];c=+h[e>>3];c=b>3]=c;b=+h[f>>3];c=b>3]=c;h[d>>3]=+h[d>>3]-c;h[e>>3]=+h[e>>3]-+h[g>>3];h[f>>3]=+h[f>>3]-+h[g>>3];return}function VE(a,b,c,d,e,f){a=+a;b=+b;c=+c;d=d|0;e=e|0;f=f|0;var g=0.0,i=0.0,j=0.0,k=0,l=0;a:do if(!(b<=0.0)){i=!(a>=1.0)?a*6.0:0.0;l=~~i;i=i-+(l|0);a=(1.0-b)*c;j=(1.0-i*b)*c;b=(1.0-(1.0-i)*b)*c;switch(l|0){case 0:{g=a;i=b;a=c;k=8;break a}case 1:{g=a;i=c;a=j;k=8;break a}case 2:{g=b;i=c;k=8;break a}case 3:{g=c;i=j;k=8;break a}case 4:{g=c;i=a;a=b;k=8;break a}case 5:{g=j;i=a;a=c;k=8;break a}default:break a}}else{g=c;i=c;a=c;k=8}while(0);if((k|0)==8){h[d>>3]=a;h[e>>3]=i;h[f>>3]=g}return}function WE(b){b=b|0;var d=0,e=0;d=a[b>>0]|0;if(((d<<24>>24!=98?(e=b+1|0,!(d<<24>>24==119|(VJ(e,122058,4)|0)==0)):0)?!(d<<24>>24==108|(VJ(e,122063,4)|0)==0):0)?(VJ(e,122068,8)|0)!=0:0){do if(d<<24>>24==47){d=WJ(e,47)|0;if(!d)b=e;else{if((a[e>>0]|0)!=47){e=(pK(122077,e,4)|0)==0;b=e?d+1|0:b;break}d=c[42413]|0;if((d|0?a[d>>0]|0:0)?pK(122077,d,3)|0:0){b=YE(d,b+2|0)|0;break}b=b+2|0}}else{d=c[42413]|0;if(((d|0)!=0?(a[d>>0]|0)!=0:0)?(pK(122077,d,3)|0)!=0:0)b=YE(d,b)|0}while(0);b=RE(b)|0}return b|0}function XE(a,b){a=a|0;b=b|0;return iK(c[a>>2]|0,c[b>>2]|0)|0}function YE(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;f=l;l=l+16|0;e=f;g=rJ(a)|0;g=(rJ(b)|0)+g|0;d=g+13|0;if((g+3|0)>>>0<(c[42414]|0)>>>0)d=c[42415]|0;else{c[42414]=d;d=yw(c[42415]|0,d)|0;c[42415]=d}c[e>>2]=a;c[e+4>>2]=b;pL(d,122082,e)|0;l=f;return c[42415]|0}function ZE(a){a=a|0;c[42413]=a;return}function _E(a,b,c,d,e){a=a|0;b=+b;c=+c;d=+d;e=+e;var f=0,g=0;f=l;l=l+208|0;g=f;$E(g,+h[a>>3],+h[a+8>>3],b,c,d,e);a=aF(g)|0;l=f;return a|0}function $E(a,b,c,d,e,f,g){a=a|0;b=+b;c=+c;d=+d;e=+e;f=+f;g=+g;var i=0,j=0;h[a>>3]=b;h[a+8>>3]=c;j=a+16|0;h[j>>3]=d;i=a+24|0;h[i>>3]=e;h[a+32>>3]=0.0;c=+K(+(+F(+f)/e),+(+E(+f)/d));h[a+56>>3]=c;e=+K(+(+F(+g)/e),+(+E(+g)/d));h[a+40>>3]=1.0;h[a+48>>3]=0.0;e=e-+A(+((e-c)*.15915494309189535))*6.283185307179586;h[a+64>>3]=g-f>3.141592653589793&e-c<3.141592653589793?e+6.283185307179586:e;gF(a);hF(a);iF(a);g=+h[j>>3];g=(g-+h[i>>3])/g;h[a+168>>3]=g;h[a+176>>3]=(2.0-g)*g;g=1.0-g;h[a+184>>3]=g;h[a+192>>3]=g*g;return}function aF(a){a=a|0;var b=0,c=0.0,d=0,e=0.0,f=0.0,g=0.0,i=0.0,j=0,k=0,l=0,m=0,n=0.0,o=0.0,p=0,q=0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0;q=vw(8)|0;f=+h[a+56>>3];e=+h[a+64>>3]-f;p=1;b=0;while(1){o=e/+(p|0);if(!(b<<24>>24==0&(p|0)<1024))break;a:do if(!(o<=1.5707963267948966))b=0;else{c=f;d=0;b=1;while(1){if(!(b<<24>>24!=0&(d|0)<(p|0)))break a;n=c+o;b=+bF(a,c,n)<=1.0e-05&1;c=n;d=d+1|0}}while(0);p=p<<1}i=+E(+f);u=+F(+f);d=a+16|0;s=+h[d>>3];v=s*i;j=a+24|0;c=+h[j>>3];g=c*u;i=c*i;c=+h[a>>3];k=a+40|0;t=+h[k>>3];l=a+48|0;r=+h[l>>3];e=t*v+c-r*g;m=a+8|0;n=+h[m>>3];g=r*v+t*g+n;s=-(u*s);cF(q,c,n);dF(q,e,g);n=+G(+(o*.5));n=+F(+o)*.3333333333333333*(+C(+(n*n*3.0+4.0))+-1.0);c=f;f=g;g=r*s+t*i;i=t*s-r*i;b=0;while(1){if((b|0)>=(p|0))break;r=c+o;u=+E(+r);v=+F(+r);x=+h[d>>3];z=x*u;w=+h[j>>3];t=w*v;u=w*u;w=+h[k>>3];y=+h[l>>3];s=w*z+ +h[a>>3]-y*t;t=y*z+w*t+ +h[m>>3];x=-(v*x);v=w*x-y*u;u=y*x+w*u;eF(q,e+i*n,f+g*n,s-v*n,t-u*n,s,t);c=r;e=s;f=t;g=u;i=v;b=b+1|0}fF(q);return q|0}function bF(a,b,c){a=a|0;b=+b;c=+c;var d=0.0,e=0.0,f=0.0,g=0.0,i=0.0;d=c+b;i=+h[a+16>>3];e=+h[a+24>>3]/i;g=+E(+d);f=+E(+(d*2.0));d=+E(+(d*3.0));a=e<.25?10328:10584;return +(((e*.001+4.98)*e+.207)/(e+.0067)*i*+L(+(((+h[a+32>>3]*e+ +h[a+40>>3])*e+ +h[a+48>>3])/(+h[a+56>>3]+e)*g+((+h[a>>3]*e+ +h[a+8>>3])*e+ +h[a+16>>3])/(+h[a+24>>3]+e)+((+h[a+64>>3]*e+ +h[a+72>>3])*e+ +h[a+80>>3])/(+h[a+88>>3]+e)*f+((+h[a+96>>3]*e+ +h[a+104>>3])*e+ +h[a+112>>3])/(+h[a+120>>3]+e)*d+(((+h[a+160>>3]*e+ +h[a+168>>3])*e+ +h[a+176>>3])/(+h[a+184>>3]+e)*g+((+h[a+128>>3]*e+ +h[a+136>>3])*e+ +h[a+144>>3])/(+h[a+152>>3]+e)+((+h[a+192>>3]*e+ +h[a+200>>3])*e+ +h[a+208>>3])/(+h[a+216>>3]+e)*f+((+h[a+224>>3]*e+ +h[a+232>>3])*e+ +h[a+240>>3])/(+h[a+248>>3]+e)*d)*(c-b))))}function cF(a,b,d){a=a|0;b=+b;d=+d;var e=0;c[42416]=100;e=vw(1600)|0;c[a>>2]=e;h[e>>3]=b;h[e+8>>3]=d;c[a+4>>2]=1;return}function dF(a,b,d){a=a|0;b=+b;d=+d;var e=0,f=0;f=c[a>>2]|0;e=(c[a+4>>2]|0)+-1|0;eF(a,+h[f+(e<<4)>>3],+h[f+(e<<4)+8>>3],b,d,b,d);return}function eF(a,b,d,e,f,g,i){a=a|0;b=+b;d=+d;e=+e;f=+f;g=+g;i=+i;var j=0,k=0,l=0,m=0;l=a+4|0;j=c[l>>2]|0;k=c[42416]|0;if((j+3|0)<(k|0))a=c[a>>2]|0;else{c[42416]=k<<1;j=aJ(c[a>>2]|0,k<<5)|0;c[a>>2]=j;a=j;j=c[l>>2]|0}h[a+(j<<4)>>3]=b;m=j+1|0;h[a+(j<<4)+8>>3]=d;h[a+(m<<4)>>3]=e;k=j+2|0;h[a+(m<<4)+8>>3]=f;h[a+(k<<4)>>3]=g;c[l>>2]=j+3;h[a+(k<<4)+8>>3]=i;return}function fF(a){a=a|0;var b=0;b=c[a>>2]|0;dF(a,+h[b>>3],+h[b+8>>3]);c[a>>2]=aJ(c[a>>2]|0,c[a+4>>2]<<4)|0;c[42416]=0;return}function gF(a){a=a|0;var b=0.0,c=0.0,d=0.0,e=0.0;d=+h[a+16>>3];b=+h[a+24>>3];b=+C(+(d*d-b*b));d=b*+h[a+40>>3];b=b*+h[a+48>>3];e=+h[a>>3];h[a+104>>3]=e-d;c=+h[a+8>>3];h[a+112>>3]=c-b;h[a+120>>3]=e+d;h[a+128>>3]=c+b;return}function hF(a){a=a|0;var b=0.0,c=0.0,d=0.0,e=0.0,f=0.0,g=0.0,i=0.0,j=0.0;d=+h[a+16>>3];i=+h[a+56>>3];j=+E(+i)*d;b=+h[a+24>>3];i=+F(+i)*b;g=+h[a+64>>3];d=+E(+g)*d;b=+F(+g)*b;g=+h[a>>3];c=+h[a+40>>3];e=+h[a+48>>3];h[a+72>>3]=c*j+g-e*i;f=+h[a+8>>3];h[a+80>>3]=e*j+f+c*i;h[a+88>>3]=g+c*d-e*b;h[a+96>>3]=f+e*d+c*b;return}function iF(a){a=a|0;var b=0.0,c=0.0,d=0.0,e=0.0,f=0.0,g=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0;k=+h[a+24>>3];l=+h[a+16>>3];e=k/l;m=+h[a+48>>3];n=+B(+m)<.1;j=+h[a+40>>3];do if(n){b=m/j;c=+J(+(b*e));d=-c;if(j<0.0){b=+J(+(b/e));e=d;d=3.141592653589793-c;c=4.71238898038469-b;b=1.5707963267948966-b;break}else{b=+J(+(b/e));e=-3.141592653589793-c;c=1.5707963267948966-b;b=-1.5707963267948966-b;break}}else{b=j/m;c=+J(+(b/e));d=c+1.5707963267948966;if(m<0.0){b=+J(+(b*e));e=c+-1.5707963267948966;c=b+3.141592653589793;break}else{b=+J(+(b*e));e=d;d=c+4.71238898038469;c=b;b=b+-3.141592653589793;break}}while(0);g=+h[a+56>>3];e=e-+A(+((e-g)*.15915494309189535))*6.283185307179586;b=b-+A(+((b-g)*.15915494309189535))*6.283185307179586;f=d-+A(+((d-g)*.15915494309189535))*6.283185307179586;g=c-+A(+((c-g)*.15915494309189535))*6.283185307179586;i=+h[a+64>>3];if(!(e<=i)){e=+h[a+72>>3];c=+h[a+88>>3];c=e>3]-k*+F(+e)*m;h[a+136>>3]=c;if(!(b<=i)){e=+h[a+80>>3];d=+h[a+96>>3];d=e>3]+ +F(+b)*k*j;h[a+144>>3]=d;if(!(f<=i)){f=+h[a+72>>3];b=+h[a+88>>3];b=f>b?f:b}else b=+E(+f)*l*j+ +h[a>>3]-k*+F(+f)*m;h[a+152>>3]=b-c;if(!(g<=i)){m=+h[a+80>>3];b=+h[a+96>>3];b=m>b?m:b}else b=+E(+g)*l*m+ +h[a+8>>3]+ +F(+g)*k*j;h[a+160>>3]=b-d;return}function jF(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0.0,i=0,j=0,k=0.0,m=0,n=0;n=l;l=l+80|0;m=n;kF(b);k=+h[e+56>>3];g=+h[e+64>>3];switch(a[e+80>>0]|0){case 116:{g=(+h[e+48>>3]-+lF(d))*.5+g;f=4;break}case 98:{g=g-(+h[e+48>>3]-+lF(d))*.5;f=4;break}default:{}}if((f|0)==4)g=g+-1.0;h[m>>3]=k;h[m+8>>3]=g;c[m+20>>2]=c[e+8>>2];c[m+16>>2]=c[e+4>>2];h[m+32>>3]=+h[e+16>>3];j=b+16|0;f=Im(c[(c[j>>2]|0)+8>>2]|0,122089)|0;e=m+56|0;c[e>>2]=f;i=m+60|0;c[i>>2]=c[(c[j>>2]|0)+212>>2];j=m+64|0;a[j>>0]=0;if(!((f|0)!=0?(a[f>>0]|0)!=0:0))c[e>>2]=122100;if((a[d+4>>0]|0)==1){e=c[d>>2]|0;FD(b,c[(c[b>>2]|0)+336>>2]|0);f=c[e+24>>2]|0;if(!f)BD(b,122106);else BD(b,f);nF(b,e,m);if(a[j>>0]|0)_I(c[i>>2]|0)}else mF(b,c[d>>2]|0,m);oF(b);l=n;return}function kF(a){a=a|0;var d=0,e=0,f=0;d=Vt(a)|0;e=c[d>>2]|0;a=c[e+4>>2]|0;c[d+4>>2]=a;c[d+12>>2]=c[e+12>>2];switch(a|0){case 2:{a=e+8|0;f=6;break}case 0:{a=e+8|0;f=6;break}case 1:{a=e+8|0;f=6;break}case 3:{a=e+8|0;f=6;break}default:{}}if((f|0)==6)c[d+8>>2]=c[a>>2];c[d+208>>2]=c[e+208>>2];c[d+228>>2]=c[e+228>>2];c[d+244>>2]=c[e+244>>2];f=d+260|0;b[f>>1]=b[f>>1]&-2|b[e+260>>1]&1;return}function lF(b){b=b|0;var d=0.0,e=0,f=0;switch(a[b+4>>0]|0){case 1:{e=c[b>>2]|0;b=e+72|0;e=e+56|0;f=5;break}case 3:{e=c[b>>2]|0;b=e+24|0;e=e+8|0;f=5;break}case 2:{e=c[b>>2]|0;b=e+32|0;e=e+16|0;f=5;break}default:d=0.0}if((f|0)==5)d=+h[b>>3]-+h[e>>3];return +d}function mF(d,e,f){d=d|0;e=e|0;f=f|0;var g=0,i=0,j=0,k=0,m=0,n=0,o=0.0,p=0.0,q=0,r=0,s=0;n=l;l=l+96|0;j=n+64|0;i=n+32|0;g=n+16|0;k=n;m=b[e+4>>1]|0;if(m<<16>>16>=1){r=e+8|0;p=+h[e+24>>3];o=+h[r>>3];h[k>>3]=(o+p)*.5+ +h[f>>3];h[k+8>>3]=(+h[e+16>>3]+ +h[e+32>>3])*.5+ +h[f+8>>3];q=c[e>>2]|0;s=f+16|0;f=a[e+6>>0]|0;c[g>>2]=c[k>>2];c[g+4>>2]=c[k+4>>2];c[g+8>>2]=c[k+8>>2];c[g+12>>2]=c[k+12>>2];c[i>>2]=c[s>>2];c[i+4>>2]=c[s+4>>2];c[i+8>>2]=c[s+8>>2];c[i+12>>2]=c[s+12>>2];c[i+16>>2]=c[s+16>>2];c[i+20>>2]=c[s+20>>2];c[i+24>>2]=c[s+24>>2];c[i+28>>2]=c[s+28>>2];c[j>>2]=c[r>>2];c[j+4>>2]=c[r+4>>2];c[j+8>>2]=c[r+8>>2];c[j+12>>2]=c[r+12>>2];c[j+16>>2]=c[r+16>>2];c[j+20>>2]=c[r+20>>2];c[j+24>>2]=c[r+24>>2];c[j+28>>2]=c[r+28>>2];AF(d,m<<16>>16,q,g,(p-o)*.5,i,j,f)}l=n;return}function nF(e,f,g){e=e|0;f=f|0;g=g|0;var i=0,j=0,k=0,m=0.0,n=0.0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;y=l;l=l+176|0;t=y+96|0;v=y+64|0;w=y+136|0;p=y;q=y+128|0;r=f+48|0;c[v>>2]=c[r>>2];c[v+4>>2]=c[r+4>>2];c[v+8>>2]=c[r+8>>2];c[v+12>>2]=c[r+12>>2];c[v+16>>2]=c[r+16>>2];c[v+20>>2]=c[r+20>>2];c[v+24>>2]=c[r+24>>2];c[v+28>>2]=c[r+28>>2];m=+h[g>>3];n=+h[g+8>>3];r=f+84|0;i=c[r>>2]|0;if(!(c[f>>2]|0))x=(c[f+8>>2]|0)!=0;else x=1;u=f+108|0;j=c[u>>2]|0;if(j|0)pF(g,j,167296);h[v>>3]=+h[v>>3]+m;s=v+16|0;h[s>>3]=+h[s>>3]+m;s=v+8|0;h[s>>3]=+h[s>>3]+n;s=v+24|0;h[s>>3]=+h[s>>3]+n;if(x?(c[e+152>>2]&4|0)==0:0){c[t>>2]=c[v>>2];c[t+4>>2]=c[v+4>>2];c[t+8>>2]=c[v+8>>2];c[t+12>>2]=c[v+12>>2];c[t+16>>2]=c[v+16>>2];c[t+20>>2]=c[v+20>>2];c[t+24>>2]=c[v+24>>2];c[t+28>>2]=c[v+28>>2];s=qF(e,g,f,t,w)|0}else s=0;o=f+42|0;j=b[o>>1]|0;if(!(j&32)){k=c[f+20>>2]|0;if(k){j=rF(e,k,c[f+28>>2]|0,j&65535,q)|0;if(!(b[o>>1]&4)){c[t>>2]=c[v>>2];c[t+4>>2]=c[v+4>>2];c[t+8>>2]=c[v+8>>2];c[t+12>>2]=c[v+12>>2];c[t+16>>2]=c[v+16>>2];c[t+20>>2]=c[v+20>>2];c[t+24>>2]=c[v+24>>2];c[t+28>>2]=c[v+28>>2];ID(e,t,j)}else{o=d[f+33>>0]|0;c[t>>2]=c[v>>2];c[t+4>>2]=c[v+4>>2];c[t+8>>2]=c[v+8>>2];c[t+12>>2]=c[v+12>>2];c[t+16>>2]=c[v+16>>2];c[t+20>>2]=c[v+20>>2];c[t+24>>2]=c[v+24>>2];c[t+28>>2]=c[v+28>>2];yy(e,sF(p,t,o)|0,4,4,j)}_I(c[q>>2]|0)}while(1){j=c[i>>2]|0;if(!j)break;tF(e,j,g);i=i+4|0}i=c[r>>2]|0;OD(e,1.0);j=f+24|0;while(1){k=i+4|0;i=c[i>>2]|0;if(!i)break;if(!(a[i+100>>0]|0)){i=k;continue}uF(e,i,g,c[j>>2]|0,c[k>>2]|0);i=k}if(a[f+33>>0]|0){c[t>>2]=c[v>>2];c[t+4>>2]=c[v+4>>2];c[t+8>>2]=c[v+8>>2];c[t+12>>2]=c[v+12>>2];c[t+16>>2]=c[v+16>>2];c[t+20>>2]=c[v+20>>2];c[t+24>>2]=c[v+24>>2];c[t+28>>2]=c[v+28>>2];vF(e,f,t)}}if(s|0)wF(e,w);if((x?c[e+152>>2]&4|0:0)?(c[t>>2]=c[v>>2],c[t+4>>2]=c[v+4>>2],c[t+8>>2]=c[v+8>>2],c[t+12>>2]=c[v+12>>2],c[t+16>>2]=c[v+16>>2],c[t+20>>2]=c[v+20>>2],c[t+24>>2]=c[v+24>>2],c[t+28>>2]=c[v+28>>2],qF(e,g,f,t,w)|0):0)wF(e,w);if(c[u>>2]|0)xF(g,167296);l=y;return}function oF(a){a=a|0;var b=0;b=c[a+16>>2]|0;c[b+208>>2]=0;c[b+228>>2]=0;c[b+244>>2]=0;c[b+212>>2]=0;Wt(a);return}function pF(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0,g=0,i=0;i=a+16|0;f=c[i>>2]|0;if(f|0){if(!(c[b>>2]|0)){f=0;g=d}else{c[d>>2]=f;f=c[b>>2]|0;g=i}c[g>>2]=f}f=c[a+20>>2]|0;if(f|0){g=b+4|0;if(!(c[g>>2]|0)){f=0;g=d}else{c[d+4>>2]=f;f=c[g>>2]|0;g=i}c[g+4>>2]=f}e=+h[a+32>>3];if(e>=0.0){f=b+16|0;if(!(+h[f>>3]>=0.0))e=-1.0;else{h[d+16>>3]=e;e=+h[f>>3];d=i}h[d+16>>3]=e}return}function qF(d,e,f,g,h){d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;u=l;l=l+224|0;n=u+8|0;k=u;t=u+40|0;j=u+184|0;i=u+56|0;m=c[d+16>>2]|0;o=m+208|0;c[h>>2]=c[o>>2];p=m+228|0;c[h+4>>2]=c[p>>2];q=m+244|0;c[h+8>>2]=c[q>>2];r=m+212|0;c[h+12>>2]=c[r>>2];s=m+260|0;a[h+16>>0]=(b[s>>1]<<15&65535)<<16>>16>>15;h=c[f+16>>2]|0;if((h|0)!=0?(a[h>>0]|0)!=0:0)i=0;else{cm(t,128,i);i=e+60|0;h=c[i>>2]|0;if(!h){h=GL(Yt(d,c[m+8>>2]|0,t)|0)|0;c[i>>2]=h;a[e+64>>0]=1}fm(t,h)|0;i=c[42417]|0;c[42417]=i+1;c[k>>2]=i;pL(j,122183,k)|0;fm(t,j)|0;i=t+4|0;h=c[i>>2]|0;if(h>>>0>=(c[t+8>>2]|0)>>>0){dm(t,1)|0;h=c[i>>2]|0}a[h>>0]=0;h=c[t>>2]|0;c[i>>2]=h;i=1}h=Xt(d,0,c[f>>2]|0,c[f+12>>2]|0,c[f+8>>2]|0,h,c[m+8>>2]|0)|0;if(i)gm(t);do if(h|0){if((c[o>>2]|0)==0?(b[s>>1]&1)==0:0)break;c[n>>2]=c[g>>2];c[n+4>>2]=c[g+4>>2];c[n+8>>2]=c[g+8>>2];c[n+12>>2]=c[g+12>>2];c[n+16>>2]=c[g+16>>2];c[n+20>>2]=c[g+20>>2];c[n+24>>2]=c[g+24>>2];c[n+28>>2]=c[g+28>>2];du(d,n);wD(d,c[o>>2]|0,c[p>>2]|0,c[q>>2]|0,c[r>>2]|0)}while(0);l=u;return h|0}function rF(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0.0,i=0,j=0;j=l;l=l+16|0;i=j;if(!((xv(b,f,i)|0)<<24>>24)){DD(a,b);b=1}else{DD(a,c[f>>2]|0);b=c[f+4>>2]|0;h=+g[i>>2];if(!b)ED(a,122106,d,h);else ED(a,b,d,h);b=e>>>1&1|2}BD(a,122171);l=j;return b|0}function sF(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0.0,g=0.0,i=0.0,j=0.0;c[a>>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];c[a+12>>2]=c[b+12>>2];e=a+32|0;b=b+16|0;c[e>>2]=c[b>>2];c[e+4>>2]=c[b+4>>2];c[e+8>>2]=c[b+8>>2];c[e+12>>2]=c[b+12>>2];if((d|0)>1){j=+(d|0)*.5;i=+h[a>>3]+j;h[a>>3]=i;d=a+8|0;g=+h[d>>3]+j;h[d>>3]=g;f=+h[e>>3]-j;h[e>>3]=f;e=a+40|0;j=+h[e>>3]-j;h[e>>3]=j}else{f=+h[e>>3];g=+h[a+8>>3];i=+h[a>>3];j=+h[a+40>>3]}h[a+16>>3]=f;h[a+24>>3]=g;h[a+48>>3]=i;h[a+56>>3]=j;return a|0}function tF(e,f,g){e=e|0;f=f|0;g=g|0;var i=0,j=0.0,k=0.0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;v=l;l=l+176|0;r=v+96|0;s=v+136|0;t=v+64|0;p=v;q=v+128|0;u=f+48|0;c[t>>2]=c[u>>2];c[t+4>>2]=c[u+4>>2];c[t+8>>2]=c[u+8>>2];c[t+12>>2]=c[u+12>>2];c[t+16>>2]=c[u+16>>2];c[t+20>>2]=c[u+20>>2];c[t+24>>2]=c[u+24>>2];c[t+28>>2]=c[u+28>>2];j=+h[g>>3];k=+h[g+8>>3];if(!(c[f>>2]|0))u=(c[f+8>>2]|0)!=0;else u=1;h[t>>3]=+h[t>>3]+j;o=t+16|0;h[o>>3]=+h[o>>3]+j;o=t+8|0;h[o>>3]=+h[o>>3]+k;o=t+24|0;h[o>>3]=+h[o>>3]+k;if(u?(c[e+152>>2]&4|0)==0:0){c[r>>2]=c[t>>2];c[r+4>>2]=c[t+4>>2];c[r+8>>2]=c[t+8>>2];c[r+12>>2]=c[t+12>>2];c[r+16>>2]=c[t+16>>2];c[r+20>>2]=c[t+20>>2];c[r+24>>2]=c[t+24>>2];c[r+28>>2]=c[t+28>>2];o=qF(e,g,f,r,s)|0}else o=0;n=f+42|0;i=b[n>>1]|0;a:do if(!(i&32)){m=c[f+20>>2]|0;if(m|0){i=rF(e,m,c[f+28>>2]|0,i&65535,q)|0;if(!(b[n>>1]&4)){c[r>>2]=c[t>>2];c[r+4>>2]=c[t+4>>2];c[r+8>>2]=c[t+8>>2];c[r+12>>2]=c[t+12>>2];c[r+16>>2]=c[t+16>>2];c[r+20>>2]=c[t+20>>2];c[r+24>>2]=c[t+24>>2];c[r+28>>2]=c[t+28>>2];ID(e,r,i)}else{n=d[f+33>>0]|0;c[r>>2]=c[t>>2];c[r+4>>2]=c[t+4>>2];c[r+8>>2]=c[t+8>>2];c[r+12>>2]=c[t+12>>2];c[r+16>>2]=c[t+16>>2];c[r+20>>2]=c[t+20>>2];c[r+24>>2]=c[t+24>>2];c[r+28>>2]=c[t+28>>2];yy(e,sF(p,r,n)|0,4,4,i)}_I(c[q>>2]|0)}if(a[f+33>>0]|0){c[r>>2]=c[t>>2];c[r+4>>2]=c[t+4>>2];c[r+8>>2]=c[t+8>>2];c[r+12>>2]=c[t+12>>2];c[r+16>>2]=c[t+16>>2];c[r+20>>2]=c[t+20>>2];c[r+24>>2]=c[t+24>>2];c[r+28>>2]=c[t+28>>2];vF(e,f,r)}i=f+88|0;switch(a[f+92>>0]|0){case 1:{nF(e,c[i>>2]|0,g);break a}case 3:{zF(e,c[i>>2]|0,g);break a}default:{mF(e,c[i>>2]|0,g);break a}}}while(0);if(o|0)wF(e,s);if((u?c[e+152>>2]&4|0:0)?(c[r>>2]=c[t>>2],c[r+4>>2]=c[t+4>>2],c[r+8>>2]=c[t+8>>2],c[r+12>>2]=c[t+12>>2],c[r+16>>2]=c[t+16>>2],c[r+20>>2]=c[t+20>>2],c[r+24>>2]=c[t+24>>2],c[r+28>>2]=c[t+28>>2],qF(e,g,f,r,s)|0):0)wF(e,s);l=v;return}function uF(f,g,i,j,k){f=f|0;g=g|0;i=i|0;j=j|0;k=k|0;var m=0.0,n=0,o=0.0,p=0.0,q=0,r=0.0,s=0.0,t=0.0,u=0.0,v=0,w=0,x=0.0,y=0,z=0,A=0,B=0,C=0;A=l;l=l+32|0;y=A+16|0;z=A;r=+h[i>>3];x=+h[i+8>>3];q=(j|0)==0?122106:j;DD(f,q);BD(f,q);t=+h[g+48>>3];o=+h[g+56>>3];u=+h[g+64>>3];p=+h[g+72>>3];s=t+r;r=u+r;x=o+x;q=g+100|0;i=a[q>>0]|0;if((i&1)!=0?(n=c[g+96>>2]|0,((e[g+80>>1]|0)+(e[g+84>>1]|0)|0)<(c[n+104>>2]|0)):0){i=b[g+86>>1]|0;do if(i<<16>>16)if(((e[g+82>>1]|0)+(i&65535)|0)==(c[n+100>>2]|0)){B=a[n+32>>0]|0;C=(B<<24>>24)/2|0;j=(C<<24>>24)+(d[n+33>>0]|0)|0;i=j;j=j&255;m=x-+(C<<24>>24);n=B;break}else{n=a[n+32>>0]|0;i=0;j=((n<<24>>24)/2|0)<<24>>24;m=x;break}else{C=a[n+32>>0]|0;j=((C<<24>>24)/2|0)<<24>>24;i=j+(d[n+33>>0]|0)|0;m=x;n=C}while(0);h[z+8>>3]=m-+(j|0);h[z>>3]=r+ +(((n<<24>>24)/2|0)<<24>>24);c[y>>2]=c[z>>2];c[y+4>>2]=c[z+4>>2];c[y+8>>2]=c[z+8>>2];c[y+12>>2]=c[z+12>>2];yF(f,y,0.0,p-o+ +(i&255|0)+ +(n<<24>>24));i=a[q>>0]|0}if(i&2?(v=b[g+86>>1]|0,w=c[g+96>>2]|0,((e[g+82>>1]|0)+(v&65535)|0)<(c[w+100>>2]|0)):0){i=b[g+84>>1]|0;do if(!(i<<16>>16)){i=a[w+32>>0]|0;C=(i<<24>>24)/2|0;n=(C<<24>>24)+(d[w+33>>0]|0)|0;j=n&255;n=n&255;m=+(C<<24>>24);h[z>>3]=s-m-+(n|0);if((c[w+104>>2]|0)==(e[g+80>>1]|0)){j=n<<1&255;break}if((k|0)!=0?(b[k+86>>1]|0)!=v<<16>>16:0)j=~~(+(j&255)-u+ +h[w+64>>3]-m)&255}else{if(((e[g+80>>1]|0)+(i&65535)|0)==(c[w+104>>2]|0)){i=a[w+32>>0]|0;C=(i<<24>>24)/2|0;j=(C&255)+(d[w+33>>0]|0)&255;h[z>>3]=s-+(C<<24>>24);break}i=a[w+32>>0]|0;m=+(((i<<24>>24)/2|0)<<24>>24);h[z>>3]=s-m;if((k|0)!=0?(b[k+86>>1]|0)!=v<<16>>16:0)j=~~(+h[w+64>>3]-u-m)&255;else j=0}while(0);h[z+8>>3]=x-+(((i<<24>>24)/2|0)<<24>>24);c[y>>2]=c[z>>2];c[y+4>>2]=c[z+4>>2];c[y+8>>2]=c[z+8>>2];c[y+12>>2]=c[z+12>>2];yF(f,y,u-t+ +(j&255)+ +(i<<24>>24),0.0)}l=A;return}function vF(e,f,g){e=e|0;f=f|0;g=g|0;var i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0.0;p=l;l=l+160|0;o=p+112|0;n=p;j=p+144|0;m=c[f+24>>2]|0;BD(e,(m|0)==0?122106:m);m=f+42|0;i=b[m>>1]|0;if(!(i&384))FD(e,c[(c[e>>2]|0)+336>>2]|0);else{c[j+4>>2]=0;c[j>>2]=0;i=i&65535;if(!(i&256)){if(i&128|0){i=122112;k=4}}else{i=122119;k=4}if((k|0)==4)c[j>>2]=i;FD(e,j)}k=f+33|0;OD(e,+(d[k>>0]|0));a:do if(!(b[m>>1]&4)){i=b[f+36>>1]&15360;if(!(i<<16>>16)){i=a[k>>0]|0;if((i&255)>1){q=+(i&255)*.5;h[g>>3]=+h[g>>3]+q;n=g+8|0;h[n>>3]=+h[n>>3]+q;n=g+16|0;h[n>>3]=+h[n>>3]-q;n=g+24|0;h[n>>3]=+h[n>>3]-q};c[o>>2]=c[g>>2];c[o+4>>2]=c[g+4>>2];c[o+8>>2]=c[g+8>>2];c[o+12>>2]=c[g+12>>2];c[o+16>>2]=c[g+16>>2];c[o+20>>2]=c[g+20>>2];c[o+24>>2]=c[g+24>>2];c[o+28>>2]=c[g+28>>2];ID(e,o,0);break}j=n+16|0;m=d[k>>0]|0;c[o>>2]=c[g>>2];c[o+4>>2]=c[g+4>>2];c[o+8>>2]=c[g+8>>2];c[o+12>>2]=c[g+12>>2];c[o+16>>2]=c[g+16>>2];c[o+20>>2]=c[g+20>>2];c[o+24>>2]=c[g+24>>2];c[o+28>>2]=c[g+28>>2];sF(j,o,m)|0;do switch(((i&65535)+-1024|0)>>>10&4194303|0){case 7:{KD(e,j,2);break a}case 3:{KD(e,n+32|0,2);break a}case 1:{KD(e,n+48|0,2);break a}case 0:{g=n+64|0;c[n>>2]=c[g>>2];c[n+4>>2]=c[g+4>>2];c[n+8>>2]=c[g+8>>2];c[n+12>>2]=c[g+12>>2];KD(e,n,2);break a}case 11:{KD(e,j,3);break a}case 5:{KD(e,n+32|0,3);break a}case 2:{g=n+80|0;c[g>>2]=c[j>>2];c[g+4>>2]=c[j+4>>2];c[g+8>>2]=c[j+8>>2];c[g+12>>2]=c[j+12>>2];KD(e,n+48|0,3);break a}case 8:{g=n+64|0;c[n>>2]=c[g>>2];c[n+4>>2]=c[g+4>>2];c[n+8>>2]=c[g+8>>2];c[n+12>>2]=c[g+12>>2];KD(e,n,3);break a}case 13:{KD(e,j,4);break a}case 6:{g=n+80|0;c[g>>2]=c[j>>2];c[g+4>>2]=c[j+4>>2];c[g+8>>2]=c[j+8>>2];c[g+12>>2]=c[j+12>>2];KD(e,n+32|0,4);break a}case 10:{g=n+80|0;c[g>>2]=c[j>>2];c[g+4>>2]=c[j+4>>2];c[g+8>>2]=c[j+8>>2];c[g+12>>2]=c[j+12>>2];g=n+96|0;o=n+32|0;c[g>>2]=c[o>>2];c[g+4>>2]=c[o+4>>2];c[g+8>>2]=c[o+8>>2];c[g+12>>2]=c[o+12>>2];KD(e,n+48|0,4);break a}case 12:{g=n+64|0;c[n>>2]=c[g>>2];c[n+4>>2]=c[g+4>>2];c[n+8>>2]=c[g+8>>2];c[n+12>>2]=c[g+12>>2];KD(e,n,4);break a}case 9:{KD(e,j,2);KD(e,n+48|0,2);break a}case 4:{g=n+64|0;c[n>>2]=c[g>>2];c[n+4>>2]=c[g+4>>2];c[n+8>>2]=c[g+8>>2];c[n+12>>2]=c[g+12>>2];KD(e,n,2);KD(e,n+32|0,2);break a}default:break a}while(0)}else{m=d[k>>0]|0;c[o>>2]=c[g>>2];c[o+4>>2]=c[g+4>>2];c[o+8>>2]=c[g+8>>2];c[o+12>>2]=c[g+12>>2];c[o+16>>2]=c[g+16>>2];c[o+20>>2]=c[g+20>>2];c[o+24>>2]=c[g+24>>2];c[o+28>>2]=c[g+28>>2];yy(e,sF(n,o,m)|0,4,4,0)}while(0);l=p;return}function wF(d,e){d=d|0;e=e|0;var f=0,g=0,h=0;h=c[d+16>>2]|0;f=h+208|0;if((c[f>>2]|0)==0?(b[h+260>>1]&1)==0:0)d=0;else{xD(d);d=c[f>>2]|0}if((d|0)!=(c[e>>2]|0)){_I(d);c[f>>2]=c[e>>2]}d=h+228|0;f=c[d>>2]|0;g=e+4|0;if((f|0)!=(c[g>>2]|0)){_I(f);c[d>>2]=c[g>>2]}d=h+244|0;f=c[d>>2]|0;g=e+8|0;if((f|0)!=(c[g>>2]|0)){_I(f);c[d>>2]=c[g>>2]}d=h+212|0;f=c[d>>2]|0;g=e+12|0;if((f|0)!=(c[g>>2]|0)){_I(f);c[d>>2]=c[g>>2]}h=h+260|0;b[h>>1]=b[h>>1]&-2|a[e+16>>0]&1;return}function xF(a,b){a=a|0;b=b|0;var d=0.0,e=0;e=c[b>>2]|0;if(e|0)c[a+16>>2]=e;e=c[b+4>>2]|0;if(e|0)c[a+20>>2]=e;d=+h[b+16>>3];if(d>=0.0)h[a+32>>3]=d;return}function yF(a,b,d,e){a=a|0;b=b|0;d=+d;e=+e;var f=0,g=0,i=0;f=l;l=l+64|0;g=f+32|0;i=f;c[i>>2]=c[b>>2];c[i+4>>2]=c[b+4>>2];c[i+8>>2]=c[b+8>>2];c[i+12>>2]=c[b+12>>2];h[i+16>>3]=+h[b>>3]+d;h[i+24>>3]=+h[b+8>>3]+e;c[g>>2]=c[i>>2];c[g+4>>2]=c[i+4>>2];c[g+8>>2]=c[i+8>>2];c[g+12>>2]=c[i+12>>2];c[g+16>>2]=c[i+16>>2];c[g+20>>2]=c[i+20>>2];c[g+24>>2]=c[i+24>>2];c[g+28>>2]=c[i+28>>2];ID(a,g,1);l=f;return}function zF(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0.0,k=0.0,m=0.0,n=0.0;i=l;l=l+64|0;g=i;k=+h[e>>3];n=k+ +h[d>>3];m=+h[e+8>>3];j=m+ +h[d+8>>3];k=k+ +h[d+16>>3];m=m+ +h[d+24>>3];h[g>>3]=k;h[g+8>>3]=m;h[g+32>>3]=n;h[g+40>>3]=j;h[g+16>>3]=n;h[g+24>>3]=m;h[g+48>>3]=k;h[g+56>>3]=j;f=c[d+36>>2]|0;if(!f)f=c[e+56>>2]|0;e=c[d+32>>2]|0;if(!e)ma(122126,122134,623,122146);if(!(a[e>>0]|0))ma(122160,122134,624,122146);else{MD(b,e,g,4,1,f);l=i;return}}function AF(d,e,f,g,i,j,k,m){d=d|0;e=e|0;f=f|0;g=g|0;i=+i;j=j|0;k=k|0;m=m|0;var n=0.0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0.0,J=0,K=0,L=0,M=0.0,N=0.0,O=0,P=0,Q=0,R=0;R=l;l=l+128|0;K=R+104|0;O=R+48|0;P=R+16|0;L=R;J=L;c[J>>2]=0;c[J+4>>2]=0;M=+h[g>>3];N=M-i;I=M+i;J=L+8|0;h[J>>3]=(+h[k+24>>3]-+h[k+8>>3])*.5+ +h[g+8>>3];yD(d,1);D=P+16|0;E=P+4|0;F=P+24|0;G=O+4|0;H=O+16|0;s=(m|0)==0;t=O+24|0;u=O+8|0;v=O+32|0;w=O+40|0;x=O+48|0;y=j+16|0;z=j+4|0;A=P+8|0;q=0;while(1){if((q|0)>=(e|0))break;switch(a[f+(q*24|0)+6>>0]|0){case 108:{i=N;break}case 114:{i=I-+h[f+(q*24|0)+8>>3];break}default:i=M-+h[f+(q*24|0)+8>>3]*.5}h[g>>3]=i;B=f+(q*24|0)+16|0;h[J>>3]=+h[J>>3]-+h[B>>3];C=f+(q*24|0)+4|0;p=c[f+(q*24|0)>>2]|0;r=0;while(1){if((r|0)>=(b[C>>1]|0))break;o=p+4|0;m=c[o>>2]|0;if(m){h[D>>3]=+h[(+h[m+16>>3]>0.0?m:j)+16>>3];c[P>>2]=c[((c[m>>2]|0)==0?j:m)>>2];k=c[((c[m+4>>2]|0)==0?j:m)+4>>2]|0;c[E>>2]=k;m=c[m+24>>2]&127;if(!m)Q=12;else m=c[F>>2]&-128|m}else{h[D>>3]=+h[y>>3];c[P>>2]=c[j>>2];k=c[z>>2]|0;c[E>>2]=k;Q=12}if((Q|0)==12){Q=0;m=c[F>>2]&-128}c[F>>2]=m;BD(d,k);c[O>>2]=c[p>>2];c[G>>2]=P;h[H>>3]=+h[p+16>>3];if(s)n=1.0;else n=+h[p+24>>3];h[t>>3]=n;c[A>>2]=c[(c[o>>2]|0)+8>>2];c[u>>2]=c[p+8>>2];o=p+32|0;h[v>>3]=+h[o>>3];h[w>>3]=+h[B>>3];a[x>>0]=108;h[L>>3]=i;c[K>>2]=c[L>>2];c[K+4>>2]=c[L+4>>2];c[K+8>>2]=c[L+8>>2];c[K+12>>2]=c[L+12>>2];AD(d,K,O);n=+h[o>>3]+i;h[g>>3]=n;p=p+56|0;r=r+1|0;i=n}q=q+1|0}zD(d);l=R;return}function BF(a){a=a|0;_I(c[a>>2]|0);_I(c[a+4>>2]|0);_I(c[a+8>>2]|0);_I(c[a+16>>2]|0);_I(c[a+12>>2]|0);_I(c[a+20>>2]|0);_I(c[a+24>>2]|0);return}function CF(a){a=a|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;if(a|0){j=a+4|0;e=0;g=c[a>>2]|0;while(1){if((e|0)>=(b[j>>1]|0))break;k=g+4|0;d=0;f=c[g>>2]|0;while(1){if((d|0)>=(b[k>>1]|0))break;_I(c[f>>2]|0);h=c[f+8>>2]|0;if(h|0?(i=c[f+12>>2]|0,i|0):0)gb[i&127](h);d=d+1|0;f=f+56|0}e=e+1|0;g=g+24|0}d=c[a>>2]|0;if(d|0)_I(d);_I(a)}return}function DF(a){a=a|0;_I(c[a+32>>2]|0);_I(a);return}function EF(b,d){b=b|0;d=d|0;switch(a[b+4>>0]|0){case 1:{FF(c[b>>2]|0);break}case 3:{DF(c[b>>2]|0);break}default:CF(c[b>>2]|0)}if(d|0)_I(b);return}function FF(a){a=a|0;var b=0,d=0,e=0;e=a+84|0;if((c[a+100>>2]|0)==-1)Kl(c[e>>2]|0)|0;else{b=c[e>>2]|0;_I(c[a+92>>2]|0);_I(c[a+96>>2]|0);while(1){d=c[b>>2]|0;if(!d)break;GF(d);b=b+4|0}_I(c[e>>2]|0)}BF(a);_I(a);return}function GF(a){a=a|0;EF(a+88|0,0);BF(a);_I(a);return}function HF(b,e,f){b=b|0;e=e|0;f=f|0;var g=0;b=c[(c[(c[b+16>>2]|0)+104>>2]|0)+72>>2]|0;if((a[b+4>>0]|0)!=2?(g=IF(c[b>>2]|0,e)|0,(g|0)!=0):0){c[f>>2]=d[g+35>>0];b=g+48|0}else b=0;return b|0}function IF(a,b){a=a|0;b=b|0;var d=0,e=0;d=c[a+4>>2]|0;if(!((d|0)!=0?(iK(d,b)|0)==0:0))e=3;a:do if((e|0)==3){d=c[a+84>>2]|0;while(1){a=c[d>>2]|0;if(!a){a=0;break a}a=JF(a,b)|0;if(!a)d=d+4|0;else break}}while(0);return a|0}function JF(b,d){b=b|0;d=d|0;var e=0;e=c[b+4>>2]|0;if(!((e|0)!=0?(iK(e,d)|0)==0:0))if((a[b+92>>0]|0)==1)b=IF(c[b+88>>2]|0,d)|0;else b=0;return b|0}function KF(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return 0}function LF(d){d=d|0;var f=0.0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;p=d+92|0;c[p>>2]=vw((c[d+100>>2]<<2)+4|0)|0;n=vw((c[d+104>>2]<<2)+4|0)|0;c[d+96>>2]=n;o=d+32|0;m=c[d+84>>2]|0;while(1){l=c[m>>2]|0;if(!l)break;d=b[l+82>>1]|0;f=+h[l+72>>3];if(d<<16>>16==1)i=~~f;else{i=~~((f-+(O((a[o>>0]|0)+-1|0,(d&65535)+-1|0)|0))/+(d&65535));i=(i|0)>1?i:1}j=b[l+80>>1]|0;f=+h[l+64>>3];if(j<<16>>16==1)k=~~f;else{k=~~((f-+(O((a[o>>0]|0)+-1|0,(j&65535)+-1|0)|0))/+(j&65535));k=(k|0)>1?k:1}q=e[l+86>>1]|0;g=(d&65535)+q|0;d=q;while(1){if((d|0)>=(g|0))break;q=(c[p>>2]|0)+(d<<2)|0;r=c[q>>2]|0;c[q>>2]=(r|0)>(i|0)?r:i;d=d+1|0}d=e[l+84>>1]|0;g=(j&65535)+d|0;while(1){if((d|0)>=(g|0))break;r=n+(d<<2)|0;q=c[r>>2]|0;c[r>>2]=(q|0)>(k|0)?q:k;d=d+1|0}m=m+4|0}return}function MF(a){a=a|0;var b=0,d=0;d=l;l=l+16|0;b=d;if(a>>>0<21)a=c[54824+(a<<2)>>2]|0;else{c[b>>2]=a;pL(174081,122187,b)|0;a=174081}l=d;return a|0}function NF(a,b,d){a=a|0;b=b|0;d=d|0;var f=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;k=a+104|0;l=a+100|0;j=d+16|0;f=0;g=0;while(1){if((f|0)>(c[k>>2]|0))break;i=no(d,MF(f)|0,1)|0;No(i,122241,304,1)|0;m=i+16|0;c[(c[m>>2]|0)+176>>2]=0;o=vw((c[l>>2]<<2)+4|0)|0;n=c[m>>2]|0;c[n+172>>2]=o;c[n+184>>2]=0;n=vw((c[l>>2]<<2)+4|0)|0;c[(c[m>>2]|0)+180>>2]=n;if(!g)c[(c[j>>2]|0)+192>>2]=i;else c[(c[g+16>>2]|0)+164>>2]=i;f=f+1|0;g=i}j=b+16|0;f=0;g=0;while(1){if((f|0)>(c[l>>2]|0))break;i=no(b,MF(f)|0,1)|0;No(i,122241,304,1)|0;o=i+16|0;c[(c[o>>2]|0)+176>>2]=0;m=vw((c[k>>2]<<2)+4|0)|0;n=c[o>>2]|0;c[n+172>>2]=m;c[n+184>>2]=0;n=vw((c[k>>2]<<2)+4|0)|0;c[(c[o>>2]|0)+180>>2]=n;if(!g)c[(c[j>>2]|0)+192>>2]=i;else c[(c[g+16>>2]|0)+164>>2]=i;f=f+1|0;g=i}f=c[a+84>>2]|0;while(1){g=c[f>>2]|0;if(!g)break;o=g+84|0;n=no(d,MF(e[o>>1]|0)|0,0)|0;o=no(d,MF((e[g+80>>1]|0)+(e[o>>1]|0)|0)|0,0)|0;OF(d,n,o,~~+h[g+64>>3]);o=g+86|0;n=no(b,MF(e[o>>1]|0)|0,0)|0;o=no(b,MF((e[g+82>>1]|0)+(e[o>>1]|0)|0)|0,0)|0;OF(b,n,o,~~+h[g+72>>3]);f=f+4|0}PF(d);PF(b);return}function OF(a,d,f,g){a=a|0;d=d|0;f=f|0;g=g|0;var h=0,i=0;h=an(a,d,f,0,0)|0;if(!h){i=an(a,d,f,0,1)|0;No(i,122254,176,1)|0;b[(c[i+16>>2]|0)+170>>1]=g;d=d+16|0;a=c[d>>2]|0;h=c[a+180>>2]|0;if(!h)a=ww((c[a+184>>2]<<2)+8|0)|0;else a=yw(h,(c[a+184>>2]<<2)+8|0)|0;g=c[d>>2]|0;c[g+180>>2]=a;g=g+184|0;h=c[g>>2]|0;c[g>>2]=h+1;c[a+(h<<2)>>2]=i;d=c[d>>2]|0;c[(c[d+180>>2]|0)+(c[d+184>>2]<<2)>>2]=0;d=f+16|0;a=c[d>>2]|0;h=c[a+172>>2]|0;if(!h)a=ww((c[a+176>>2]<<2)+8|0)|0;else a=yw(h,(c[a+176>>2]<<2)+8|0)|0;g=c[d>>2]|0;c[g+172>>2]=a;g=g+176|0;f=c[g>>2]|0;c[g>>2]=f+1;c[a+(f<<2)>>2]=i;i=c[d>>2]|0;c[(c[i+172>>2]|0)+(c[i+176>>2]<<2)>>2]=0}else{i=(c[h+16>>2]|0)+170|0;f=e[i>>1]|0;b[i>>1]=(f|0)>(g|0)?f:g}return}function PF(a){a=a|0;var d=0,e=0,f=0,g=0,h=0,i=0;d=c[(c[a+16>>2]|0)+192>>2]|0;while(1){f=d+16|0;h=c[(c[f>>2]|0)+164>>2]|0;if(!h)break;if(an(a,d,h,0,0)|0){d=h;continue}g=an(a,d,h,0,1)|0;No(g,122254,176,1)|0;b[(c[g+16>>2]|0)+170>>1]=0;d=c[f>>2]|0;e=c[d+180>>2]|0;if(!e)d=ww((c[d+184>>2]<<2)+8|0)|0;else d=yw(e,(c[d+184>>2]<<2)+8|0)|0;i=c[f>>2]|0;c[i+180>>2]=d;i=i+184|0;e=c[i>>2]|0;c[i>>2]=e+1;c[d+(e<<2)>>2]=g;f=c[f>>2]|0;c[(c[f+180>>2]|0)+(c[f+184>>2]<<2)>>2]=0;f=h+16|0;d=c[f>>2]|0;e=c[d+172>>2]|0;if(!e)d=ww((c[d+176>>2]<<2)+8|0)|0;else d=yw(e,(c[d+176>>2]<<2)+8|0)|0;e=c[f>>2]|0;c[e+172>>2]=d;e=e+176|0;i=c[e>>2]|0;c[e>>2]=i+1;c[d+(i<<2)>>2]=g;d=c[f>>2]|0;c[(c[d+172>>2]|0)+(c[d+176>>2]<<2)>>2]=0;d=h}return}function QF(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0;g=a+92|0;e=0;f=0;b=c[(c[(c[b+16>>2]|0)+192>>2]|0)+16>>2]|0;while(1){b=c[b+164>>2]|0;if(!b)break;b=c[b+16>>2]|0;h=b+232|0;c[(c[g>>2]|0)+(f<<2)>>2]=(c[h>>2]|0)-e;e=c[h>>2]|0;f=f+1|0}a=a+96|0;e=0;f=0;b=c[(c[(c[d+16>>2]|0)+192>>2]|0)+16>>2]|0;while(1){b=c[b+164>>2]|0;if(!b)break;b=c[b+16>>2]|0;h=b+232|0;c[(c[a>>2]|0)+(f<<2)>>2]=(c[h>>2]|0)-e;e=c[h>>2]|0;f=f+1|0}return}function RF(b){b=b|0;var d=0,e=0,f=0,g=0,h=0;h=l;l=l+16|0;g=h+4|0;d=h;c[d>>2]=c[4411];e=c[b+100>>2]|0;if((e|0)!=1?(f=b+104|0,(c[f>>2]|0)!=1):0){c[b+92>>2]=vw((e<<2)+4|0)|0;c[b+96>>2]=vw((c[f>>2]<<2)+4|0)|0;a[g>>0]=a[d>>0]|0;a[g+1>>0]=a[d+1>>0]|0;a[g+2>>0]=a[d+2>>0]|0;a[g+3>>0]=a[d+3>>0]|0;f=gn(122267,g,0)|0;a[g>>0]=a[d>>0]|0;a[g+1>>0]=a[d+1>>0]|0;a[g+2>>0]=a[d+2>>0]|0;a[g+3>>0]=a[d+3>>0]|0;g=gn(122272,g,0)|0;No(f,122277,280,1)|0;No(g,122277,280,1)|0;NF(b,f,g);gx(f,2,2147483647)|0;gx(g,2,2147483647)|0;QF(b,f,g);SF(f,g)}else LF(b);l=h;return}function SF(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=(c[b+16>>2]|0)+192|0;while(1){d=c[d>>2]|0;if(!d)break;f=d+16|0;d=c[f>>2]|0;e=c[d+172>>2]|0;if(e){_I(e);d=c[f>>2]|0}e=c[d+180>>2]|0;if(e){_I(e);d=c[f>>2]|0}d=d+164|0}ln(a)|0;ln(b)|0;return}function TF(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0.0,r=0.0;p=l;l=l+272|0;n=p+104|0;o=p+136|0;j=p+72|0;k=p;g=p+144|0;c[k+48>>2]=b;switch(Co(b)|0){case 0:{e=c[b+60>>2]|0;break}case 1:{e=ro(b)|0;break}case 2:{e=ro(c[((c[b>>2]&3|0)==2?b:b+-48|0)+40>>2]|0)|0;break}default:{}}i=k+52|0;c[i>>2]=e;m=c[e+60>>2]|0;h[k+32>>3]=+h[d+16>>3];c[k+16>>2]=c[d+4>>2];c[k+20>>2]=c[d+8>>2];c[k+40>>2]=0;f=bI(c[d>>2]|0,o,k)|0;if(!f){cm(n,128,g);a[d+82>>0]=0;e=GL(UF(b,n)|0)|0;c[d>>2]=e;if((c[d+12>>2]|0)==1)e=yB(e)|0;else e=vB(e,c[i>>2]|0)|0;_I(c[d>>2]|0);c[d>>2]=e;jw(c[(c[m+16>>2]|0)+144>>2]|0,d);gm(n);e=c[o>>2]|0}else{e=f+4|0;if((a[e>>0]|0)==1){if((c[(c[f>>2]|0)+24>>2]|0)==0?VF(b)|0:0){i=GL(VF(b)|0)|0;c[(c[f>>2]|0)+24>>2]=i}m=WF(m,c[f>>2]|0,0,k)|0;c[o>>2]=c[o>>2]|m;m=c[f>>2]|0;r=+h[m+64>>3]*.5;q=+h[m+72>>3]*.5;XF(j,-r,-q,r,q);m=c[f>>2]|0;c[n>>2]=c[j>>2];c[n+4>>2]=c[j+4>>2];c[n+8>>2]=c[j+8>>2];c[n+12>>2]=c[j+12>>2];c[n+16>>2]=c[j+16>>2];c[n+20>>2]=c[j+20>>2];c[n+24>>2]=c[j+24>>2];c[n+28>>2]=c[j+28>>2];YF(m,n,15)}else{ZF(c[(c[m+16>>2]|0)+144>>2]|0,c[f>>2]|0,k);n=c[f>>2]|0;q=+h[n+24>>3]*.5;r=+h[n+32>>3]*.5;XF(j,-q,-r,q,r);n=(c[f>>2]|0)+8|0;c[n>>2]=c[j>>2];c[n+4>>2]=c[j+4>>2];c[n+8>>2]=c[j+8>>2];c[n+12>>2]=c[j+12>>2];c[n+16>>2]=c[j+16>>2];c[n+20>>2]=c[j+20>>2];c[n+24>>2]=c[j+24>>2];c[n+28>>2]=c[j+28>>2]}h[d+24>>3]=+h[j+16>>3]-+h[j>>3];h[d+32>>3]=+h[j+24>>3]-+h[j+8>>3];c[d+72>>2]=f;if((a[e>>0]|0)==1){_I(c[d>>2]|0);c[d>>2]=GL(122290)|0}e=c[o>>2]|0}l=p;return e|0}function UF(b,d){b=b|0;d=d|0;var e=0;a:do switch(Co(b)|0){case 0:{fm(d,Dn(b)|0)|0;break}case 1:{fm(d,Dn(b)|0)|0;break}case 2:{fm(d,Dn(c[((c[b>>2]&3|0)==3?b:b+48|0)+40>>2]|0)|0)|0;e=b+-48|0;fm(d,Dn(c[((c[b>>2]&3|0)==2?b:e)+40>>2]|0)|0)|0;if(!(qn(ro(c[((c[b>>2]&3|0)==2?b:e)+40>>2]|0)|0)|0)){fm(d,122549)|0;break a}else{fm(d,122546)|0;break a}}default:{}}while(0);e=d+4|0;b=c[e>>2]|0;if(b>>>0>=(c[d+8>>2]|0)>>>0){dm(d,1)|0;b=c[e>>2]|0}a[b>>0]=0;d=c[d>>2]|0;c[e>>2]=d;return d|0}function VF(b){b=b|0;var c=0,d=0;c=Im(b,122531)|0;if(!((c|0)!=0?(a[c>>0]|0)!=0:0))d=3;do if((d|0)==3){c=Im(b,122540)|0;if(c|0?a[c>>0]|0:0)break;c=0}while(0);return c|0}function WF(f,g,i,j){f=f|0;g=g|0;i=i|0;j=j|0;var k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;w=l;l=l+16|0;u=w+8|0;t=w;v=g+108|0;k=c[v>>2]|0;if(k|0)pF(j,k,167328);c[g+80>>2]=i;k=bG(f,g,j)|0;r=g+36|0;f=b[r>>1]|0;if(!(f&128))a[g+32>>0]=2;i=g+33|0;if(!(f&32))a[i>>0]=1;RF(g);n=c[g+104>>2]|0;p=a[g+32>>0]|0;f=O(n+1|0,p)|0;o=d[i>>0]<<1;q=c[g+100>>2]|0;p=O(q+1|0,p)|0;m=g+96|0;f=o+f|0;i=0;while(1){if((i|0)>=(n|0))break;f=(c[(c[m>>2]|0)+(i<<2)>>2]|0)+f|0;i=i+1|0}n=g+92|0;i=p+o|0;m=0;while(1){if((m|0)>=(q|0))break;i=(c[(c[n>>2]|0)+(m<<2)>>2]|0)+i|0;m=m+1|0}n=g+38|0;do if(b[r>>1]&1){r=b[n>>1]|0;m=r&65535;if(r<<16>>16?(s=b[g+40>>1]|0,s<<16>>16):0){if(!((f|0)>(m|0)|(i|0)>(s&65535|0))){i=0;f=0;break}_l(0,122331,t)|0;k=1;i=0;f=0;break}_l(0,122365,u)|0;k=1}while(0);u=e[n>>1]|0;h[g+64>>3]=+(((f|0)>(u|0)?f:u)|0);u=e[g+40>>1]|0;h[g+72>>3]=+(((i|0)>(u|0)?i:u)|0);if(c[v>>2]|0)xF(j,167328);l=w;return k|0}function XF(a,b,c,d,e){a=a|0;b=+b;c=+c;d=+d;e=+e;h[a>>3]=b;h[a+8>>3]=c;h[a+16>>3]=d;h[a+24>>3]=e;return}function YF(e,f,g){e=e|0;f=f|0;g=g|0;var i=0,j=0,k=0,m=0.0,n=0.0,o=0,p=0,q=0.0,r=0.0,s=0,t=0,u=0,v=0,w=0,x=0,y=0.0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0.0,K=0;I=l;l=l+64|0;G=I+32|0;H=I;E=c[e+84>>2]|0;k=c[e+80>>2]|0;if((k|0?(i=c[k+24>>2]|0,i|0):0)?(j=e+24|0,(c[j>>2]|0)==0):0)c[j>>2]=GL(i)|0;F=e+48|0;i=f+16|0;n=+h[i>>3];m=+h[f>>3];k=~~(n-m-+(~~+h[e+64>>3]|0));if((k|0)<=-1)ma(122298,122134,1761,122308);o=f+24|0;y=+h[o>>3];p=f+8|0;q=+h[p>>3];r=+(~~+h[e+72>>3]|0);s=~~(y-q-r);if((s|0)<=-1)ma(122321,122134,1764,122308);t=b[e+36>>1]|0;j=t&65535;a:do if(j&1){b:do if((k|0)>0)switch(j&6){case 4:{h[i>>3]=m+r;break b}case 2:{J=+(k|0);h[i>>3]=n+J;m=m+J;h[f>>3]=m;break b}default:{J=+(k>>>1|0);m=m+J;h[f>>3]=m;h[i>>3]=n-J;break b}}while(0);if((s|0)>0)switch(t&24){case 16:{y=q+r;h[o>>3]=y;s=0;i=0;break a}case 8:{J=+(s|0);y=y+J;h[o>>3]=y;h[p>>3]=q+J;s=0;i=0;break a}default:{J=+(s>>>1|0);h[p>>3]=q+J;y=y-J;h[o>>3]=y;s=0;i=0;break a}}else{s=0;i=0}}else i=k;while(0);n=+(d[e+33>>0]|0);C=e+32|0;u=a[C>>0]|0;q=+(u<<24>>24);D=e+104|0;k=c[D>>2]|0;t=(i|0)/(k|0)|0;o=i-(O(t,k)|0)|0;o=~~(((o|0)>-1?.5:-.5)+ +(o|0));B=e+96|0;p=u<<24>>24;i=~~(m+n+q);j=0;while(1){if((j|0)>(k|0))break;A=(c[B>>2]|0)+(j<<2)|0;k=c[A>>2]|0;c[A>>2]=i;i=i+t+((j|0)<(o|0)&1)+k+p|0;j=j+1|0;k=c[D>>2]|0}A=e+100|0;k=c[A>>2]|0;t=(s|0)/(k|0)|0;p=s-(O(t,k)|0)|0;p=~~(((p|0)>-1?.5:-.5)+ +(p|0));z=e+92|0;o=u<<24>>24;i=~~(y-n-q);j=0;while(1){if((j|0)>(k|0))break;x=(c[z>>2]|0)+(j<<2)|0;k=c[x>>2]|0;c[x>>2]=i;i=i-t+(((j|0)<(p|0))<<31>>31)-k-o|0;j=j+1|0;k=c[A>>2]|0}u=(g|0)==0;v=H+16|0;w=H+24|0;x=H+8|0;i=E;while(1){o=c[i>>2]|0;if(!o)break;k=b[o+84>>1]|0;if(u){j=0;p=b[o+80>>1]|0;s=b[o+86>>1]|0;t=b[o+82>>1]|0}else{j=k<<16>>16==0?8:0;s=b[o+86>>1]|0;j=s<<16>>16==0?j|4:j;p=b[o+80>>1]|0;t=b[o+82>>1]|0;j=(((p&65535)+(k&65535)|0)==(c[D>>2]|0)?j|2:j)|((t&65535)+(s&65535)|0)==(c[A>>2]|0)}K=c[B>>2]|0;k=k&65535;h[H>>3]=+(c[K+(k<<2)>>2]|0);E=a[C>>0]|0;h[v>>3]=+((c[K+((p&65535)+k<<2)>>2]|0)-E|0);p=c[z>>2]|0;h[w>>3]=+(c[p+((s&65535)<<2)>>2]|0);h[x>>3]=+((c[p+((t&65535)+(s&65535)<<2)>>2]|0)+E|0);c[G>>2]=c[H>>2];c[G+4>>2]=c[H+4>>2];c[G+8>>2]=c[H+8>>2];c[G+12>>2]=c[H+12>>2];c[G+16>>2]=c[H+16>>2];c[G+20>>2]=c[H+20>>2];c[G+24>>2]=c[H+24>>2];c[G+28>>2]=c[H+28>>2];_F(o,G,j&g);i=i+4|0}a[e+35>>0]=g;c[F>>2]=c[f>>2];c[F+4>>2]=c[f+4>>2];c[F+8>>2]=c[f+8>>2];c[F+12>>2]=c[f+12>>2];c[F+16>>2]=c[f+16>>2];c[F+20>>2]=c[f+20>>2];c[F+24>>2]=c[f+24>>2];c[F+28>>2]=c[f+28>>2];l=I;return}function ZF(d,e,f){d=d|0;e=e|0;f=f|0;var g=0,i=0,j=0.0,k=0.0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0,s=0.0,t=0.0,u=0.0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0.0,Q=0.0,R=0.0;O=l;l=l+112|0;H=O+48|0;I=O+16|0;J=O;c[I>>2]=0;c[I+4>>2]=0;c[I+8>>2]=0;c[I+12>>2]=0;c[I+16>>2]=0;c[I+20>>2]=0;c[I+24>>2]=0;c[I+28>>2]=0;K=e+4|0;L=f+16|0;M=f+32|0;N=I+16|0;r=b[K>>1]|0;n=r<<16>>16;g=0;j=-1.0;m=0;while(1){if((m|0)>=(n|0)){g=1;break}i=c[e>>2]|0;if((b[i+(m*24|0)+4>>1]|0)>1){g=0;break}i=c[(c[i+(m*24|0)>>2]|0)+4>>2]|0;if(!i){k=+h[M>>3];h[N>>3]=k;i=L}else{if(c[i+24>>2]&127|0){g=0;break}k=+h[(+h[i+16>>3]>0.0?i:L)+16>>3];h[N>>3]=k;i=(c[i>>2]|0)==0?L:i}i=c[i>>2]|0;c[I>>2]=i;if(!(j==-1.0)){if(k!=j){g=0;break}}else j=k;if(g){if(xJ(i,g)|0){g=0;break}}else g=i;m=m+1|0}a[e+6>>0]=g;E=f+48|0;F=f+20|0;G=I+4|0;w=f+40|0;x=I+24|0;y=d+144|0;z=H+4|0;v=J+8|0;A=H+16|0;B=H+24|0;C=H+8|0;D=H+12|0;f=(g|0)==0;j=0.0;s=0.0;t=0.0;u=0.0;n=0;g=r;while(1){if((n|0)>=(g<<16>>16|0))break;k=0.0;q=0.0;m=0;p=0.0;j=0.0;i=c[e>>2]|0;while(1){if((m|0)>=(b[i+(n*24|0)+4>>1]|0))break;c[H>>2]=qw(c[(c[i+(n*24|0)>>2]|0)+(m*56|0)>>2]|0,c[E>>2]|0)|0;i=(c[e>>2]|0)+(n*24|0)|0;g=c[(c[i>>2]|0)+(m*56|0)+4>>2]|0;if(!g){h[N>>3]=+h[M>>3];c[I>>2]=c[L>>2];c[G>>2]=c[F>>2];c[x>>2]=c[x>>2]&-128|c[w>>2]&127}else{g=c[g+24>>2]&127;if(!g)g=c[w>>2]&127;c[x>>2]=c[x>>2]&-128|g;r=c[(c[i>>2]|0)+(m*56|0)+4>>2]|0;h[N>>3]=+h[(+h[r+16>>3]>0.0?r:L)+16>>3];c[I>>2]=c[((c[r>>2]|0)==0?L:r)>>2];c[G>>2]=c[((c[r+4>>2]|0)==0?L:r)+4>>2]}i=c[y>>2]|0;c[z>>2]=bb[c[i>>2]&31](i,I,1)|0;pA(J,d,H);Q=+h[J>>3];o=+h[v>>3];_I(c[(c[(c[e>>2]|0)+(n*24|0)>>2]|0)+(m*56|0)>>2]|0);i=c[e>>2]|0;r=c[i+(n*24|0)>>2]|0;c[r+(m*56|0)>>2]=c[H>>2];h[r+(m*56|0)+32>>3]=Q;h[r+(m*56|0)+16>>3]=+h[A>>3];h[r+(m*56|0)+24>>3]=+h[B>>3];c[r+(m*56|0)+4>>2]=c[z>>2];c[r+(m*56|0)+8>>2]=c[C>>2];c[r+(m*56|0)+12>>2]=c[D>>2];P=+h[N>>3];R=+h[B>>3];k=R>k?R:k;q=Q+q;m=m+1|0;p=P>p?P:p;j=o>j?o:j}h[i+(n*24|0)+8>>3]=q;g=(n|0)==0;do if(f)if(g){o=p;k=p-k;g=i;break}else{o=p;k=t-u+p-k;g=i+(n*24|0)|0;break}else{o=j;k=g?p:j;g=i+(n*24|0)|0}while(0);h[g+16>>3]=k;s=q>s?q:s;t=o+t;u=+h[i+(n*24|0)+16>>3]+u;n=n+1|0;g=b[K>>1]|0}h[e+24>>3]=s;h[e+32>>3]=g<<16>>16==1?j:t;l=O;return}function _F(e,f,g){e=e|0;f=f|0;g=g|0;var i=0,j=0,k=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0.0,A=0.0;y=l;l=l+64|0;v=y+32|0;x=y;j=e+24|0;if((c[j>>2]|0)==0?(i=c[(c[e+96>>2]|0)+24>>2]|0,i|0):0)c[j>>2]=GL(i)|0;t=e+36|0;w=b[t>>1]|0;i=w&65535;a:do if(i&1){k=+h[e+64>>3];q=+h[e+72>>3];j=f+16|0;m=+h[j>>3];o=+h[f>>3];n=m-o-k;b:do if(n>0.0)switch(i&6){case 4:{m=o+k;h[j>>3]=m;k=o;break b}case 2:{m=n+m;h[j>>3]=m;k=o+n;h[f>>3]=k;break b}default:{p=n*.5;k=p+o;h[f>>3]=k;m=m-p;h[j>>3]=m;break b}}else k=o;while(0);i=f+24|0;p=+h[i>>3];j=f+8|0;n=+h[j>>3];o=p-n-q;if(o>0.0)switch(w&24){case 16:{o=n+q;h[i>>3]=o;break a}case 8:{q=o+p;h[i>>3]=q;n=n+o;h[j>>3]=n;o=q;break a}default:{o=o*.5;n=o+n;h[j>>3]=n;o=p-o;h[i>>3]=o;break a}}else o=p}else{k=+h[f>>3];n=+h[f+8>>3];m=+h[f+16>>3];o=+h[f+24>>3]}while(0);s=e+48|0;c[s>>2]=c[f>>2];c[s+4>>2]=c[f+4>>2];c[s+8>>2]=c[f+8>>2];c[s+12>>2]=c[f+12>>2];c[s+16>>2]=c[f+16>>2];c[s+20>>2]=c[f+20>>2];c[s+24>>2]=c[f+24>>2];c[s+28>>2]=c[f+28>>2];a[e+35>>0]=g;A=+(d[e+33>>0]|0);z=+(d[e+34>>0]|0);p=k+A+z;h[x>>3]=p;q=n+A+z;s=x+8|0;h[s>>3]=q;n=m-A-z;f=x+16|0;h[f>>3]=n;o=o-A-z;r=x+24|0;h[r>>3]=o;j=e+88|0;switch(a[e+92>>0]|0){case 1:{w=c[j>>2]|0;c[v>>2]=c[x>>2];c[v+4>>2]=c[x+4>>2];c[v+8>>2]=c[x+8>>2];c[v+12>>2]=c[x+12>>2];c[v+16>>2]=c[x+16>>2];c[v+20>>2]=c[x+20>>2];c[v+24>>2]=c[x+24>>2];c[v+28>>2]=c[x+28>>2];YF(w,v,g);break}case 3:{i=c[j>>2]|0;k=+h[i+24>>3];m=n-p-+h[i+16>>3];c:do if(m>0.0)switch(w&6){case 4:{h[f>>3]=n-m;break c}case 2:{h[x>>3]=m+p;break c}default:break c}while(0);k=o-q-k;d:do if(k>0.0)switch(w&24){case 16:{h[r>>3]=o-k;break d}case 8:{h[s>>3]=k+q;break d}default:break d}while(0);c[v>>2]=c[x>>2];c[v+4>>2]=c[x+4>>2];c[v+8>>2]=c[x+8>>2];c[v+12>>2]=c[x+12>>2];c[v+16>>2]=c[x+16>>2];c[v+20>>2]=c[x+20>>2];c[v+24>>2]=c[x+24>>2];c[v+28>>2]=c[x+28>>2];$F(i,v);break}default:{i=c[j>>2]|0;k=+h[i+32>>3];m=n-p-+h[i+24>>3];e:do if(m>0.0?(u=w&6,u<<16>>16!=6):0)switch(u&7){case 4:{h[f>>3]=n-m;break e}case 2:{h[x>>3]=m+p;break e}default:{A=m*.5;h[x>>3]=A+p;h[f>>3]=n-A;break e}}while(0);k=o-q-k;f:do if(k>0.0)switch(w&24){case 16:{h[r>>3]=o-k;break f}case 8:{h[s>>3]=k+q;break f}default:{A=k*.5;h[s>>3]=A+q;h[r>>3]=o-A;break f}}while(0);w=i+8|0;c[w>>2]=c[x>>2];c[w+4>>2]=c[x+4>>2];c[w+8>>2]=c[x+8>>2];c[w+12>>2]=c[x+12>>2];c[w+16>>2]=c[x+16>>2];c[w+20>>2]=c[x+20>>2];c[w+24>>2]=c[x+24>>2];c[w+28>>2]=c[x+28>>2];x=b[t>>1]&768;aG(c[j>>2]|0,(x&1023)==512?108:(x&1023)==256?114:110)}}l=y;return}function $F(a,b){a=a|0;b=b|0;c[a>>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];c[a+12>>2]=c[b+12>>2];c[a+16>>2]=c[b+16>>2];c[a+20>>2]=c[b+20>>2];c[a+24>>2]=c[b+24>>2];c[a+28>>2]=c[b+28>>2];return}function aG(d,e){d=d|0;e=e|0;var f=0,g=0,h=0;g=b[d+4>>1]|0;f=0;while(1){if((f|0)>=(g|0))break;h=(c[d>>2]|0)+(f*24|0)+6|0;if(!(a[h>>0]|0))a[h>>0]=e;f=f+1|0}return}function bG(d,f,g){d=d|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;l=f+84|0;t=c[l>>2]|0;u=wx()|0;v=fG()|0;i=0;h=0;k=Ol(t)|0;while(1){if(!k)break;j=Ol(c[k+8>>2]|0)|0;while(1){if(!j)break;j=c[j>>2]|0;i=i+1|0}h=h+1|0;if(a[k+12>>0]|0)jG(v,h);k=c[k>>2]|0}h=vw((i<<2)+4|0)|0;c[l>>2]=h;i=0;j=0;k=0;q=0;r=Ol(t)|0;while(1){if(!r)break;s=q&65535;p=0;o=Ol(c[r+8>>2]|0)|0;while(1){if(!o)break;n=c[o+8>>2]|0;c[h>>2]=n;k=cG(d,n,f,g)|0|k;l=dG(u,q,p,n)|0;b[n+86>>1]=s;b[n+84>>1]=l;l=l+(e[n+80>>1]|0)|0;m=q+(e[n+82>>1]|0)|0;if(kG(v,m)|0){p=n+100|0;a[p>>0]=a[p>>0]|2}p=l;h=h+4|0;o=c[o>>2]|0;i=(l|0)>(i|0)?l:i;j=(m|0)>(j|0)?m:j}q=q+1|0;r=c[r>>2]|0}c[f+100>>2]=j;c[f+104>>2]=i;Kl(t)|0;Kl(v)|0;zx(u);return k|0}function cG(f,g,i,j){f=f|0;g=g|0;i=i|0;j=j|0;var k=0.0,m=0.0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0.0;u=l;l=l+16|0;t=u+8|0;s=u;c[g+96>>2]=i;q=g+36|0;o=b[q>>1]|0;if(!(o&64)){if(!(b[i+36>>1]&64))n=2;else n=a[i+34>>0]|0;a[g+34>>0]=n}if(!(o&32)){n=a[i+88>>0]|0;if(n<<24>>24<=-1)if(!(b[i+36>>1]&32))n=1;else n=a[i+33>>0]|0;a[g+33>>0]=n}n=g+88|0;p=g+92|0;switch(a[p>>0]|0){case 1:{o=WF(f,c[n>>2]|0,g,j)|0;i=c[n>>2]|0;n=o;o=i+64|0;i=i+72|0;break}case 3:{o=eG(c[n>>2]|0,j)|0;i=c[n>>2]|0;n=o;o=i+16|0;i=i+24|0;break}default:{ZF(c[(c[f+16>>2]|0)+144>>2]|0,c[n>>2]|0,j);i=c[n>>2]|0;n=0;o=i+24|0;i=i+32|0}}k=+((d[g+33>>0]|0)+(d[g+34>>0]|0)<<1|0);m=+h[o>>3]+k;k=+h[i>>3]+k;i=g+38|0;do if(b[q>>1]&1){o=b[i>>1]|0;if(o<<16>>16?(r=b[g+40>>1]|0,r<<16>>16):0){if(!(m>+(o&65535)|k>+(r&65535))){m=0.0;k=0.0;break}if((a[p>>0]|0)==3){m=0.0;k=0.0;break}_l(0,122416,s)|0;n=1;m=0.0;k=0.0;break}_l(0,122449,t)|0;n=1}while(0);v=+(e[i>>1]|0);h[g+64>>3]=m>v?m:v;m=+(e[g+40>>1]|0);h[g+72>>3]=k>m?k:m;l=u;return n|0}function dG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var f=0,g=0,h=0,i=0,j=0;j=d+80|0;i=(e[j>>1]|0)+-1|0;h=0;a:while(1){f=c;while(1){if(h)break a;g=i+f|0;while(1){if((g|0)<(f|0)){c=f;h=1;continue a}if(Ex(a,g,b)|0)break;g=g+-1|0}f=g+1|0}}h=d+82|0;f=c;while(1){if((f|0)<(c+(e[j>>1]|0)|0))g=b;else break;while(1){if((g|0)>=((e[h>>1]|0)+b|0))break;Cx(a,f,g);g=g+1|0}f=f+1|0}return c|0}function eG(b,d){b=b|0;d=d|0;var e=0.0,f=0.0,g=0,i=0,j=0,k=0,m=0;m=l;l=l+16|0;j=m;i=m+8|0;d=d+52|0;g=b+32|0;Pr(i,c[d>>2]|0,c[g>>2]|0);k=c[i>>2]|0;i=c[i+4>>2]|0;if((i&k|0)==-1){c[j>>2]=c[g>>2];_l(1,122499,j)|0;d=1;f=0.0;e=0.0}else{a[(c[(c[d>>2]|0)+16>>2]|0)+114>>0]=1;d=0;f=+(i|0);e=+(k|0)}c[b>>2]=0;c[b+4>>2]=0;c[b+8>>2]=0;c[b+12>>2]=0;h[b+16>>3]=e;h[b+24>>3]=f;l=m;return d|0}function fG(){return Ql(54908,c[4345]|0)|0}function gG(a,b,d){a=a|0;b=b|0;d=d|0;d=vw(12)|0;c[d>>2]=c[b>>2];return d|0}function hG(a,b,c){a=a|0;b=b|0;c=c|0;_I(b);return}function iG(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;b=c[b>>2]|0;e=c[d>>2]|0;return ((b|0)>(e|0)?1:((b|0)<(e|0))<<31>>31)|0}function jG(a,b){a=a|0;b=b|0;var d=0,e=0;d=l;l=l+16|0;e=d;c[e>>2]=b;bb[c[a>>2]&31](a,e,1)|0;l=d;return}function kG(a,b){a=a|0;b=b|0;var d=0,e=0;d=l;l=l+16|0;e=d;c[e>>2]=b;b=(bb[c[a>>2]&31](a,e,512)|0)!=0&1;l=d;return b|0}function lG(a){a=a|0;var b=0;if(!(c[42418]|0)){b=vw((a<<2)+4|0)|0;c[42418]=b;c[b>>2]=169676;c[42429]=a}c[42430]=0;return}function mG(){_I(c[42418]|0);c[42418]=0;c[42430]=0;return}function nG(){c[42430]=0;return}function oG(){var a=0,b=0,d=0;b=c[42430]|0;d=c[42418]|0;a=1;while(1){if((a|0)>(b|0)){a=5;break}if((c[(c[d+(a<<2)>>2]|0)+4>>2]|0)==(a|0))a=a+1|0;else{a=4;break}}if((a|0)==4)ma(123205,122552,59,122558);else if((a|0)==5)return}function pG(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0;f=c[42418]|0;g=c[f+(a<<2)>>2]|0;h=c[g>>2]|0;while(1){b=(a|0)/2|0;d=c[f+(b<<2)>>2]|0;e=f+(a<<2)|0;if((c[d>>2]|0)>=(h|0))break;c[e>>2]=d;c[d+4>>2]=a;a=b}c[e>>2]=g;c[g+4>>2]=a;return}function qG(a){a=a|0;var b=0,d=0;d=l;l=l+16|0;b=c[42430]|0;if((b|0)==(c[42429]|0)){_l(1,122566,d)|0;a=1}else{b=b+1|0;c[42430]=b;c[(c[42418]|0)+(b<<2)>>2]=a;pG(b);oG();a=0}l=d;return a|0}function rG(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;e=c[42418]|0;f=c[e+(a<<2)>>2]|0;g=c[f>>2]|0;h=c[42430]|0;i=(h|0)/2|0;while(1){if((a|0)>(i|0))break;d=a<<1;b=c[e+(d<<2)>>2]|0;if((d|0)<(h|0)){l=d|1;j=c[e+(l<<2)>>2]|0;k=(c[b>>2]|0)<(c[j>>2]|0);d=k?l:d;b=k?j:b}if((g|0)>=(c[b>>2]|0))break;c[e+(a<<2)>>2]=b;c[b+4>>2]=a;a=d}c[e+(a<<2)>>2]=f;c[f+4>>2]=a;return}function sG(){var a=0,b=0,d=0,e=0;b=c[42430]|0;if(!b)a=0;else{e=c[42418]|0;d=e+4|0;a=c[d>>2]|0;c[d>>2]=c[e+(b<<2)>>2];b=b+-1|0;c[42430]=b;if(b|0)rG(1);oG()}return a|0}function tG(a,b){a=a|0;b=b|0;c[a>>2]=b;pG(c[a+4>>2]|0);oG();return}function uG(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;m=b+16|0;j=c[m>>2]|0;j=(a[j+((c[e+12>>2]|0)*40|0)+36>>0]|0)!=(a[j+((c[e+16>>2]|0)*40|0)+36>>0]|0);k=~~((+h[d+64>>3]+-3.0-+h[d+48>>3])*.5);l=~~((+h[d+56>>3]+-3.0-+h[d+40>>3])*.5);g=(k|0)<(l|0)?k:l;n=d+4|0;f=0;while(1){b=c[n>>2]|0;if((f|0)>=(b|0)){g=f;break}i=c[d+8+(f<<2)>>2]|0;o=c[m>>2]|0;if((a[o+((c[i+12>>2]|0)*40|0)+36>>0]|0)==(a[o+((c[i+16>>2]|0)*40|0)+36>>0]|0)){g=f;break}vG(i,g);f=f+1|0}while(1){if((g|0)>=(b|0))break;f=c[d+8+(g<<2)>>2]|0;if(j|(f|0)==(e|0)){vG(f,a[(c[m>>2]|0)+((c[f+12>>2]|0)*40|0)+36>>0]|0?k:l);b=c[n>>2]|0}g=g+1|0}return}function vG(a,b){a=a|0;b=b|0;var d=0,e=0;d=a+8|0;e=c[d>>2]|0;c[d>>2]=e+1;if((e|0)>=(b|0)){c[d>>2]=0;h[a>>3]=+h[a>>3]+16384.0}return}function wG(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0,k=0,m=0,n=0.0,o=0.0,p=0.0,q=0.0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0.0,z=0.0,A=0.0,B=0.0,C=0,D=0,E=0.0;x=l;l=l+112|0;u=x+64|0;t=x+96|0;m=x+32|0;v=x;w=vw(28)|0;b=mn(a)|0;s=w+4|0;c[s>>2]=b;b=vw(b*72|0)|0;r=w+12|0;c[r>>2]=b;e=v+8|0;h[e>>3]=1797693134862315708145274.0e284;h[v>>3]=1797693134862315708145274.0e284;f=v+24|0;h[f>>3]=-1797693134862315708145274.0e284;g=v+16|0;h[g>>3]=-1797693134862315708145274.0e284;i=m+16|0;j=m+8|0;k=m+24|0;d=co(a)|0;n=1797693134862315708145274.0e284;o=1797693134862315708145274.0e284;p=-1797693134862315708145274.0e284;q=-1797693134862315708145274.0e284;while(1){if(!d)break;C=d+16|0;D=c[C>>2]|0;z=(+h[D+96>>3]+ +h[D+88>>3])*.5;z=z<1.0?1.0:z;y=+h[D+80>>3]*.5;y=y<1.0?1.0:y;E=+h[D+16>>3];B=E-z;h[m>>3]=B;z=E+z;h[i>>3]=z;E=+h[D+24>>3];A=E-y;h[j>>3]=A;y=E+y;h[k>>3]=y;B=+h[(n>3];h[v>>3]=B;A=+h[(o>3];h[e>>3]=A;z=+h[(p>z?v:m)+16>>3];h[g>>3]=z;y=+h[(q>y?v:m)+24>>3];h[f>>3]=y;D=b+40|0;c[D>>2]=c[m>>2];c[D+4>>2]=c[m+4>>2];c[D+8>>2]=c[m+8>>2];c[D+12>>2]=c[m+12>>2];c[D+16>>2]=c[m+16>>2];c[D+20>>2]=c[m+20>>2];c[D+24>>2]=c[m+24>>2];c[D+28>>2]=c[m+28>>2];c[b>>2]=c[b>>2]|1;c[(c[C>>2]|0)+112>>2]=b;b=b+72|0;d=eo(a,d)|0;n=B;o=A;p=z;q=y}h[v>>3]=n+-36.0;h[e>>3]=o+-36.0;h[g>>3]=p+36.0;h[f>>3]=q+36.0;D=c[r>>2]|0;f=c[s>>2]|0;c[u>>2]=c[v>>2];c[u+4>>2]=c[v+4>>2];c[u+8>>2]=c[v+8>>2];c[u+12>>2]=c[v+12>>2];c[u+16>>2]=c[v+16>>2];c[u+20>>2]=c[v+20>>2];c[u+24>>2]=c[v+24>>2];c[u+28>>2]=c[v+28>>2];f=GG(D,f,t,u)|0;if(c[42366]&1|0){r=c[r>>2]|0;C=c[s>>2]|0;D=c[t>>2]|0;c[u>>2]=c[v>>2];c[u+4>>2]=c[v+4>>2];c[u+8>>2]=c[v+8>>2];c[u+12>>2]=c[v+12>>2];c[u+16>>2]=c[v+16>>2];c[u+20>>2]=c[v+20>>2];c[u+24>>2]=c[v+24>>2];c[u+28>>2]=c[v+28>>2];xG(r,C,u,f,D)}e=w+8|0;c[e>>2]=vw((c[t>>2]|0)*72|0)|0;c[w>>2]=c[t>>2];d=c[t>>2]|0;b=0;while(1){if((b|0)>=(d|0))break;D=(c[e>>2]|0)+(b*72|0)+40|0;C=f+(b<<5)|0;c[D>>2]=c[C>>2];c[D+4>>2]=c[C+4>>2];c[D+8>>2]=c[C+8>>2];c[D+12>>2]=c[C+12>>2];c[D+16>>2]=c[C+16>>2];c[D+20>>2]=c[C+20>>2];c[D+24>>2]=c[C+24>>2];c[D+28>>2]=c[C+28>>2];b=b+1|0}_I(f);c[u>>2]=c[v>>2];c[u+4>>2]=c[v+4>>2];c[u+8>>2]=c[v+8>>2];c[u+12>>2]=c[v+12>>2];c[u+16>>2]=c[v+16>>2];c[u+20>>2]=c[v+20>>2];c[u+24>>2]=c[v+24>>2];c[u+28>>2]=c[v+28>>2];c[w+16>>2]=yG(w,u)|0;l=x;return w|0}function xG(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0.0,i=0,j=0,k=0.0,m=0.0,n=0.0,o=0,p=0,q=0,r=0,s=0,t=0.0,u=0.0,v=0.0;q=l;l=l+128|0;p=q+96|0;o=q+64|0;j=q+32|0;r=q+16|0;s=q;m=+h[d+16>>3];n=+h[d>>3];k=+h[d+24>>3];g=+h[d+8>>3];i=c[13918]|0;WL(122581,i)|0;c[s>>2]=10;c[s+4>>2]=10;c[s+8>>2]=~~(m+10.0-n);c[s+12>>2]=~~(k+10.0-g);zL(i,123011,s)|0;h[r>>3]=10.0-n;h[r+8>>3]=10.0-g;zL(i,123059,r)|0;WL(123076,i)|0;d=0;while(1){if((d|0)>=(b|0))break;v=+h[a+(d*72|0)+48>>3];u=+h[a+(d*72|0)+56>>3];t=+h[a+(d*72|0)+64>>3];h[j>>3]=+h[a+(d*72|0)+40>>3];h[j+8>>3]=v;h[j+16>>3]=u;h[j+24>>3]=t;zL(i,123095,j)|0;d=d+1|0}WL(123113,i)|0;d=0;while(1){if((d|0)>=(f|0))break;t=+h[e+(d<<5)+8>>3];u=+h[e+(d<<5)+16>>3];v=+h[e+(d<<5)+24>>3];h[o>>3]=+h[e+(d<<5)>>3];h[o+8>>3]=t;h[o+16>>3]=u;h[o+24>>3]=v;zL(i,123132,o)|0;d=d+1|0}WL(123150,i)|0;h[p>>3]=n;h[p+8>>3]=g;h[p+16>>3]=m;h[p+24>>3]=k;zL(i,123132,p)|0;WL(122897,i)|0;l=q;return}function yG(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;A=l;l=l+32|0;t=A+16|0;k=A;w=c[a>>2]|0;y=WC(w<<2|2)|0;z=Ql(54944,c[4345]|0)|0;v=Ql(54980,c[4345]|0)|0;w=vw(w<<7)|0;f=vw(c[a>>2]<<4)|0;x=a+8|0;g=b+16|0;i=k+8|0;j=b+24|0;m=b+8|0;d=0;while(1){if((d|0)>=(c[a>>2]|0))break;n=c[x>>2]|0;o=n+(d*72|0)|0;c[n+(d*72|0)+32>>2]=4;p=n+(d*72|0)+36|0;c[p>>2]=f+(d<<2<<2);q=n+(d*72|0)+40|0;e=+h[n+(d*72|0)+56>>3];if(e<+h[g>>3]){h[k>>3]=e;h[i>>3]=+h[n+(d*72|0)+48>>3];c[t>>2]=c[k>>2];c[t+4>>2]=c[k+4>>2];c[t+8>>2]=c[k+8>>2];c[t+12>>2]=c[k+12>>2];s=zG(y,z,t,w,1)|0;c[s+20>>2]=o;c[c[p>>2]>>2]=s}e=+h[n+(d*72|0)+64>>3];if(e<+h[j>>3]){h[k>>3]=+h[q>>3];h[i>>3]=e;c[t>>2]=c[k>>2];c[t+4>>2]=c[k+4>>2];c[t+8>>2]=c[k+8>>2];c[t+12>>2]=c[k+12>>2];s=zG(y,v,t,w,0)|0;c[s+20>>2]=o;c[(c[p>>2]|0)+4>>2]=s}if(+h[q>>3]>+h[b>>3]){c[t>>2]=c[q>>2];c[t+4>>2]=c[q+4>>2];c[t+8>>2]=c[q+8>>2];c[t+12>>2]=c[q+12>>2];s=zG(y,z,t,w,1)|0;c[s+24>>2]=o;c[(c[p>>2]|0)+8>>2]=s}if(+h[n+(d*72|0)+48>>3]>+h[m>>3]){c[t>>2]=c[q>>2];c[t+4>>2]=c[q+4>>2];c[t+8>>2]=c[q+8>>2];c[t+12>>2]=c[q+12>>2];s=zG(y,v,t,w,0)|0;c[s+24>>2]=o;c[(c[p>>2]|0)+12>>2]=s}d=d+1|0}o=vw(c[y>>2]<<2)|0;r=a+4|0;s=a+12|0;p=t+8|0;m=0;q=0;n=0;while(1){d=c[r>>2]|0;if((n|0)>=(d|0)){b=0;break}g=c[s>>2]|0;i=g+(n*72|0)|0;j=g+(n*72|0)+36|0;c[j>>2]=o+(m<<2);b=g+(n*72|0)+40|0;c[t>>2]=c[b>>2];c[t+4>>2]=c[b+4>>2];c[t+8>>2]=c[b+8>>2];c[t+12>>2]=c[b+12>>2];b=g+(n*72|0)+56|0;k=g+(n*72|0)+32|0;d=bb[c[v>>2]&31](v,t,512)|0;while(1){if(!d)break;if(!(+h[d+8>>3]<+h[b>>3]))break;C=c[d>>2]|0;B=c[j>>2]|0;f=c[k>>2]|0;c[k>>2]=f+1;c[B+(f<<2)>>2]=C;c[(c[d>>2]|0)+24>>2]=i;d=bb[c[v>>2]&31](v,d,8)|0}f=g+(n*72|0)+64|0;d=bb[c[z>>2]&31](z,t,512)|0;while(1){if(!d){u=20;break}e=+h[f>>3];if(!(+h[d+16>>3]>2]|0;B=c[j>>2]|0;C=c[k>>2]|0;c[k>>2]=C+1;c[B+(C<<2)>>2]=b;c[(c[d>>2]|0)+24>>2]=i;d=bb[c[z>>2]&31](z,d,8)|0}if((u|0)==20){u=0;e=+h[f>>3]}h[p>>3]=e;b=g+(n*72|0)+56|0;d=bb[c[v>>2]&31](v,t,512)|0;while(1){if(!d){u=25;break}e=+h[b>>3];if(!(+h[d+8>>3]>2]|0;B=c[j>>2]|0;C=c[k>>2]|0;c[k>>2]=C+1;c[B+(C<<2)>>2]=D;c[(c[d>>2]|0)+20>>2]=i;d=bb[c[v>>2]&31](v,d,8)|0}if((u|0)==25){u=0;e=+h[b>>3]}h[t>>3]=e;h[p>>3]=+h[g+(n*72|0)+48>>3];d=bb[c[z>>2]&31](z,t,512)|0;while(1){if(!d)break;if(!(+h[d+16>>3]<+h[f>>3]))break;B=c[d>>2]|0;C=c[j>>2]|0;D=c[k>>2]|0;c[k>>2]=D+1;c[C+(D<<2)>>2]=B;c[(c[d>>2]|0)+20>>2]=i;d=bb[c[z>>2]&31](z,d,8)|0}D=c[k>>2]|0;m=D+m|0;q=(D|0)>(q|0)?D:q;n=n+1|0}while(1){if((b|0)>=(d|0))break;AG((c[s>>2]|0)+(b*72|0)|0);b=b+1|0;d=c[r>>2]|0}d=c[y>>2]|0;D=c[y+16>>2]|0;c[D+(d*40|0)+32>>2]=d;d=d+1|0;c[D+(d*40|0)+32>>2]=d;VC(y,q);d=0;while(1){if((d|0)>=(c[a>>2]|0))break;BG((c[x>>2]|0)+(d*72|0)|0,y);d=d+1|0}Kl(z)|0;Kl(v)|0;_I(w);CG(y);TC(y);l=A;return y|0}function zG(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0;h=bb[c[d>>2]&31](d,e,512)|0;do if(!h){b=XC(b)|0;if(!f)ma(122994,122942,291,123001);else{h=c[b+32>>2]|0;i=f+(h<<5)|0;f=f+(h<<5)+8|0;c[f>>2]=c[e>>2];c[f+4>>2]=c[e+4>>2];c[f+8>>2]=c[e+8>>2];c[f+12>>2]=c[e+12>>2];c[i>>2]=b;a[b+36>>0]=g;bb[c[d>>2]&31](d,i,1)|0;break}}else i=h;while(0);return c[i>>2]|0}function AG(b){b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0;a:do if((+h[b+64>>3]+-3.0-+h[b+48>>3])*.5<2.0){i=c[b+32>>2]|0;j=b+36|0;g=0;while(1){if((g|0)>=(i|0))break a;d=c[(c[j>>2]|0)+(g<<2)>>2]|0;b:do if(a[d+36>>0]|0){f=c[d+20>>2]|0;if((f|0)==(b|0)){e=c[d+24>>2]|0;d=e;e=c[e>>2]|0;do{c[d>>2]=e|8;d=c[c[d+36>>2]>>2]|0;if(!d)break b;d=c[d+24>>2]|0;e=c[d>>2]|0}while(!(e&1|0))}else{e=f;d=c[f>>2]|0;do{c[e>>2]=d|8;d=c[(c[e+36>>2]|0)+8>>2]|0;if(!d)break b;e=c[d+20>>2]|0;d=c[e>>2]|0}while(!(d&1|0))}}while(0);g=g+1|0}}while(0);c:do if((+h[b+56>>3]+-3.0-+h[b+40>>3])*.5<2.0){i=c[b+32>>2]|0;j=b+36|0;g=0;while(1){if((g|0)>=(i|0))break c;d=c[(c[j>>2]|0)+(g<<2)>>2]|0;d:do if(!(a[d+36>>0]|0)){f=c[d+20>>2]|0;if((f|0)==(b|0)){e=c[d+24>>2]|0;d=e;e=c[e>>2]|0;do{c[d>>2]=e|16;d=c[(c[d+36>>2]|0)+4>>2]|0;if(!d)break d;d=c[d+24>>2]|0;e=c[d>>2]|0}while(!(e&1|0))}else{e=f;d=c[f>>2]|0;do{c[e>>2]=d|16;d=c[(c[e+36>>2]|0)+12>>2]|0;if(!d)break d;e=c[d+20>>2]|0;d=c[e>>2]|0}while(!(d&1|0))}}while(0);g=g+1|0}}while(0);return}function BG(a,b){a=a|0;b=b|0;var d=0,e=0,f=0.0,g=0.0,i=0.0,j=0,k=0,l=0,m=0,n=0,o=0,p=0.0,q=0;g=+h[a+56>>3]-+h[a+40>>3];i=+h[a+64>>3]-+h[a+48>>3];f=(i+g)*.5+500.0;if((i+-3.0)*.5<2.0){l=(c[a>>2]&8|0)==0;f=l?16384.0:f;p=l?16384.0:g}else p=g;if((g+-3.0)*.5<2.0){l=(c[a>>2]&16|0)==0;i=l?16384.0:i;f=l?16384.0:f}l=a+36|0;d=c[l>>2]|0;e=c[d+8>>2]|0;if((e|0)!=0?(j=c[d+4>>2]|0,(j|0)!=0):0){j=YC(b,e,j,f)|0;e=a+4|0;d=c[e>>2]|0;c[e>>2]=d+1;c[a+8+(d<<2)>>2]=j;d=c[l>>2]|0}e=c[d+4>>2]|0;if((e|0)!=0?(k=c[d>>2]|0,(k|0)!=0):0){k=YC(b,e,k,f)|0;j=a+4|0;d=c[j>>2]|0;c[j>>2]=d+1;c[a+8+(d<<2)>>2]=k;d=c[l>>2]|0}e=c[d+8>>2]|0;if((e|0)!=0?(m=c[d+12>>2]|0,(m|0)!=0):0){m=YC(b,e,m,f)|0;k=a+4|0;d=c[k>>2]|0;c[k>>2]=d+1;c[a+8+(d<<2)>>2]=m;d=c[l>>2]|0}e=c[d+12>>2]|0;if((e|0)!=0?(n=c[d>>2]|0,(n|0)!=0):0){n=YC(b,e,n,f)|0;m=a+4|0;d=c[m>>2]|0;c[m>>2]=d+1;c[a+8+(d<<2)>>2]=n;d=c[l>>2]|0}e=c[d+4>>2]|0;if((e|0)!=0?(o=c[d+12>>2]|0,(o|0)!=0):0){o=YC(b,e,o,i)|0;n=a+4|0;d=c[n>>2]|0;c[n>>2]=d+1;c[a+8+(d<<2)>>2]=o;d=c[l>>2]|0}e=c[d+8>>2]|0;if(e|0?(q=c[d>>2]|0,q|0):0){b=YC(b,e,q,p)|0;o=a+4|0;q=c[o>>2]|0;c[o>>2]=q+1;c[a+8+(q<<2)>>2]=b}return}function CG(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;j=l;l=l+16|0;i=j+8|0;h=j;f=a+16|0;g=c[13918]|0;e=0;while(1){if((e|0)>=(c[a>>2]|0)){b=10;break}b=c[f>>2]|0;d=b+(e*40|0)+20|0;if((c[d>>2]|0)==0?(c[h>>2]=e,zL(g,122907,h)|0,(c[d>>2]|0)==0):0){b=5;break}b=b+(e*40|0)+24|0;if((c[b>>2]|0)==0?(c[i>>2]=e,zL(g,122959,i)|0,(c[b>>2]|0)==0):0){b=8;break}e=e+1|0}if((b|0)==5)ma(122929,122942,311,122949);else if((b|0)==8)ma(122981,122942,313,122949);else if((b|0)==10){l=j;return}}function DG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0.0,f=0.0;e=+h[b+8>>3];f=+h[c+8>>3];if(!(e>f))if(!(e>3];e=+h[c>>3];if(f>e)a=1;else a=(f>31}else a=-1;else a=1;return a|0}function EG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0.0,f=0.0;e=+h[b>>3];f=+h[c>>3];if(!(e>f))if(!(e>3];e=+h[c+8>>3];if(f>e)a=1;else a=(f>31}else a=-1;else a=1;return a|0}function FG(a){a=a|0;var b=0,d=0;d=a+8|0;_I(c[(c[d>>2]|0)+36>>2]|0);b=a+12|0;_I(c[(c[b>>2]|0)+36>>2]|0);_I(c[d>>2]|0);_I(c[b>>2]|0);_C(c[a+16>>2]|0);Kl(c[a+20>>2]|0)|0;Kl(c[a+24>>2]|0)|0;_I(a);return}function GG(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0;p=l;l=l+32|0;h=p;i=b<<2;f=i+4|0;i=i+5|0;o=ww(i*56|0)|0;i=vw(i<<2)|0;g=f*5|1;j=ww(g*72|0)|0;m=g<<5;k=vw(m)|0;m=vw(m)|0;c[h>>2]=c[e>>2];c[h+4>>2]=c[e+4>>2];c[h+8>>2]=c[e+8>>2];c[h+12>>2]=c[e+12>>2];c[h+16>>2]=c[e+16>>2];c[h+20>>2]=c[e+20>>2];c[h+24>>2]=c[e+24>>2];c[h+28>>2]=c[e+28>>2];HG(a,b,h,o,0);yM(173);IG(f,i);SG(f,o,i,g,j)|0;n=JG(f,o,j,0,k)|0;c[h>>2]=c[e>>2];c[h+4>>2]=c[e+4>>2];c[h+8>>2]=c[e+8>>2];c[h+12>>2]=c[e+12>>2];c[h+16>>2]=c[e+16>>2];c[h+20>>2]=c[e+20>>2];c[h+24>>2]=c[e+24>>2];c[h+28>>2]=c[e+28>>2];HG(a,b,h,o,1);IG(f,i);SG(f,o,i,g,j)|0;f=JG(f,o,j,1,m)|0;g=vw(O(n<<5,f)|0)|0;b=0;a=0;while(1){if((b|0)>=(f|0))break;h=m+(b<<5)|0;e=0;while(1){if((e|0)>=(n|0))break;q=a+((KG(g+(a<<5)|0,h,k+(e<<5)|0)|0)!=0&1)|0;e=e+1|0;a=q}b=b+1|0}q=yw(g,a<<5)|0;_I(o);_I(i);_I(j);_I(k);_I(m);c[d>>2]=a;l=p;return q|0}function HG(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0;j=l;l=l+96|0;h=j+64|0;i=j;c[h>>2]=c[d>>2];c[h+4>>2]=c[d+4>>2];c[h+8>>2]=c[d+8>>2];c[h+12>>2]=c[d+12>>2];c[h+16>>2]=c[d+16>>2];c[h+20>>2]=c[d+20>>2];c[h+24>>2]=c[d+24>>2];c[h+28>>2]=c[d+28>>2];QG(h,f,1,i);d=RG(e,1,i)|0;g=0;while(1){if((g|0)>=(b|0))break;k=a+(g*72|0)+40|0;c[h>>2]=c[k>>2];c[h+4>>2]=c[k+4>>2];c[h+8>>2]=c[k+8>>2];c[h+12>>2]=c[k+12>>2];c[h+16>>2]=c[k+16>>2];c[h+20>>2]=c[k+20>>2];c[h+24>>2]=c[k+24>>2];c[h+28>>2]=c[k+28>>2];QG(h,f,0,i);d=RG(e,d,i)|0;g=g+1|0}l=j;return}function IG(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;d=0;while(1){if((d|0)>(a|0))break;c[b+(d<<2)>>2]=d;d=d+1|0}g=a+1|0;d=1;while(1){if((d|0)>(a|0))break;h=~~(+AM()*+(g-d|0)+ +(d|0));e=b+(d<<2)|0;f=b+(h<<2)|0;if((d|0)!=(h|0)){h=c[e>>2]|0;c[e>>2]=c[f>>2];c[f>>2]=h}d=d+1|0}return}function JG(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;g=a*5|0;j=g+1|0;l=vw(j<<2)|0;c[42431]=vw(j<<4)|0;c[42432]=vw((a*56|0)+56|0)|0;j=vw(a<<2)|0;c[42433]=j;k=0;while(1){if((k|0)>(g|0))break;if(LG(d+(k*72|0)|0,b)|0)break;k=k+1|0}h=c[42431]|0;i=c[42432]|0;g=1;while(1){if((g|0)>(a|0))break;c[h+(g<<4)+8>>2]=c[b+(g*56|0)+48>>2];m=b+(g*56|0)+44|0;c[h+(g<<4)+4>>2]=c[m>>2];c[h+(g<<4)>>2]=g;n=i+(g*56|0)|0;o=b+(g*56|0)|0;c[n>>2]=c[o>>2];c[n+4>>2]=c[o+4>>2];c[n+8>>2]=c[o+8>>2];c[n+12>>2]=c[o+12>>2];c[i+(g*56|0)+16>>2]=c[m>>2];c[i+(g*56|0)+32>>2]=g;c[i+(g*56|0)+48>>2]=1;g=g+1|0}c[42434]=a;c[42435]=0;c[j>>2]=1;g=c[d+(k*72|0)+40>>2]|0;if((g|0)<=0){g=c[d+(k*72|0)+48>>2]|0;if((g|0)>0)g=MG(l,f,0,b,d,0,k,g,e,2)|0;else g=0}else g=MG(l,f,0,b,d,0,k,g,e,1)|0;_I(l);_I(c[42431]|0);_I(c[42432]|0);_I(c[42433]|0);return g|0}function KG(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0,g=0.0;g=+h[(+h[b>>3]>+h[c>>3]?b:c)>>3];f=+h[(+h[b+16>>3]<+h[c+16>>3]?b:c)+16>>3];h[a+16>>3]=f;h[a>>3]=g;e=+h[(+h[b+8>>3]>+h[c+8>>3]?b:c)+8>>3];d=+h[(+h[b+24>>3]<+h[c+24>>3]?b:c)+24>>3];h[a+24>>3]=d;h[a+8>>3]=e;return !(g>=f)&!(e>=d)&1|0}function LG(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0;f=c[a+4>>2]|0;do if((c[a+68>>2]|0)!=2?!((f|0)<1|(c[a>>2]|0)<1):0){if(!((c[a+40>>2]|0)<1?(c[a+44>>2]|0)<1:0)){if((c[a+48>>2]|0)>=1){a=0;break}if((c[a+52>>2]|0)>=1){a=0;break}}d=+h[b+(f*56|0)+24>>3];e=+h[b+(f*56|0)+8>>3];if(!(d>e+1.0e-07))if(d>3]>+h[b+(f*56|0)>>3]&1;else a=1}else a=0;while(0);return a|0}function MG(a,b,d,e,f,g,i,j,k,l){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;i=i|0;j=j|0;k=k|0;l=l|0;var m=0,n=0,o=0.0,p=0.0,q=0.0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0.0,J=0,K=0.0,L=0,M=0,N=0,O=0,P=0;D=(k|0)==0;C=i;a:while(1){y=f+(C*72|0)|0;if((C|0)<1)break;i=a+(C<<2)|0;if(c[i>>2]|0)break;c[i>>2]=1;v=f+(C*72|0)+8|0;t=f+(C*72|0)+16|0;p=+h[t>>3];w=f+(C*72|0)+24|0;x=f+(C*72|0)+32|0;o=+h[x>>3];if((p>o?(A=c[y>>2]|0,I=+h[e+(A*56|0)>>3],I==+h[e+(A*56|0)+16>>3]):0)?(A=c[f+(C*72|0)+4>>2]|0,K=+h[e+(A*56|0)>>3],K==+h[e+(A*56|0)+16>>3]):0){i=b+(d<<5)|0;if(D){h[i>>3]=I;q=p;p=K}else{h[i>>3]=o;q=-I;o=-K}h[b+(d<<5)+8>>3]=o;h[b+(d<<5)+16>>3]=p;h[b+(d<<5)+24>>3]=q;d=d+1|0}i=f+(C*72|0)+40|0;z=c[i>>2]|0;do if((z|0)<1?(L=f+(C*72|0)+44|0,(c[L>>2]|0)<1):0){i=f+(C*72|0)+48|0;n=f+(C*72|0)+52|0;if((c[i>>2]|0)>0?(M=c[n>>2]|0,(M|0)>0):0){m=c[f+(M*72|0)>>2]|0;l=c[y>>2]|0;if((M|0)==(j|0)){l=NG(g,l,m)|0;d=MG(a,b,d,e,f,g,c[n>>2]|0,C,k,1)|0;g=l;l=1;break}else{l=NG(g,m,l)|0;d=MG(a,b,d,e,f,g,c[i>>2]|0,C,k,1)|0;g=l;i=n;l=1;break}}d=MG(a,b,d,e,f,g,z,C,k,2)|0;d=MG(a,b,d,e,f,g,c[L>>2]|0,C,k,2)|0;d=MG(a,b,d,e,f,g,c[i>>2]|0,C,k,1)|0;i=n;l=1}else P=19;while(0);do if((P|0)==19){P=0;A=f+(C*72|0)+48|0;r=c[A>>2]|0;if((r|0)<1?(N=f+(C*72|0)+52|0,(c[N>>2]|0)<1):0){n=f+(C*72|0)+44|0;if((z|0)>0?(O=c[n>>2]|0,(O|0)>0):0){m=c[f+(C*72|0)+4>>2]|0;l=c[f+(z*72|0)+4>>2]|0;if((O|0)==(j|0)){l=NG(g,l,m)|0;d=MG(a,b,d,e,f,g,c[n>>2]|0,C,k,2)|0;g=l;l=2;break}else{l=NG(g,m,l)|0;d=MG(a,b,d,e,f,g,c[i>>2]|0,C,k,2)|0;g=l;i=n;l=2;break}}d=MG(a,b,d,e,f,g,z,C,k,2)|0;d=MG(a,b,d,e,f,g,c[n>>2]|0,C,k,2)|0;d=MG(a,b,d,e,f,g,c[A>>2]|0,C,k,1)|0;i=N;l=1;break}u=f+(C*72|0)+44|0;s=c[u>>2]|0;m=(s|0)>0;if((z|0)>0){if(m){if((r|0)>0?(E=f+(C*72|0)+52|0,F=c[E>>2]|0,(F|0)>0):0){n=c[f+(F*72|0)>>2]|0;m=c[f+(z*72|0)+4>>2]|0;if(!((l|0)==2&(F|0)==(j|0))?!((l|0)==1&(s|0)==(j|0)):0){l=NG(g,n,m)|0;d=MG(a,b,d,e,f,g,c[i>>2]|0,C,k,2)|0;d=MG(a,b,d,e,f,g,c[A>>2]|0,C,k,1)|0;d=MG(a,b,d,e,f,l,c[u>>2]|0,C,k,2)|0;g=l;i=E;l=1;break}l=NG(g,m,n)|0;d=MG(a,b,d,e,f,g,c[u>>2]|0,C,k,2)|0;d=MG(a,b,d,e,f,g,c[E>>2]|0,C,k,1)|0;d=MG(a,b,d,e,f,l,c[i>>2]|0,C,k,2)|0;g=l;i=A;l=1;break}m=c[y>>2]|0;if(+B(+(+h[x>>3]-+h[e+(m*56|0)+24>>3]))<=1.0e-07?+B(+(+h[w>>3]-+h[e+(m*56|0)+16>>3]))<=1.0e-07:0){n=c[f+(z*72|0)+4>>2]|0;m=c[e+(m*56|0)+44>>2]|0;if((l|0)==1&(z|0)==(j|0)){l=NG(g,m,n)|0;d=MG(a,b,d,e,f,g,c[i>>2]|0,C,k,2)|0;d=MG(a,b,d,e,f,l,c[A>>2]|0,C,k,1)|0;d=MG(a,b,d,e,f,l,c[u>>2]|0,C,k,2)|0;g=l;i=f+(C*72|0)+52|0;l=1;break}else{l=NG(g,n,m)|0;d=MG(a,b,d,e,f,g,c[u>>2]|0,C,k,2)|0;d=MG(a,b,d,e,f,g,c[A>>2]|0,C,k,1)|0;d=MG(a,b,d,e,f,g,c[f+(C*72|0)+52>>2]|0,C,k,1)|0;g=l;l=2;break}}n=c[f+(C*72|0)+4>>2]|0;m=c[f+(z*72|0)+4>>2]|0;if((l|0)==1&(s|0)==(j|0)){l=NG(g,m,n)|0;d=MG(a,b,d,e,f,g,c[u>>2]|0,C,k,2)|0;d=MG(a,b,d,e,f,l,c[f+(C*72|0)+52>>2]|0,C,k,1)|0;d=MG(a,b,d,e,f,l,c[A>>2]|0,C,k,1)|0;g=l;l=2;break}else{l=NG(g,n,m)|0;d=MG(a,b,d,e,f,g,c[i>>2]|0,C,k,2)|0;d=MG(a,b,d,e,f,g,c[A>>2]|0,C,k,1)|0;d=MG(a,b,d,e,f,g,c[f+(C*72|0)+52>>2]|0,C,k,1)|0;g=l;i=u;l=2;break}}}else if(!m)break a;if((r|0)>0?(G=f+(C*72|0)+52|0,H=c[G>>2]|0,(H|0)>0):0){n=c[y>>2]|0;if(+B(+(+h[t>>3]-+h[e+(n*56|0)+8>>3]))<=1.0e-07?+B(+(+h[v>>3]-+h[e+(n*56|0)>>3]))<=1.0e-07:0){m=c[f+(H*72|0)>>2]|0;if((l|0)==2&(r|0)==(j|0)){l=NG(g,m,n)|0;d=MG(a,b,d,e,f,g,c[A>>2]|0,C,k,1)|0;d=MG(a,b,d,e,f,l,c[i>>2]|0,C,k,2)|0;d=MG(a,b,d,e,f,l,c[f+(C*72|0)+44>>2]|0,C,k,2)|0;g=l;i=G;l=1;break}else{l=NG(g,n,m)|0;d=MG(a,b,d,e,f,g,c[f+(C*72|0)+44>>2]|0,C,k,2)|0;d=MG(a,b,d,e,f,g,c[G>>2]|0,C,k,1)|0;d=MG(a,b,d,e,f,g,c[i>>2]|0,C,k,2)|0;g=l;i=A;l=1;break}}m=c[f+(H*72|0)>>2]|0;n=c[e+((c[f+(C*72|0)+4>>2]|0)*56|0)+44>>2]|0;if((l|0)==2&(H|0)==(j|0)){l=NG(g,n,m)|0;d=MG(a,b,d,e,f,g,c[G>>2]|0,C,k,1)|0;d=MG(a,b,d,e,f,l,c[f+(C*72|0)+44>>2]|0,C,k,2)|0;d=MG(a,b,d,e,f,l,c[i>>2]|0,C,k,2)|0;g=l;i=A;l=1;break}else{l=NG(g,m,n)|0;d=MG(a,b,d,e,f,g,c[i>>2]|0,C,k,2)|0;d=MG(a,b,d,e,f,g,c[A>>2]|0,C,k,1)|0;d=MG(a,b,d,e,f,g,c[f+(C*72|0)+44>>2]|0,C,k,2)|0;g=l;i=G;l=1;break}}o=+h[t>>3];n=c[y>>2]|0;if(((+B(+(o-+h[e+(n*56|0)+8>>3]))<=1.0e-07?+B(+(+h[v>>3]-+h[e+(n*56|0)>>3]))<=1.0e-07:0)?(J=c[f+(C*72|0)+4>>2]|0,+B(+(+h[x>>3]-+h[e+(J*56|0)+8>>3]))<=1.0e-07):0)?+B(+(+h[w>>3]-+h[e+(J*56|0)>>3]))<=1.0e-07:0)if((l|0)==1){l=NG(g,n,J)|0;d=MG(a,b,d,e,f,g,c[i>>2]|0,C,k,2)|0;d=MG(a,b,d,e,f,g,c[f+(C*72|0)+44>>2]|0,C,k,2)|0;d=MG(a,b,d,e,f,l,c[f+(C*72|0)+52>>2]|0,C,k,1)|0;g=l;i=A;l=1;break}else{l=NG(g,J,n)|0;d=MG(a,b,d,e,f,g,c[f+(C*72|0)+52>>2]|0,C,k,1)|0;d=MG(a,b,d,e,f,g,c[A>>2]|0,C,k,1)|0;d=MG(a,b,d,e,f,l,c[i>>2]|0,C,k,2)|0;g=l;i=f+(C*72|0)+44|0;l=2;break}j=c[f+(C*72|0)+4>>2]|0;if(((+B(+(o-+h[e+(j*56|0)+24>>3]))<=1.0e-07?+B(+(+h[v>>3]-+h[e+(j*56|0)+16>>3]))<=1.0e-07:0)?+B(+(+h[x>>3]-+h[e+(n*56|0)+24>>3]))<=1.0e-07:0)?+B(+(+h[w>>3]-+h[e+(n*56|0)+16>>3]))<=1.0e-07:0){m=c[e+(j*56|0)+44>>2]|0;j=c[e+(n*56|0)+44>>2]|0;if((l|0)==1){l=NG(g,j,m)|0;d=MG(a,b,d,e,f,g,c[i>>2]|0,C,k,2)|0;d=MG(a,b,d,e,f,g,c[f+(C*72|0)+44>>2]|0,C,k,2)|0;d=MG(a,b,d,e,f,l,c[f+(C*72|0)+52>>2]|0,C,k,1)|0;g=l;i=A;l=1;break}else{l=NG(g,m,j)|0;d=MG(a,b,d,e,f,g,c[f+(C*72|0)+52>>2]|0,C,k,1)|0;d=MG(a,b,d,e,f,g,c[A>>2]|0,C,k,1)|0;d=MG(a,b,d,e,f,l,c[i>>2]|0,C,k,2)|0;g=l;i=f+(C*72|0)+44|0;l=2;break}}d=MG(a,b,d,e,f,g,z,C,k,2)|0;d=MG(a,b,d,e,f,g,c[A>>2]|0,C,k,1)|0;d=MG(a,b,d,e,f,g,c[f+(C*72|0)+44>>2]|0,C,k,2)|0;i=f+(C*72|0)+52|0;l=1}while(0);j=C;C=c[i>>2]|0}return d|0}function NG(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0;f=l;l=l+16|0;r=f+4|0;i=f;e=(c[42435]|0)+1|0;c[42435]=e;m=c[42432]|0;OG(b,d,r,i);r=c[r>>2]|0;h=c[m+(b*56|0)+32+(r<<2)>>2]|0;i=c[m+(d*56|0)+32+(c[i>>2]<<2)>>2]|0;n=c[42434]|0;g=n+1|0;n=n+2|0;c[42434]=n;q=c[42431]|0;c[q+(g<<4)>>2]=b;c[q+(n<<4)>>2]=d;o=q+(h<<4)+4|0;p=q+(g<<4)+4|0;c[p>>2]=c[o>>2];c[q+(c[o>>2]<<4)+8>>2]=g;c[q+(g<<4)+8>>2]=n;c[q+(n<<4)+4>>2]=g;j=q+(i<<4)+8|0;c[q+(n<<4)+8>>2]=c[j>>2];c[q+(c[j>>2]<<4)+4>>2]=n;c[o>>2]=i;c[j>>2]=h;j=m+(b*56|0)+48|0;o=c[j>>2]|0;i=m+(d*56|0)+48|0;k=c[i>>2]|0;c[m+(b*56|0)+16+(r<<2)>>2]=d;c[m+(b*56|0)+32+(o<<2)>>2]=g;c[m+(b*56|0)+16+(o<<2)>>2]=c[q+(c[p>>2]<<4)>>2];c[m+(d*56|0)+32+(k<<2)>>2]=n;c[m+(d*56|0)+16+(k<<2)>>2]=b;c[j>>2]=(c[j>>2]|0)+1;c[i>>2]=(c[i>>2]|0)+1;d=c[42433]|0;c[d+(a<<2)>>2]=h;c[d+(e<<2)>>2]=g;l=f;return e|0}function OG(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0.0,h=0,i=0,j=0.0,k=0.0,l=0,m=0,n=0;l=c[42432]|0;m=l+(a*56|0)|0;n=l+(b*56|0)|0;f=0;g=-4.0;i=0;while(1){if((i|0)==4)break;h=c[l+(a*56|0)+16+(i<<2)>>2]|0;if((h|0)>=1?(j=+PG(m,l+(h*56|0)|0,n),j>g):0){f=i;g=j}i=i+1|0}c[d>>2]=f;f=0;i=0;g=-4.0;while(1){if((i|0)==4)break;h=c[l+(b*56|0)+16+(i<<2)>>2]|0;if((h|0)>=1?(k=+PG(n,l+(h*56|0)|0,m),k>g):0){f=i;g=k}i=i+1|0}c[e>>2]=f;return}function PG(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0,g=0.0,i=0.0;g=+h[a>>3];i=+h[b>>3]-g;d=+h[a+8>>3];f=+h[b+8>>3]-d;g=+h[c>>3]-g;d=+h[c+8>>3]-d;e=d*f+g*i;if(!(d*i-g*f>=0.0))d=-e/(+C(+(d*d+g*g))*+C(+(f*f+i*i)))+-2.0;else d=e/(+C(+(d*d+g*g))*+C(+(f*f+i*i)));return +d}function QG(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0.0,l=0.0;c[e>>2]=c[a>>2];c[e+4>>2]=c[a+4>>2];c[e+8>>2]=c[a+8>>2];c[e+12>>2]=c[a+12>>2];i=e+32|0;j=a+16|0;c[i>>2]=c[j>>2];c[i+4>>2]=c[j+4>>2];c[i+8>>2]=c[j+8>>2];c[i+12>>2]=c[j+12>>2];if(!d){f=a+8|0;g=j;i=a+24|0;d=a}else{f=a+24|0;g=a;i=a+8|0;d=j}k=+h[g>>3];l=+h[i>>3];h[e+16>>3]=+h[d>>3];h[e+24>>3]=l;h[e+48>>3]=k;h[e+56>>3]=+h[f>>3];a:do if(b|0){d=0;while(1){if((d|0)==4)break a;j=e+(d<<4)+8|0;l=+h[j>>3];b=e+(d<<4)|0;h[j>>3]=+h[b>>3];h[b>>3]=-l;d=d+1|0}}while(0);return}function RG(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;h=b+3|0;i=b+1|0;j=b+2|0;k=a+(b*56|0)+44|0;l=a+(h*56|0)+44|0;e=0;f=b;while(1){if((f|0)>(h|0))break;do if((f|0)!=(b|0))if((f|0)==(h|0)){c[l>>2]=b;g=j;break}else{c[a+(f*56|0)+44>>2]=f+1;g=f+-1|0;break}else{c[k>>2]=i;g=h}while(0);c[a+(f*56|0)+48>>2]=g;c[a+(f*56|0)+32>>2]=0;n=a+(f*56|0)|0;m=d+(e<<4)|0;c[n>>2]=c[m>>2];c[n+4>>2]=c[m+4>>2];c[n+8>>2]=c[m+8>>2];c[n+12>>2]=c[m+12>>2];UN(a+(g*56|0)+16|0,m|0,16)|0;e=e+1|0;f=f+1|0}return b+4|0}function SG(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0;c[42436]=e<<1;c[42437]=e;k=vw(e*80|0)|0;c[42438]=1;c[42439]=1;VN(f|0,0,e*72|0)|0;g=TG(c[d+4>>2]|0,b,f,k)|0;e=1;while(1){if((e|0)>(a|0))break;c[b+(e*56|0)+40>>2]=g;c[b+(e*56|0)+36>>2]=g;e=e+1|0}j=UG(a)|0;g=2;i=1;while(1){if((i|0)>(j|0))break;e=VG(a,i+-1|0)|0;h=VG(a,i)|0;while(1){if((e|0)>=(h|0)){e=1;break}WG(c[d+(g<<2)>>2]|0,b,f,k);e=e+1|0;g=g+1|0}while(1){if((e|0)>(a|0))break;XG(e,b,f,k);e=e+1|0}i=i+1|0}e=VG(a,j)|0;while(1){if((e|0)>=(a|0))break;WG(c[d+(g<<2)>>2]|0,b,f,k);g=g+1|0;e=e+1|0}_I(k);return c[42438]|0}function TG(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;f=aH()|0;c[e+(f*40|0)>>2]=2;s=e+(f*40|0)+8|0;k=b+(a*56|0)|0;l=b+(a*56|0)+16|0;eH(s,k,l);n=aH()|0;c[e+(f*40|0)+36>>2]=n;c[e+(n*40|0)>>2]=3;c[e+(n*40|0)+28>>2]=f;j=aH()|0;c[e+(f*40|0)+32>>2]=j;c[e+(j*40|0)>>2]=2;r=e+(j*40|0)+8|0;fH(r,k,l);c[e+(j*40|0)+28>>2]=f;l=aH()|0;c[e+(j*40|0)+32>>2]=l;c[e+(l*40|0)>>2]=3;c[e+(l*40|0)+28>>2]=j;k=aH()|0;c[e+(j*40|0)+36>>2]=k;c[e+(k*40|0)>>2]=1;c[e+(k*40|0)+4>>2]=a;c[e+(k*40|0)+28>>2]=j;j=aH()|0;c[e+(k*40|0)+32>>2]=j;c[e+(j*40|0)>>2]=3;c[e+(j*40|0)+28>>2]=k;g=aH()|0;c[e+(k*40|0)+36>>2]=g;c[e+(g*40|0)>>2]=3;c[e+(g*40|0)+28>>2]=k;k=$G(d)|0;i=$G(d)|0;m=$G(d)|0;o=$G(d)|0;p=d+(k*72|0)+8|0;q=d+(i*72|0)+8|0;t=d+(o*72|0)+24|0;c[t>>2]=c[s>>2];c[t+4>>2]=c[s+4>>2];c[t+8>>2]=c[s+8>>2];c[t+12>>2]=c[s+12>>2];UN(q|0,s|0,16)|0;c[p>>2]=c[q>>2];c[p+4>>2]=c[q+4>>2];c[p+8>>2]=c[q+8>>2];c[p+12>>2]=c[q+12>>2];p=d+(k*72|0)+24|0;q=d+(i*72|0)+24|0;s=d+(m*72|0)+8|0;c[s>>2]=c[r>>2];c[s+4>>2]=c[r+4>>2];c[s+8>>2]=c[r+8>>2];c[s+12>>2]=c[r+12>>2];UN(q|0,r|0,16)|0;c[p>>2]=c[q>>2];c[p+4>>2]=c[q+4>>2];c[p+8>>2]=c[q+8>>2];c[p+12>>2]=c[q+12>>2];h[d+(o*72|0)+16>>3]=1073741824.0;h[d+(o*72|0)+8>>3]=1073741824.0;h[d+(m*72|0)+32>>3]=-1073741824.0;h[d+(m*72|0)+24>>3]=-1073741824.0;c[d+(i*72|0)>>2]=a;c[d+(k*72|0)+4>>2]=a;c[d+(i*72|0)+40>>2]=o;c[d+(k*72|0)+40>>2]=o;c[d+(i*72|0)+48>>2]=m;c[d+(k*72|0)+48>>2]=m;c[d+(m*72|0)+40>>2]=k;c[d+(o*72|0)+48>>2]=k;c[d+(m*72|0)+44>>2]=i;c[d+(o*72|0)+52>>2]=i;c[d+(k*72|0)+56>>2]=j;c[d+(i*72|0)+56>>2]=g;c[d+(m*72|0)+56>>2]=l;c[d+(o*72|0)+56>>2]=n;c[d+(i*72|0)+68>>2]=1;c[d+(k*72|0)+68>>2]=1;c[d+(o*72|0)+68>>2]=1;c[d+(m*72|0)+68>>2]=1;c[e+(n*40|0)+24>>2]=o;c[e+(l*40|0)+24>>2]=m;c[e+(j*40|0)+24>>2]=k;c[e+(g*40|0)+24>>2]=i;c[b+(a*56|0)+32>>2]=1;return f|0}function UG(a){a=a|0;var b=0.0;b=+(a|0);a=0;while(1){if(!(b>=1.0))break;b=+CJ(b);a=a+1|0}return a+-1|0}function VG(a,b){a=a|0;b=b|0;var c=0.0,d=0.0;d=+(a|0);c=d;a=0;while(1){if((a|0)>=(b|0))break;c=+CJ(c);a=a+1|0}return ~~+N(+(d/c))|0}function WG(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0.0,j=0.0,k=0,m=0,n=0,o=0,p=0,q=0.0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0;W=l;l=l+96|0;S=W+32|0;f=W+16|0;T=W;s=S;k=b+(a*56|0)|0;r=s+56|0;do{c[s>>2]=c[k>>2];s=s+4|0;k=k+4|0}while((s|0)<(r|0));U=S+16|0;V=S+24|0;i=+h[V>>3];H=S+8|0;j=+h[H>>3];do if(!(i>j+1.0e-07)){if(!(i>3]>+h[S>>3]:0){G=4;break}G=(_G(a,b,1)|0)==0;f=c[S+36>>2]|0;if(G){n=0;G=7}else{f=YG(S,U,f,b,e)|0;G=20}}else G=4;while(0);if((G|0)==4){c[f>>2]=c[S>>2];c[f+4>>2]=c[S+4>>2];c[f+8>>2]=c[S+8>>2];c[f+12>>2]=c[S+12>>2];c[S>>2]=c[U>>2];c[S+4>>2]=c[U+4>>2];c[S+8>>2]=c[U+8>>2];c[S+12>>2]=c[U+12>>2];c[U>>2]=c[f>>2];c[U+4>>2]=c[f+4>>2];c[U+8>>2]=c[f+8>>2];c[U+12>>2]=c[f+12>>2];E=S+36|0;F=c[E>>2]|0;G=S+40|0;f=c[G>>2]|0;c[E>>2]=f;c[G>>2]=F;if(!(_G(a,b,2)|0)){n=1;G=7}else{f=YG(S,U,f,b,e)|0;G=19}}if((G|0)==7){m=YG(S,U,f,b,e)|0;f=$G(d)|0;c[d+(f*72|0)+68>>2]=1;s=d+(f*72|0)|0;k=d+(m*72|0)|0;r=s+72|0;do{c[s>>2]=c[k>>2];s=s+4|0;k=k+4|0}while((s|0)<(r|0));q=+h[H>>3];h[d+(f*72|0)+16>>3]=q;h[d+(m*72|0)+32>>3]=q;q=+h[S>>3];h[d+(f*72|0)+8>>3]=q;h[d+(m*72|0)+24>>3]=q;c[d+(m*72|0)+48>>2]=f;c[d+(m*72|0)+52>>2]=0;c[d+(f*72|0)+40>>2]=m;c[d+(f*72|0)+44>>2]=0;g=c[d+(f*72|0)+48>>2]|0;if((g|0)>0){k=d+(g*72|0)+40|0;if((c[k>>2]|0)==(m|0))c[k>>2]=f;g=d+(g*72|0)+44|0;if((c[g>>2]|0)==(m|0))c[g>>2]=f}g=c[d+(f*72|0)+52>>2]|0;if((g|0)>0){k=d+(g*72|0)+40|0;if((c[k>>2]|0)==(m|0))c[k>>2]=f;g=d+(g*72|0)+44|0;if((c[g>>2]|0)==(m|0))c[g>>2]=f}E=aH()|0;G=aH()|0;F=d+(m*72|0)+56|0;D=c[F>>2]|0;c[e+(D*40|0)>>2]=2;C=e+(D*40|0)+8|0;c[C>>2]=c[S>>2];c[C+4>>2]=c[S+4>>2];c[C+8>>2]=c[S+8>>2];c[C+12>>2]=c[S+12>>2];c[e+(D*40|0)+4>>2]=a;c[e+(D*40|0)+32>>2]=G;c[e+(D*40|0)+36>>2]=E;c[e+(E*40|0)>>2]=3;c[e+(E*40|0)+24>>2]=m;c[e+(E*40|0)+28>>2]=D;c[e+(G*40|0)>>2]=3;c[e+(G*40|0)+24>>2]=f;c[e+(G*40|0)+28>>2]=D;c[F>>2]=E;c[d+(f*72|0)+56>>2]=G;if(n)G=19;else G=20}if((G|0)==19)if(!(_G(a,b,1)|0)){g=1;G=21}else{g=1;G=32}else if((G|0)==20)if(!(_G(a,b,2)|0)){g=0;G=21}else{g=0;G=32}if((G|0)==21){o=YG(U,S,c[S+40>>2]|0,b,e)|0;n=$G(d)|0;c[d+(n*72|0)+68>>2]=1;s=d+(n*72|0)|0;k=d+(o*72|0)|0;r=s+72|0;do{c[s>>2]=c[k>>2];s=s+4|0;k=k+4|0}while((s|0)<(r|0));q=+h[V>>3];h[d+(n*72|0)+16>>3]=q;h[d+(o*72|0)+32>>3]=q;q=+h[U>>3];h[d+(n*72|0)+8>>3]=q;h[d+(o*72|0)+24>>3]=q;c[d+(o*72|0)+48>>2]=n;c[d+(o*72|0)+52>>2]=0;c[d+(n*72|0)+40>>2]=o;c[d+(n*72|0)+44>>2]=0;k=c[d+(n*72|0)+48>>2]|0;if((k|0)>0){m=d+(k*72|0)+40|0;if((c[m>>2]|0)==(o|0))c[m>>2]=n;k=d+(k*72|0)+44|0;if((c[k>>2]|0)==(o|0))c[k>>2]=n}k=c[d+(n*72|0)+52>>2]|0;if((k|0)>0){m=d+(k*72|0)+40|0;if((c[m>>2]|0)==(o|0))c[m>>2]=n;k=d+(k*72|0)+44|0;if((c[k>>2]|0)==(o|0))c[k>>2]=n}D=aH()|0;F=aH()|0;E=d+(o*72|0)+56|0;C=c[E>>2]|0;c[e+(C*40|0)>>2]=2;A=e+(C*40|0)+8|0;c[A>>2]=c[U>>2];c[A+4>>2]=c[U+4>>2];c[A+8>>2]=c[U+8>>2];c[A+12>>2]=c[U+12>>2];c[e+(C*40|0)+4>>2]=a;c[e+(C*40|0)+32>>2]=F;c[e+(C*40|0)+36>>2]=D;c[e+(D*40|0)>>2]=3;c[e+(D*40|0)+24>>2]=o;c[e+(D*40|0)+28>>2]=C;c[e+(F*40|0)>>2]=3;c[e+(F*40|0)+24>>2]=n;c[e+(F*40|0)+28>>2]=C;c[E>>2]=D;c[d+(n*72|0)+56>>2]=F;F=f;f=0}else if((G|0)==32){F=f;o=YG(U,S,c[S+40>>2]|0,b,e)|0;f=1}a:do if((F|0)>0){D=d+(o*72|0)+24|0;E=d+(o*72|0)+32|0;C=(f|0)!=0;y=g?b+(a*56|0)+48|0:b+(a*56|0)+44|0;z=T+8|0;g=0;f=0;x=F;b:while(1){k=d+(x*72|0)|0;v=d+(x*72|0)+24|0;if(!(bH(v,D)|0))break a;m=d+(x*72|0)+56|0;u=c[m>>2]|0;n=aH()|0;p=aH()|0;c[e+(u*40|0)>>2]=1;c[e+(u*40|0)+4>>2]=a;c[e+(u*40|0)+32>>2]=n;c[e+(u*40|0)+36>>2]=p;c[e+(n*40|0)>>2]=3;c[e+(n*40|0)+24>>2]=x;c[e+(n*40|0)+28>>2]=u;c[e+(p*40|0)>>2]=3;w=$G(d)|0;c[e+(p*40|0)+24>>2]=w;A=d+(w*72|0)|0;c[d+(w*72|0)+68>>2]=1;c[e+(p*40|0)+28>>2]=u;g=(x|0)==(F|0)?w:g;u=d+(x*72|0)+32|0;if(+B(+(+h[u>>3]-+h[E>>3]))<=1.0e-07?+B(+(+h[v>>3]-+h[D>>3]))<=1.0e-07:0)f=w;s=A;r=s+72|0;do{c[s>>2]=c[k>>2];s=s+4|0;k=k+4|0}while((s|0)<(r|0));c[m>>2]=n;c[d+(w*72|0)+56>>2]=p;t=d+(x*72|0)+48|0;m=d+(x*72|0)+52|0;k=(c[m>>2]|0)<1;do if((c[t>>2]|0)<1){if(k)break b;s=d+(x*72|0)+40|0;k=c[s>>2]|0;do if((k|0)>0?(M=d+(x*72|0)+44|0,N=c[M>>2]|0,(N|0)>0):0){r=d+(x*72|0)+60|0;k=c[r>>2]|0;if((k|0)<=0){c[d+(w*72|0)+40>>2]=N;c[d+(w*72|0)+44>>2]=-1;c[M>>2]=-1;c[d+(N*72|0)+48>>2]=w;break}if((c[d+(x*72|0)+64>>2]|0)==1){c[d+(w*72|0)+40>>2]=N;c[M>>2]=-1;c[d+(w*72|0)+44>>2]=k;c[d+((c[s>>2]|0)*72|0)+48>>2]=x;p=w;n=N}else{c[d+(w*72|0)+44>>2]=-1;t=d+(w*72|0)+40|0;c[t>>2]=c[M>>2];n=c[s>>2]|0;c[M>>2]=n;c[s>>2]=k;c[d+(k*72|0)+48>>2]=x;p=x;k=c[t>>2]|0}c[d+(n*72|0)+48>>2]=p;c[d+(k*72|0)+48>>2]=w;c[d+(w*72|0)+60>>2]=0;c[r>>2]=0}else G=77;while(0);do if((G|0)==77){G=0;n=d+(k*72|0)+48|0;p=c[n>>2]|0;k=d+(k*72|0)+52|0;if((p|0)>0?(c[k>>2]|0)>0:0){k=c[d+(p*72|0)+4>>2]|0;if((k|0)>0?(ZG(k,b,U)|0)==0:0){c[d+(w*72|0)+44>>2]=-1;c[d+(x*72|0)+44>>2]=-1;c[s>>2]=-1;c[d+((c[d+(w*72|0)+40>>2]|0)*72|0)+52>>2]=w;break}c[d+(x*72|0)+44>>2]=-1;c[d+(w*72|0)+44>>2]=-1;c[d+(w*72|0)+40>>2]=-1;c[d+((c[s>>2]|0)*72|0)+48>>2]=x;break}c[n>>2]=x;c[k>>2]=w}while(0);if(+B(+(+h[u>>3]-+h[E>>3]))<=1.0e-07?C&+B(+(+h[v>>3]-+h[D>>3]))<=1.0e-07:0){k=c[y>>2]|0;if((k|0)>0?(ZG(k,b,S)|0)!=0:0){c[d+((c[m>>2]|0)*72|0)+40>>2]=x;n=d+(w*72|0)+52|0;k=w}else{c[d+((c[d+(w*72|0)+52>>2]|0)*72|0)+44>>2]=w;n=m;k=x}c[n>>2]=-1;c[d+(k*72|0)+48>>2]=-1;k=c[m>>2]|0;break}k=c[m>>2]|0;m=d+(k*72|0)+40|0;n=c[m>>2]|0;p=d+(k*72|0)+44|0;if((n|0)>0?(O=c[p>>2]|0,P=(n|0)==(x|0),(O|0)>0):0){c[d+(k*72|0)+60>>2]=P?O:n;c[d+(k*72|0)+64>>2]=P?1:2}c[m>>2]=x;c[p>>2]=w}else{if(!k){i=+h[u>>3];j=+h[H>>3];q=i-j;if(!(+B(+q)<=1.0e-07)){h[z>>3]=i;i=+h[S>>3];h[T>>3]=(+h[U>>3]-i)*(q/(+h[V>>3]-j))+i;s=(cH(T,v)|0)!=0}else s=+h[v>>3]>+h[S>>3];r=d+(x*72|0)+40|0;k=c[r>>2]|0;do if((k|0)>0?(Q=d+(x*72|0)+44|0,R=c[Q>>2]|0,(R|0)>0):0){p=d+(x*72|0)+60|0;k=c[p>>2]|0;if((k|0)<=0){c[d+(w*72|0)+40>>2]=R;c[d+(w*72|0)+44>>2]=-1;c[Q>>2]=-1;c[d+(R*72|0)+48>>2]=w;break}if((c[d+(x*72|0)+64>>2]|0)==1){c[d+(w*72|0)+40>>2]=R;c[Q>>2]=-1;c[d+(w*72|0)+44>>2]=k;c[d+((c[r>>2]|0)*72|0)+48>>2]=x;n=w;m=R}else{c[d+(w*72|0)+44>>2]=-1;X=d+(w*72|0)+40|0;c[X>>2]=c[Q>>2];m=c[r>>2]|0;c[Q>>2]=m;c[r>>2]=k;c[d+(k*72|0)+48>>2]=x;n=x;k=c[X>>2]|0}c[d+(m*72|0)+48>>2]=n;c[d+(k*72|0)+48>>2]=w;c[d+(w*72|0)+60>>2]=0;c[p>>2]=0}else G=106;while(0);do if((G|0)==106){G=0;m=d+(k*72|0)+48|0;n=c[m>>2]|0;k=d+(k*72|0)+52|0;if((n|0)>0?(c[k>>2]|0)>0:0){k=c[d+(n*72|0)+4>>2]|0;if((k|0)>0?(ZG(k,b,U)|0)==0:0){c[d+(w*72|0)+44>>2]=-1;c[d+(x*72|0)+44>>2]=-1;c[r>>2]=-1;c[d+((c[d+(w*72|0)+40>>2]|0)*72|0)+52>>2]=w;break}c[d+(x*72|0)+44>>2]=-1;c[d+(w*72|0)+44>>2]=-1;c[d+(w*72|0)+40>>2]=-1;c[d+((c[r>>2]|0)*72|0)+48>>2]=x;break}c[m>>2]=x;c[k>>2]=w}while(0);if(+B(+(+h[u>>3]-+h[E>>3]))<=1.0e-07?C&+B(+(+h[v>>3]-+h[D>>3]))<=1.0e-07:0){k=c[t>>2]|0;c[d+(k*72|0)+40>>2]=x;c[d+(k*72|0)+44>>2]=-1;k=d+(x*72|0)+52|0;X=c[k>>2]|0;c[d+(X*72|0)+40>>2]=w;c[d+(X*72|0)+44>>2]=-1;c[d+(w*72|0)+48>>2]=X;c[d+(w*72|0)+52>>2]=-1;c[k>>2]=-1;k=-1}else G=116;do if((G|0)==116){G=0;k=c[t>>2]|0;c[d+(k*72|0)+40>>2]=x;m=d+(k*72|0)+44|0;if(s){c[m>>2]=w;X=d+(x*72|0)+52|0;v=c[X>>2]|0;c[d+(v*72|0)+40>>2]=w;c[d+(v*72|0)+44>>2]=-1;c[X>>2]=-1;break}else{c[m>>2]=-1;k=d+(x*72|0)+52|0;X=c[k>>2]|0;c[d+(X*72|0)+40>>2]=x;c[d+(X*72|0)+44>>2]=w;c[d+(w*72|0)+48>>2]=X;c[d+(w*72|0)+52>>2]=-1;k=c[k>>2]|0;break}}while(0);break}s=d+(x*72|0)+40|0;k=c[s>>2]|0;do if((k|0)>0?(I=d+(x*72|0)+44|0,J=c[I>>2]|0,(J|0)>0):0){r=d+(x*72|0)+60|0;k=c[r>>2]|0;if((k|0)<=0){c[d+(w*72|0)+40>>2]=J;c[d+(w*72|0)+44>>2]=-1;c[I>>2]=-1;c[d+(J*72|0)+48>>2]=w;break}if((c[d+(x*72|0)+64>>2]|0)==1){c[d+(w*72|0)+40>>2]=J;c[I>>2]=-1;c[d+(w*72|0)+44>>2]=k;c[d+((c[s>>2]|0)*72|0)+48>>2]=x;p=w;n=J}else{c[d+(w*72|0)+44>>2]=-1;X=d+(w*72|0)+40|0;c[X>>2]=c[I>>2];n=c[s>>2]|0;c[I>>2]=n;c[s>>2]=k;c[d+(k*72|0)+48>>2]=x;p=x;k=c[X>>2]|0}c[d+(n*72|0)+48>>2]=p;c[d+(k*72|0)+48>>2]=w;c[d+(w*72|0)+60>>2]=0;c[r>>2]=0}else G=51;while(0);do if((G|0)==51){G=0;n=d+(k*72|0)+48|0;p=c[n>>2]|0;k=d+(k*72|0)+52|0;if((p|0)>0?(c[k>>2]|0)>0:0){k=c[d+(p*72|0)+4>>2]|0;if((k|0)>0?(ZG(k,b,U)|0)==0:0){c[d+(w*72|0)+44>>2]=-1;c[d+(x*72|0)+44>>2]=-1;c[s>>2]=-1;c[d+((c[d+(w*72|0)+40>>2]|0)*72|0)+52>>2]=w;break}c[d+(x*72|0)+44>>2]=-1;c[d+(w*72|0)+44>>2]=-1;c[d+(w*72|0)+40>>2]=-1;c[d+((c[s>>2]|0)*72|0)+48>>2]=x;break}c[n>>2]=x;c[k>>2]=w}while(0);if(+B(+(+h[u>>3]-+h[E>>3]))<=1.0e-07?C&+B(+(+h[v>>3]-+h[D>>3]))<=1.0e-07:0){k=c[y>>2]|0;if((k|0)>0?(ZG(k,b,S)|0)!=0:0){c[d+((c[t>>2]|0)*72|0)+40>>2]=x;m=d+(w*72|0)+52|0;k=w}else{c[d+((c[d+(w*72|0)+48>>2]|0)*72|0)+44>>2]=w;k=x}c[m>>2]=-1;c[d+(k*72|0)+48>>2]=-1;k=c[t>>2]|0;break}k=c[t>>2]|0;m=d+(k*72|0)+40|0;n=c[m>>2]|0;p=d+(k*72|0)+44|0;if((n|0)>0?(K=c[p>>2]|0,L=(n|0)==(x|0),(K|0)>0):0){c[d+(k*72|0)+60>>2]=L?K:n;c[d+(k*72|0)+64>>2]=L?1:2}c[m>>2]=x;c[p>>2]=w}while(0);c[A>>2]=a;c[d+(x*72|0)+4>>2]=a;if((k|0)>0)x=k;else break a}XL(123235,19,1,c[13918]|0)|0}else{g=0;f=0}while(0);dH(a,F,o,1,d,e);dH(a,g,f,2,d,e);c[b+(a*56|0)+32>>2]=1;l=W;return}function XG(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;if(!(c[b+(a*56|0)+32>>2]|0)){f=b+(a*56|0)|0;g=b+(a*56|0)+16|0;h=b+(a*56|0)+36|0;c[h>>2]=c[d+((YG(f,g,c[h>>2]|0,b,e)|0)*72|0)+56>>2];a=b+(a*56|0)+40|0;c[a>>2]=c[d+((YG(g,f,c[a>>2]|0,b,e)|0)*72|0)+56>>2]}return}function YG(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0.0,i=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0,p=0.0,q=0,r=0;o=a+8|0;q=b+8|0;a:while(1){b:do switch(c[f+(d*40|0)>>2]|0){case 3:{r=3;break a}case 2:{g=+h[o>>3];i=f+(d*40|0)+8|0;j=+h[f+(d*40|0)+16>>3];k=j+1.0e-07;do if(!(g>k)){l=j+-1.0e-07;if(!(g>3]>+h[i>>3]:0)break;if(+B(+(g-j))<=1.0e-07?(m=+h[i>>3],+B(+(+h[a>>3]-m))<=1.0e-07):0){g=+h[q>>3];do if(!(g>k)){if(!(g>3]>m:0)break;d=f+(d*40|0)+32|0;break b}while(0);d=f+(d*40|0)+36|0;break b}d=f+(d*40|0)+32|0;break b}while(0);d=f+(d*40|0)+36|0;break}case 1:{g=+h[o>>3];i=c[f+(d*40|0)+4>>2]|0;if(+B(+(g-+h[e+(i*56|0)+8>>3]))<=1.0e-07?(n=+h[a>>3],+B(+(n-+h[e+(i*56|0)>>3]))<=1.0e-07):0)j=n;else r=19;do if((r|0)==19){r=0;if(+B(+(g-+h[e+(i*56|0)+24>>3]))<=1.0e-07?(p=+h[a>>3],+B(+(p-+h[e+(i*56|0)+16>>3]))<=1.0e-07):0){j=p;break}if(!(ZG(i,e,a)|0)){d=f+(d*40|0)+36|0;break b}else{d=f+(d*40|0)+32|0;break b}}while(0);if(!(+B(+(g-+h[q>>3]))<=1.0e-07))if(!(ZG(i,e,b)|0)){d=f+(d*40|0)+36|0;break b}else{d=f+(d*40|0)+32|0;break b}else if(+h[b>>3]>2]|0}if((r|0)==3)return c[f+(d*40|0)+24>>2]|0;else if((r|0)==31){XL(123169,35,1,c[13918]|0)|0;ma(123205,123207,349,123219)}return 0}function ZG(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0,e=0.0,f=0,g=0.0,i=0,j=0,k=0.0;f=b+(a*56|0)+16|0;g=+h[b+(a*56|0)+24>>3];i=b+(a*56|0)|0;e=+h[b+(a*56|0)+8>>3];do if(!(g>e+1.0e-07)){if(!(g>3]>+h[i>>3]:0){j=4;break}d=+h[c+8>>3];if(+B(+(g-d))<=1.0e-07){d=+h[c>>3]<+h[f>>3]?1.0:-1.0;break}if(!(+B(+(e-d))<=1.0e-07)){k=+h[f>>3];d=(+h[i>>3]-k)*(d-g)-(+h[c>>3]-k)*(e-g);break}else{d=+h[c>>3]<+h[i>>3]?1.0:-1.0;break}}else j=4;while(0);do if((j|0)==4){d=+h[c+8>>3];if(+B(+(g-d))<=1.0e-07){d=+h[c>>3]<+h[f>>3]?1.0:-1.0;break}if(!(+B(+(e-d))<=1.0e-07)){k=+h[i>>3];d=(+h[f>>3]-k)*(d-e)-(+h[c>>3]-k)*(g-e);break}else{d=+h[c>>3]<+h[i>>3]?1.0:-1.0;break}}while(0);return d>0.0|0}function _G(a,b,d){a=a|0;b=b|0;d=d|0;return c[b+((c[((d|0)==1?b+(a*56|0)+48|0:b+(a*56|0)+44|0)>>2]|0)*56|0)+32>>2]|0}function $G(a){a=a|0;var b=0,d=0,e=0;e=l;l=l+16|0;d=e;b=c[42438]|0;if((b|0)<(c[42437]|0)){c[a+(b*72|0)>>2]=-1;c[a+(b*72|0)+4>>2]=-1;c[a+(b*72|0)+68>>2]=1;c[42438]=b+1;l=e;return b|0}else{e=c[13918]|0;c[d>>2]=b;zL(e,123294,d)|0;ma(123205,123207,88,123332)}return 0}function aH(){var a=0;a=c[42439]|0;if((a|0)<(c[42436]|0)){c[42439]=a+1;return a|0}else{XL(123255,30,1,c[13918]|0)|0;ma(123205,123207,72,123286)}return 0}function bH(a,b){a=a|0;b=b|0;var c=0.0,d=0.0;c=+h[a+8>>3];d=+h[b+8>>3];if(!(c>d+1.0e-07))if(c>3]>=+h[b>>3]&1;else a=1;return a|0}function cH(a,b){a=a|0;b=b|0;var c=0.0,d=0.0;c=+h[a+8>>3];d=+h[b+8>>3];if(!(cd+1.0e-07)a=0;else a=+h[a>>3]<+h[b>>3]&1;else a=1;return a|0}function dH(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;q=f+(d*72|0)+24|0;p=(e|0)==1;a:while(1){o=f+(b*72|0)+24|0;j=f+(b*72|0)+48|0;k=f+(b*72|0)+52|0;l=f+(b*72|0)|0;m=f+(b*72|0)+4|0;n=f+(b*72|0)+56|0;if((b|0)<=0)break;while(1){if(!(bH(o,q)|0))break a;d=c[j>>2]|0;e=(d|0)>0;do if(p){if(e?(c[f+(d*72|0)+4>>2]|0)==(a|0):0)break;d=c[k>>2]|0;if((d|0)<=0){b=d;continue a}if((c[f+(d*72|0)+4>>2]|0)!=(a|0)){b=d;continue a}}else{if(e?(c[f+(d*72|0)>>2]|0)==(a|0):0)break;d=c[k>>2]|0;if((d|0)<=0){b=d;continue a}if((c[f+(d*72|0)>>2]|0)!=(a|0)){b=d;continue a}}while(0);if((c[l>>2]|0)!=(c[f+(d*72|0)>>2]|0)){b=d;continue a}if((c[m>>2]|0)!=(c[f+(d*72|0)+4>>2]|0)){b=d;continue a}r=c[f+(d*72|0)+56>>2]|0;e=c[g+(r*40|0)+28>>2]|0;h=g+(e*40|0)+32|0;i=c[n>>2]|0;if((c[h>>2]|0)==(r|0))c[h>>2]=i;else c[g+(e*40|0)+36>>2]=i;e=c[f+(d*72|0)+48>>2]|0;c[j>>2]=e;do if((e|0)>0){h=f+(e*72|0)+40|0;if((c[h>>2]|0)==(d|0)){c[h>>2]=b;break}e=f+(e*72|0)+44|0;if((c[e>>2]|0)==(d|0))c[e>>2]=b}while(0);e=c[f+(d*72|0)+52>>2]|0;c[k>>2]=e;do if((e|0)>0){h=f+(e*72|0)+40|0;if((c[h>>2]|0)==(d|0)){c[h>>2]=b;break}e=f+(e*72|0)+44|0;if((c[e>>2]|0)==(d|0))c[e>>2]=b}while(0);r=f+(d*72|0)+24|0;c[o>>2]=c[r>>2];c[o+4>>2]=c[r+4>>2];c[o+8>>2]=c[r+8>>2];c[o+12>>2]=c[r+12>>2];c[f+(d*72|0)+68>>2]=2}}return}function eH(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0;e=+h[b+8>>3];f=+h[d+8>>3];do if(!(e>f+1.0e-07)){if(!(+B(+(e-f))<=1.0e-07)){c[a>>2]=c[d>>2];c[a+4>>2]=c[d+4>>2];c[a+8>>2]=c[d+8>>2];c[a+12>>2]=c[d+12>>2];break}if(+h[b>>3]>+h[d>>3]+1.0e-07){c[a>>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];c[a+12>>2]=c[b+12>>2];break}else{c[a>>2]=c[d>>2];c[a+4>>2]=c[d+4>>2];c[a+8>>2]=c[d+8>>2];c[a+12>>2]=c[d+12>>2];break}}else{c[a>>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];c[a+12>>2]=c[b+12>>2]}while(0);return}function fH(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0;e=+h[b+8>>3];f=+h[d+8>>3];do if(!(e>2]=c[d>>2];c[a+4>>2]=c[d+4>>2];c[a+8>>2]=c[d+8>>2];c[a+12>>2]=c[d+12>>2];break}if(+h[b>>3]<+h[d>>3]){c[a>>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];c[a+12>>2]=c[b+12>>2];break}else{c[a>>2]=c[d>>2];c[a+4>>2]=c[d+4>>2];c[a+8>>2]=c[d+8>>2];c[a+12>>2]=c[d+12>>2];break}}else{c[a>>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];c[a+12>>2]=c[b+12>>2]}while(0);return}function gH(a){a=a|0;var b=0;b=vw(8)|0;if(b|0){c[b+4>>2]=a;c[b>>2]=0}return b|0}function hH(a,b){a=a|0;b=b|0;if(b){b=gH(b)|0;c[b>>2]=a;a=b}return a|0}function iH(a){a=a|0;var b=0;do{b=a;a=c[a>>2]|0;_I(b)}while((a|0)!=0);return}function jH(){var a=0;a=vw(1992)|0;if(a|0)c[a>>2]=kH(a)|0;return a|0}function kH(a){a=a|0;var b=0;b=qH(a)|0;c[b+4>>2]=0;a=a+1972|0;c[a>>2]=(c[a>>2]|0)+1;return b|0}function lH(a){a=a|0;mH(a,c[a>>2]|0);_I(c[a>>2]|0);_I(a);return 0}function mH(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;g=a+1980|0;h=a+1912|0;i=a+1936|0;a:do if((c[b+4>>2]|0)>0){d=0;while(1){if((d|0)==64)break a;e=b+8+(d*20|0)+16|0;f=c[e>>2]|0;if(f|0?(mH(a,f),_I(c[e>>2]|0),wH(b,d),c[g>>2]=(c[g>>2]|0)+-1,c[h>>2]|0):0)c[i>>2]=(c[i>>2]|0)+1;d=d+1|0}}else{d=0;while(1){if((d|0)==64)break a;if(c[b+8+(d*20|0)+16>>2]|0?(wH(b,d),c[g>>2]=(c[g>>2]|0)+-1,c[h>>2]|0):0)c[i>>2]=(c[i>>2]|0)+1;d=d+1|0}}while(0);return}function nH(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;if(!b)ma(123690,123340,194,123348);e=c[b+4>>2]|0;if((e|0)<=-1)ma(123360,123340,195,123348);if(!d)ma(123632,123340,196,123348);i=a+1952|0;c[i>>2]=(c[i>>2]|0)+1;a:do if((e|0)>0){i=0;e=0;while(1){if((i|0)==64)break a;f=b+8+(i*20|0)+16|0;if((c[f>>2]|0)!=0?(BH(d,b+8+(i*20|0)|0)|0)!=0:0){g=nH(a,c[f>>2]|0,d)|0;if(!e)e=g;else{f=e;while(1){h=c[f>>2]|0;if(!h)break;else f=h}c[f>>2]=g}}i=i+1|0}}else{g=0;e=0;while(1){if((g|0)==64)break a;f=b+8+(g*20|0)|0;if((c[b+8+(g*20|0)+16>>2]|0)!=0?(BH(d,f)|0)!=0:0)e=hH(e,f)|0;g=g+1|0}}while(0);return e|0}function oH(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0;p=l;l=l+64|0;k=p+52|0;m=p+32|0;n=p+16|0;o=p;c[k>>2]=0;if(!((b|0)!=0&(e|0)!=0))ma(123546,123340,247,123374);if((f|0)>-1?(j=c[e>>2]|0,(c[j+4>>2]|0)>=(f|0)):0){g=0;while(1){if((g|0)>=2)break;if((c[b+(g<<2)>>2]|0)>(c[b+(g+2<<2)>>2]|0)){h=8;break}else g=g+1|0}if((h|0)==8)ma(123421,123340,250,123374);i=a+1912|0;g=a+1908|0;h=c[g>>2]|0;if(c[i>>2]|0){q=h|0?a+1924|0:a+1916|0;c[q>>2]=(c[q>>2]|0)+1}if(!h){q=a+1964|0;c[q>>2]=(c[q>>2]|0)+1}if(!(pH(a,b,d,j,k,f)|0))g=0;else{if(c[i>>2]|0){q=c[g>>2]|0?a+1948|0:a+1944|0;c[q>>2]=(c[q>>2]|0)+1}g=qH(a)|0;q=a+1976|0;c[q>>2]=(c[q>>2]|0)+1;q=c[e>>2]|0;c[g+4>>2]=(c[q+4>>2]|0)+1;tH(n,q);c[m>>2]=c[n>>2];c[m+4>>2]=c[n+4>>2];c[m+8>>2]=c[n+8>>2];c[m+12>>2]=c[n+12>>2];q=m+16|0;c[q>>2]=c[e>>2];vH(a,m,g,0)|0;tH(o,c[k>>2]|0);c[m>>2]=c[o>>2];c[m+4>>2]=c[o+4>>2];c[m+8>>2]=c[o+8>>2];c[m+12>>2]=c[o+12>>2];c[q>>2]=c[k>>2];vH(a,m,g,0)|0;c[e>>2]=g;g=a+1980|0;c[g>>2]=(c[g>>2]|0)+2;g=1}l=p;return g|0}ma(123386,123340,248,123374);return 0}function pH(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0;q=l;l=l+80|0;m=q+52|0;n=q+48|0;o=q+32|0;p=q+16|0;k=q;c[n>>2]=0;if(!((b|0)!=0&(e|0)!=0&(f|0)!=0))ma(123464,123340,311,123478);if((g|0)>-1?(i=e+4|0,h=c[i>>2]|0,(h|0)>=(g|0)):0){if(c[a+1912>>2]|0){h=c[a+1908>>2]|0?a+1948|0:a+1944|0;c[h>>2]=(c[h>>2]|0)+1;h=c[i>>2]|0}do if((h|0)>(g|0)){i=uH(b,e)|0;h=e+8+(i*20|0)+16|0;i=e+8+(i*20|0)|0;if(!(pH(a,b,d,c[h>>2]|0,n,g)|0)){AH(o,b,i);c[i>>2]=c[o>>2];c[i+4>>2]=c[o+4>>2];c[i+8>>2]=c[o+8>>2];c[i+12>>2]=c[o+12>>2];j=0;break}else{tH(p,c[h>>2]|0);c[i>>2]=c[p>>2];c[i+4>>2]=c[p+4>>2];c[i+8>>2]=c[p+8>>2];c[i+12>>2]=c[p+12>>2];j=c[n>>2]|0;c[m+16>>2]=j;tH(k,j);c[m>>2]=c[k>>2];c[m+4>>2]=c[k+4>>2];c[m+8>>2]=c[k+8>>2];c[m+12>>2]=c[k+12>>2];j=a+1980|0;c[j>>2]=(c[j>>2]|0)+1;j=vH(a,m,e,f)|0;break}}else if((h|0)==(g|0)){c[m>>2]=c[b>>2];c[m+4>>2]=c[b+4>>2];c[m+8>>2]=c[b+8>>2];c[m+12>>2]=c[b+12>>2];c[m+16>>2]=d;j=a+1980|0;c[j>>2]=(c[j>>2]|0)+1;j=vH(a,m,e,f)|0;break}else ma(123523,123340,341,123478);while(0);l=q;return j|0}ma(123491,123340,312,123478);return 0}function qH(a){a=a|0;a=a+1968|0;c[a>>2]=(c[a>>2]|0)+1;a=ZI(1288)|0;rH(a);return a|0}function rH(a){a=a|0;var b=0;c[a>>2]=0;c[a+4>>2]=-1;b=0;while(1){if((b|0)==64)break;sH(a+8+(b*20|0)|0);b=b+1|0}return}function sH(a){a=a|0;xH(a);c[a+16>>2]=0;return}function tH(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;i=l;l=l+32|0;g=i+16|0;h=i;if(!b)ma(123690,123529,99,123536);xH(g);d=1;f=0;while(1){if((f|0)==64)break;do if(c[b+8+(f*20|0)+16>>2]|0){e=b+8+(f*20|0)|0;if(!d){AH(h,g,e);c[g>>2]=c[h>>2];c[g+4>>2]=c[h+4>>2];c[g+8>>2]=c[h+8>>2];c[g+12>>2]=c[h+12>>2];d=0;break}else{c[g>>2]=c[e>>2];c[g+4>>2]=c[e+4>>2];c[g+8>>2]=c[e+8>>2];c[g+12>>2]=c[e+12>>2];d=0;break}}while(0);f=f+1|0}c[a>>2]=c[g>>2];c[a+4>>2]=c[g+4>>2];c[a+8>>2]=c[g+8>>2];c[a+12>>2]=c[g+12>>2];l=i;return}function uH(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0;k=l;l=l+32|0;i=k+16|0;j=k;if(!((a|0)!=0&(b|0)!=0))ma(123546,123529,125,123553);d=0;e=0;f=0;g=1;h=0;while(1){if((h|0)==64)break;if(c[b+8+(h*20|0)+16>>2]|0){n=b+8+(h*20|0)|0;p=zH(n)|0;AH(j,a,n);c[i>>2]=c[j>>2];c[i+4>>2]=c[j+4>>2];c[i+8>>2]=c[j+8>>2];c[i+12>>2]=c[j+12>>2];n=(zH(i)|0)-p|0;m=(g|0)!=0|(n|0)<(f|0);o=m|(p|0)<(e|0)&(n|0)==(f|0);d=o?h:d;e=o?p:e;f=o?n:f;g=m?0:g}h=h+1|0}l=k;return d|0}function vH(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;if(!b)ma(123712,123529,167,123564);if(!d)ma(123690,123529,168,123564);do if((c[d>>2]|0)<64){a=0;while(1){if((a|0)>=64){e=10;break}if(!(c[d+8+(a*20|0)+16>>2]|0)){e=8;break}a=a+1|0}if((e|0)==8){f=d+8+(a*20|0)|0;c[f>>2]=c[b>>2];c[f+4>>2]=c[b+4>>2];c[f+8>>2]=c[b+8>>2];c[f+12>>2]=c[b+12>>2];c[f+16>>2]=c[b+16>>2];f=0;g=d;break}else if((e|0)==10)ma(123574,123529,178,123564)}else{if(c[a+1912>>2]|0){h=c[a+1908>>2]|0?a+1948|0:a+1944|0;c[h>>2]=(c[h>>2]|0)+1}if(!e)ma(123587,123529,187,123564);else{CH(a,d,b,e);f=1;g=(c[d+4>>2]|0)==0?a+1972|0:a+1976|0;break}}while(0);c[g>>2]=(c[g>>2]|0)+1;return f|0}function wH(a,b){a=a|0;b=b|0;if(!((a|0)!=0&b>>>0<64))ma(123591,123529,201,123619);if(!(c[a+8+(b*20|0)+16>>2]|0))ma(124113,123529,202,123619);else{sH(a+8+(b*20|0)|0);c[a>>2]=(c[a>>2]|0)+-1;return}}function xH(a){a=a|0;var b=0;b=0;while(1){if((b|0)==4)break;c[a+(b<<2)>>2]=0;b=b+1|0}return}function yH(a){a=a|0;var b=0,d=0,e=0;e=l;l=l+16|0;d=e;c[d>>2]=1;c[d+8>>2]=-1;b=1;while(1){if((b|0)==2)break;c[d+(b+2<<2)>>2]=0;c[d+(b<<2)>>2]=0;b=b+1|0}c[a>>2]=c[d>>2];c[a+4>>2]=c[d+4>>2];c[a+8>>2]=c[d+8>>2];c[a+12>>2]=c[d+12>>2];l=e;return}function zH(a){a=a|0;var b=0,d=0,e=0;if(!a)ma(123632,123634,128,123646);a:do if((c[a>>2]|0)>(c[a+8>>2]|0))b=0;else{b=1;d=0;while(1){if((d|0)==2)break a;e=O(c[a+(d+2<<2)>>2]|0,b)|0;b=e-(c[a+(d<<2)>>2]|0)|0;d=d+1|0}}while(0);return b|0}function AH(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;g=l;l=l+16|0;f=g;if(!((b|0)!=0&(d|0)!=0))ma(123655,123634,195,123663);do if((c[b>>2]|0)>(c[b+8>>2]|0)){c[a>>2]=c[d>>2];c[a+4>>2]=c[d+4>>2];c[a+8>>2]=c[d+8>>2];c[a+12>>2]=c[d+12>>2]}else{if((c[d>>2]|0)>(c[d+8>>2]|0)){c[a>>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];c[a+12>>2]=c[b+12>>2];break}else e=0;while(1){if((e|0)==2)break;j=c[b+(e<<2)>>2]|0;h=c[d+(e<<2)>>2]|0;c[f+(e<<2)>>2]=(j|0)<(h|0)?j:h;h=e+2|0;j=c[b+(h<<2)>>2]|0;i=c[d+(h<<2)>>2]|0;c[f+(h<<2)>>2]=(j|0)>(i|0)?j:i;e=e+1|0}c[a>>2]=c[f>>2];c[a+4>>2]=c[f+4>>2];c[a+8>>2]=c[f+8>>2];c[a+12>>2]=c[f+12>>2]}while(0);l=g;return}function BH(a,b){a=a|0;b=b|0;var d=0,e=0;if((a|0)!=0&(b|0)!=0)d=0;else ma(123675,123634,216,123682);while(1){if((d|0)>=2){d=1;break}e=d+2|0;if((c[a+(d<<2)>>2]|0)>(c[b+(e<<2)>>2]|0)){d=0;break}if((c[b+(d<<2)>>2]|0)>(c[a+(e<<2)>>2]|0)){d=0;break}else d=d+1|0}return d|0}function CH(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,i=0,j=0;if(!b)ma(123690,123692,40,123702);if(!d)ma(123712,123692,41,123702);j=a+1912|0;if(c[j>>2]|0){i=c[a+1908>>2]|0?a+1932|0:a+1928|0;c[i>>2]=(c[i>>2]|0)+1}h=b+4|0;i=c[h>>2]|0;DH(a,b,d);d=a+1324|0;EH(a);f=zH(a+1852|0)|0;f=(zH(a+1868|0)|0)+f|0;if(c[j>>2]|0?(f|0)!=0&(c[a+1908>>2]|0)==0:0){j=a+1960|0;g[j>>2]=+((c[a+1320>>2]|0)>>>0)/+(f|0)+ +g[j>>2]}j=qH(a)|0;c[e>>2]=j;c[h>>2]=i;c[j+4>>2]=i;FH(a,b,j,d);if(((c[c[e>>2]>>2]|0)+(c[b>>2]|0)|0)==65)return;else ma(123714,123692,86,123702)}function DH(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;h=l;l=l+16|0;g=h;if(!b)ma(123690,123692,106,124101);if(!d)ma(123712,123692,107,124101);else e=0;while(1){if((e|0)>=64)break;if(!(c[b+8+(e*20|0)+16>>2]|0)){f=7;break}j=b+8+(e*20|0)|0;i=a+4+(e*20|0)|0;c[i>>2]=c[j>>2];c[i+4>>2]=c[j+4>>2];c[i+8>>2]=c[j+8>>2];c[i+12>>2]=c[j+12>>2];c[i+16>>2]=c[j+16>>2];e=e+1|0}if((f|0)==7)ma(124113,123692,111,124101);e=a+4|0;j=a+1284|0;c[j>>2]=c[d>>2];c[j+4>>2]=c[d+4>>2];c[j+8>>2]=c[d+8>>2];c[j+12>>2]=c[d+12>>2];c[j+16>>2]=c[d+16>>2];d=a+1304|0;c[d>>2]=c[e>>2];c[d+4>>2]=c[e+4>>2];c[d+8>>2]=c[e+8>>2];c[d+12>>2]=c[e+12>>2];e=1;while(1){if((e|0)==65)break;AH(g,d,a+4+(e*20|0)|0);c[d>>2]=c[g>>2];c[d+4>>2]=c[g+4>>2];c[d+8>>2]=c[g+8>>2];c[d+12>>2]=c[g+12>>2];e=e+1|0}c[a+1320>>2]=zH(d)|0;rH(b);l=h;return}function EH(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;u=l;l=l+48|0;i=u+32|0;k=u+16|0;m=u;GH(a);HH(a);q=a+1844|0;s=a+1848|0;t=a+1892|0;n=a+1852|0;o=a+1884|0;p=a+1868|0;j=a+1888|0;f=0;e=0;while(1){d=c[q>>2]|0;b=c[s>>2]|0;if((b+d|0)>=65)break;h=65-(c[t>>2]|0)|0;if((d|0)<(h|0)&(b|0)<(h|0)){g=-1;h=0}else{r=12;break}while(1){if((h|0)==65)break;if(!(c[a+1584+(h<<2)>>2]|0)){v=a+4+(h*20|0)|0;AH(k,v,n);c[i>>2]=c[k>>2];c[i+4>>2]=c[k+4>>2];c[i+8>>2]=c[k+8>>2];c[i+12>>2]=c[k+12>>2];b=zH(i)|0;d=c[o>>2]|0;AH(m,v,p);c[i>>2]=c[m>>2];c[i+4>>2]=c[m+4>>2];c[i+8>>2]=c[m+8>>2];c[i+12>>2]=c[m+12>>2];v=zH(i)|0;b=v-(c[j>>2]|0)+(d-b)|0;d=(b|0)>-1;b=d?b:0-b|0;d=(d^1)&1;if((b|0)<=(g|0))if((b|0)==(g|0)){v=(c[a+1844+(d<<2)>>2]|0)<(c[a+1844+(f<<2)>>2]|0);b=g;d=v?d:f;e=v?h:e}else{b=g;d=f}else e=h}else{b=g;d=f}g=b;h=h+1|0;f=d}IH(a,e,f)}if((r|0)==12){b=(d|0)>=(65-(c[t>>2]|0)|0)&1;d=0;while(1){if((d|0)==65)break;if(!(c[a+1584+(d<<2)>>2]|0))IH(a,d,b);d=d+1|0}d=c[q>>2]|0;b=c[s>>2]|0}if((b+d|0)!=65)ma(123857,123692,210,123943);v=c[t>>2]|0;if((d|0)<(v|0)|(b|0)<(v|0))ma(123954,123692,212,123943);else{l=u;return}}function FH(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;if(!b)ma(123690,123692,297,123754);if(!d)ma(123764,123692,298,123754);if(!e)ma(123766,123692,299,123754);else f=0;while(1){if((f|0)>=65){e=14;break}e=c[a+1324+(f<<2)>>2]|0;if(e>>>0>=2){e=9;break}switch(e|0){case 0:{vH(a,a+4+(f*20|0)|0,b,0)|0;break}case 1:{vH(a,a+4+(f*20|0)|0,d,0)|0;break}default:{}}f=f+1|0}if((e|0)==9)ma(123768,123692,303,123754);else if((e|0)==14)return}function GH(a){a=a|0;var b=0,d=0,e=0,f=0;d=l;l=l+16|0;e=d;c[a+1848>>2]=0;c[a+1844>>2]=0;b=a+1852|0;f=a+1868|0;yH(e);c[f>>2]=c[e>>2];c[f+4>>2]=c[e+4>>2];c[f+8>>2]=c[e+8>>2];c[f+12>>2]=c[e+12>>2];c[b>>2]=c[e>>2];c[b+4>>2]=c[e+4>>2];c[b+8>>2]=c[e+8>>2];c[b+12>>2]=c[e+12>>2];c[a+1888>>2]=0;c[a+1884>>2]=0;b=0;while(1){if((b|0)==65)break;c[a+1584+(b<<2)>>2]=0;c[a+1324+(b<<2)>>2]=-1;b=b+1|0}l=d;return}function HH(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0;o=l;l=l+304|0;k=o+32|0;m=o+16|0;n=o;b=0;while(1){if((b|0)==65)break;c[k+(b<<2)>>2]=zH(a+4+(b*20|0)|0)|0;b=b+1|0}b=0;d=0;e=0;g=0;a:while(1){if((g|0)==64)break;i=g+1|0;j=a+4+(g*20|0)|0;h=k+(g<<2)|0;f=i;while(1){if((f|0)==65){g=i;continue a}AH(n,j,a+4+(f*20|0)|0);c[m>>2]=c[n>>2];c[m+4>>2]=c[n+4>>2];c[m+8>>2]=c[n+8>>2];c[m+12>>2]=c[n+12>>2];p=zH(m)|0;p=p-(c[h>>2]|0)-(c[k+(f<<2)>>2]|0)|0;q=p>>>0>e>>>0;r=q?f:b;f=f+1|0;b=r;d=q?g:d;e=q?p:e}}IH(a,d,0);IH(a,b,1);l=o;return}function IH(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;i=l;l=l+16|0;h=i;e=a+1584+(b<<2)|0;if(c[e>>2]|0)ma(124057,123692,257,124092);c[a+1324+(b<<2)>>2]=d;c[e>>2]=1;g=a+1844+(d<<2)|0;f=a+1852+(d<<4)|0;e=a+4+(b*20|0)|0;if(!(c[g>>2]|0)){c[f>>2]=c[e>>2];c[f+4>>2]=c[e+4>>2];c[f+8>>2]=c[e+8>>2];c[f+12>>2]=c[e+12>>2]}else{AH(h,e,f);c[f>>2]=c[h>>2];c[f+4>>2]=c[h+4>>2];c[f+8>>2]=c[h+8>>2];c[f+12>>2]=c[h+12>>2]}c[a+1884+(d<<2)>>2]=zH(f)|0;c[g>>2]=(c[g>>2]|0)+1;l=i;return}function JH(){var e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;t=l;l=l+1200|0;r=t+800|0;g=t;c[42440]=0;c[42441]=-2;f=r;i=200;n=g;p=0;q=0;o=r;a:while(1){b[o>>1]=p;if((f+(i<<1)+-2|0)>>>0>o>>>0)k=i;else{m=o-f>>1;e=m+1|0;if(i>>>0>9999){s=95;break}k=i<<1;k=k>>>0<1e4?k:1e4;h=ZI(k*6|3)|0;if(h){TN(h|0,f|0,e<<1|0)|0;i=h+(k>>>1<<2)|0;TN(i|0,n|0,e<<2|0)|0;if((f|0)==(r|0)){e=0;f=h}else{_I(f);e=0;f=h}}else{e=4;i=n}j=(e|0)==0;h=f+(m<<1)|0;switch((j?((f+(k<<1)+-2|0)>>>0>h>>>0?0:9):e)&15){case 9:{e=1;s=96;break a}case 4:{s=95;break a}case 0:{g=j?i+(m<<2)|0:g;n=i;o=j?h:o;break}default:{e=0;break a}}}if((p|0)==31){e=0;s=96;break}e=b[58358+(p<<1)>>1]|0;j=e<<16>>16;do if(e<<16>>16!=-82){h=c[42441]|0;if((h|0)==-2){h=gI()|0;c[42441]=h}if((h|0)>=1)if(h>>>0<296)i=d[124132+h>>0]|0;else i=2;else{c[42441]=0;i=0}h=i+j|0;if(h>>>0<=271?(i|0)==(a[124428+h>>0]|0):0){p=a[124700+h>>0]|0;e=p<<24>>24;if(p<<24>>24<1){h=0-e|0;s=23;break}else{c[42441]=-2;g=g+4|0;c[g>>2]=0;j=(q|0)==0?0:q+-1|0;h=o;break}}else s=22}else s=22;while(0);if((s|0)==22){s=0;p=a[124972+p>>0]|0;h=p&255;if(!(p<<24>>24)){h=c[42441]|0;b:do switch(q|0){case 0:{c[42440]=(c[42440]|0)+1;cI(125369);h=o;break}case 3:if((h|0)<1)if(!h){e=1;s=96;break a}else{h=o;break b}else{c[42441]=-2;h=o;break b}default:h=o}while(0);while(1){if(e<<16>>16==8)break;if((h|0)==(f|0)){e=1;s=96;break a}e=h+-2|0;g=g+-4|0;h=e;e=b[58358+(b[e>>1]<<1)>>1]|0}g=g+4|0;c[g>>2]=0;e=1;j=3}else s=23}do if((s|0)==23){s=0;j=d[125088+h>>0]|0;e=c[g+(1-j<<2)>>2]|0;do switch(h|0){case 4:{s=26;break a}case 2:{c[42442]=KH(c[g+-4>>2]|0,2)|0;break}case 3:{c[42442]=KH(c[g+-4>>2]|0,1)|0;break}case 5:{e=MH()|0;break}case 8:{NH(c[42443]|0);break}case 9:{OH(c[g>>2]|0);break}case 18:{PH(c[g>>2]|0);break}case 19:{QH();break}case 20:{PH(c[g>>2]|0);break}case 21:{QH();break}case 22:{PH(c[g>>2]|0);break}case 23:{QH();break}case 24:{PH(c[g>>2]|0);break}case 25:{QH();break}case 26:{PH(c[g>>2]|0);break}case 27:{QH();break}case 28:{PH(c[g>>2]|0);break}case 29:{QH();break}case 30:{PH(c[g>>2]|0);break}case 31:{QH();break}case 32:{PH(c[g>>2]|0);break}case 33:{QH();break}case 34:{e=c[g+-4>>2]|0;break}case 35:{e=c[g>>2]|0;break}case 38:{e=c[42443]|0;i=c[e+4>>2]|0;if(i>>>0>=(c[e+8>>2]|0)>>>0){dm(e,1)|0;i=c[42443]|0;e=i;i=c[i+4>>2]|0}a[i>>0]=0;p=c[e>>2]|0;c[e+4>>2]=p;if(RH(p)|0){s=51;break a}c[(c[g>>2]|0)+80>>2]=c[42444];e=Ql(55016,c[4344]|0)|0;c[(c[g>>2]|0)+84>>2]=e;c[42444]=c[g>>2];c[(c[g>>2]|0)+108>>2]=c[c[42445]>>2];e=c[g>>2]|0;break}case 39:{e=c[42443]|0;i=c[e+4>>2]|0;if(i>>>0>=(c[e+8>>2]|0)>>>0){dm(e,1)|0;i=c[42443]|0;e=i;i=c[i+4>>2]|0}a[i>>0]=0;p=c[e>>2]|0;c[e+4>>2]=p;if(RH(p)|0){s=56;break a}e=c[42444]|0;c[42444]=c[e+80>>2];break}case 40:{e=c[g>>2]|0;break}case 41:{e=c[g+-4>>2]|0;break}case 42:{e=c[g+-4>>2]|0;break}case 43:{e=c[g+-4>>2]|0;break}case 44:{e=c[g+-4>>2]|0;break}case 45:{e=c[g+-4>>2]|0;break}case 48:{e=c[g>>2]|0;break}case 49:{e=c[g>>2]|0;break}case 50:{a[(c[g+-8>>2]|0)+12>>0]=1;e=c[g>>2]|0;break}case 51:{SH();break}case 52:{e=TH()|0;break}case 53:{e=c[g>>2]|0;break}case 54:{e=c[g>>2]|0;break}case 55:{e=(c[g+-8>>2]|0)+100|0;a[e>>0]=a[e>>0]|1;e=c[g>>2]|0;break}case 56:{UH(c[g+-4>>2]|0,c[g>>2]|0,1);break}case 57:{e=c[g+-12>>2]|0;break}case 58:{UH(c[g+-4>>2]|0,c[g>>2]|0,2);break}case 59:{e=c[g+-12>>2]|0;break}case 60:{UH(c[g+-4>>2]|0,c[g>>2]|0,3);break}case 61:{e=c[g+-12>>2]|0;break}case 62:{UH(c[g>>2]|0,MH()|0,2);break}case 63:{e=c[g+-8>>2]|0;break}case 64:{e=c[g+-4>>2]|0;break}case 65:{e=c[g>>2]|0;break}default:{}}while(0);i=0-j|0;p=g+(i<<2)|0;i=o+(i<<1)|0;g=p+4|0;c[p+4>>2]=e;e=(d[125260+h>>0]|0)+-41|0;p=b[i>>1]|0;h=p+(b[58590+(e<<1)>>1]|0)|0;if(h>>>0<272?(a[124428+h>>0]|0)==(p|0):0){e=a[124700+h>>0]|0;j=q;h=i;break}e=a[125330+e>>0]|0;j=q;h=i}while(0);i=k;p=e;q=j;o=h+2|0}if((s|0)==26){LH();e=1;s=96}else if((s|0)==51){cI(125158);LH();e=1;s=96}else if((s|0)==56){cI(125209);LH();e=1;s=96}else if((s|0)==95){cI(125382);e=2;s=96}if((s|0)==96)if((f|0)!=(r|0))_I(f);l=t;return e|0}function KH(b,d){b=b|0;d=d|0;var e=0;e=vw(8)|0;a[e+4>>0]=d;c[e>>2]=b;return e|0}function LH(){var a=0,b=0;a=c[42444]|0;b=c[42442]|0;if(b|0){EF(b,1);c[42442]=0}c[13767]=62;while(1){if(!a)break;b=c[a+80>>2]|0;YH(a);a=b}c[13767]=51;c[13776]=63;b=c[42447]|0;bb[c[b>>2]&31](b,0,64)|0;c[13776]=51;c[13785]=64;b=c[42448]|0;bb[c[b>>2]&31](b,0,64)|0;c[13785]=51;$H();return}function MH(){var a=0,d=0,e=0,f=0,g=0,h=0;e=c[42448]|0;f=vw(40)|0;if(Sl(c[42447]|0)|0)OH(0);a=Sl(e)|0;b[f+4>>1]=a;a:do if(!a)a=e;else{c[f>>2]=vw(a*24|0)|0;a=0;d=bb[c[e>>2]&31](e,0,128)|0;while(1){if(!d){a=e;break a}g=(c[f>>2]|0)+(a*24|0)|0;h=d+8|0;c[g>>2]=c[h>>2];c[g+4>>2]=c[h+4>>2];c[g+8>>2]=c[h+8>>2];c[g+12>>2]=c[h+12>>2];c[g+16>>2]=c[h+16>>2];c[g+20>>2]=c[h+20>>2];a=a+1|0;d=bb[c[e>>2]&31](e,d,8)|0}}while(0);bb[c[a>>2]&31](e,0,64)|0;return f|0}function NH(b){b=b|0;var d=0,e=0,f=0;e=vw(64)|0;f=b+4|0;d=c[f>>2]|0;if(d>>>0>=(c[b+8>>2]|0)>>>0){dm(b,1)|0;d=c[f>>2]|0}a[d>>0]=0;b=c[b>>2]|0;c[f>>2]=b;c[e+8>>2]=GL(b)|0;c[e+12>>2]=c[c[42445]>>2];f=c[42447]|0;bb[c[f>>2]&31](f,e,1)|0;return}function OH(d){d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0;i=vw(32)|0;j=c[42447]|0;e=Sl(j)|0;k=i+8|0;a[i+14>>0]=d;a:do if(!e){c[k>>2]=vw(56)|0;b[i+12>>1]=1;h=GL(174181)|0;k=c[k>>2]|0;c[k>>2]=h;c[k+4>>2]=c[c[42445]>>2]}else{b[i+12>>1]=e;c[k>>2]=vw(e*56|0)|0;d=0;e=Ol(j)|0;while(1){if(!e)break a;f=(c[k>>2]|0)+(d*56|0)|0;g=e+8|0;h=f+56|0;do{c[f>>2]=c[g>>2];f=f+4|0;g=g+4|0}while((f|0)<(h|0));d=d+1|0;e=c[e>>2]|0}}while(0);bb[c[j>>2]&31](j,0,64)|0;k=c[42448]|0;bb[c[k>>2]&31](k,i,1)|0;return}function PH(a){a=a|0;var b=0,d=0.0,e=0,f=0,g=0,i=0,j=0;j=l;l=l+32|0;g=j;i=vw(8)|0;f=c[c[42445]>>2]|0;c[g>>2]=c[a>>2];c[g+4>>2]=c[a+4>>2];c[g+8>>2]=c[a+8>>2];c[g+12>>2]=c[a+12>>2];c[g+16>>2]=c[a+16>>2];c[g+20>>2]=c[a+20>>2];c[g+24>>2]=c[a+24>>2];c[g+28>>2]=c[a+28>>2];if(f|0){a=g+4|0;if((c[a>>2]|0)==0?(b=c[f+4>>2]|0,b|0):0)c[a>>2]=b;a=g+16|0;if(+h[a>>3]<0.0?(d=+h[f+16>>3],d>=0.0):0)h[a>>3]=d;if((c[g>>2]|0)==0?(e=c[f>>2]|0,e|0):0)c[g>>2]=e;a=c[f+24>>2]&127;if(a|0){f=g+24|0;e=c[f>>2]|0;c[f>>2]=e&127|a|e&-128}}f=c[(c[42446]|0)+144>>2]|0;c[i>>2]=bb[c[f>>2]&31](f,g,1)|0;c[i+4>>2]=c[42445];c[42445]=i;l=j;return}function QH(){var a=0,b=0;b=c[42445]|0;a=c[b+4>>2]|0;_I(b);c[42445]=a;return}function RH(b){b=b|0;var c=0;while(1){c=a[b>>0]|0;if(!(c<<24>>24)){b=0;break}if(c<<24>>24==32)b=b+1|0;else{b=1;break}}return b|0}function SH(){var b=0,d=0,e=0;e=Ql(55052,c[4344]|0)|0;b=c[42444]|0;d=vw(16)|0;c[d+8>>2]=e;if(a[b+112>>0]&2)a[d+12>>0]=1;e=c[b+84>>2]|0;bb[c[e>>2]&31](e,d,1)|0;return}function TH(){var a=0;a=c[(c[42444]|0)+84>>2]|0;return bb[c[a>>2]&31](a,0,256)|0}function UH(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;g=vw(16)|0;f=c[42444]|0;h=c[f+84>>2]|0;h=c[(bb[c[h>>2]&31](h,0,256)|0)+8>>2]|0;c[g+8>>2]=b;bb[c[h>>2]&31](h,g,1)|0;a[b+92>>0]=e;if(a[f+112>>0]&1)a[b+100>>0]=1;c[b+88>>2]=d;return}function VH(a,b,c){a=a|0;b=b|0;c=c|0;_I(b);return}function WH(a,b,d){a=a|0;b=b|0;d=d|0;Kl(c[b+8>>2]|0)|0;_I(b);return}function XH(a,b,d){a=a|0;b=b|0;d=d|0;aI(c[b+8>>2]|0);_I(b);return}function YH(a){a=a|0;Kl(c[a+84>>2]|0)|0;BF(a);_I(a);return}function ZH(a,b,d){a=a|0;b=b|0;d=d|0;_I(c[b+8>>2]|0);_I(b);return}function _H(a,d,e){a=a|0;d=d|0;e=e|0;var f=0,g=0,h=0;g=d+12|0;a=b[g>>1]|0;if(a<<16>>16){h=d+8|0;e=0;f=c[h>>2]|0;while(1){if((e|0)>=(a<<16>>16|0))break;_I(c[f>>2]|0);e=e+1|0;f=f+56|0;a=b[g>>1]|0}_I(c[h>>2]|0)}_I(d);return}function $H(){var a=0,b=0;a=c[42445]|0;while(1){b=c[a+4>>2]|0;if(!b)break;_I(a);a=b}return}function aI(b){b=b|0;var d=0;d=b+88|0;switch(a[b+92>>0]|0){case 1:{YH(c[d>>2]|0);break}case 2:{CF(c[d>>2]|0);break}default:{}}BF(b);_I(b);return}function bI(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;f=l;l=l+160|0;e=f+8|0;g=f;c[g>>2]=0;c[g+4>>2]=0;c[42445]=g;c[42444]=0;c[42442]=0;c[42446]=c[(c[(c[d+52>>2]|0)+16>>2]|0)+144>>2];c[42447]=Ql(55088,c[4344]|0)|0;c[42448]=Ql(55124,c[4344]|0)|0;cm(e,128,f+24|0);c[42443]=e;if(!(eI(a,e,d)|0)){JH()|0;c[b>>2]=fI()|0;a=c[42442]|0}else{c[b>>2]=2;a=0}Kl(c[42447]|0)|0;Kl(c[42448]|0)|0;c[42447]=0;c[42448]=0;c[42445]=0;gm(e);l=f;return a|0}function cI(b){b=b|0;var d=0,e=0;e=l;l=l+16|0;d=e;if(!(a[169796]|0)){a[169796]=1;c[d>>2]=b;c[d+4>>2]=0;_l(1,125399,d)|0;dI()}else{l=e;return}}function dI(){Ta()}function eI(a,b,d){a=a|0;b=b|0;d=d|0;a=l;l=l+16|0;if(!(c[42450]|0)){_l(0,125415,a)|0;c[42450]=(c[42450]|0)+1}l=a;return 1}function fI(){return 1}function gI(){return -1}function hI(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,m=0,n=0,q=0,r=0,s=0,t=0,u=0;u=l;l=l+64|0;m=u+48|0;k=u+32|0;s=4;j=ZI(40)|0;c[j>>2]=0;n=u+16|0;q=u;r=c[d>>2]|0;i=c[d+4>>2]|0;s=RN(169804,1,j|0,s|0)|0;j=z;o=0;d=o;o=0;if((d|0)!=0&(p|0)!=0){g=SN(c[d>>2]|0,s|0,j|0)|0;if(!g)Ua(d|0,p|0);z=p}else g=-1;if((g|0)==1)d=z;else d=0;while(1){if(d|0){d=-1;break}o=0;c[m>>2]=c[e>>2];c[m+4>>2]=c[e+4>>2];c[m+8>>2]=c[e+8>>2];c[m+12>>2]=c[e+12>>2];ga(26,n|0,m|0);d=o;o=0;if((d|0)!=0&(p|0)!=0){g=SN(c[d>>2]|0,s|0,j|0)|0;if(!g)Ua(d|0,p|0);z=p}else g=-1;if((g|0)==1){d=z;continue};c[e>>2]=c[n>>2];c[e+4>>2]=c[n+4>>2];c[e+8>>2]=c[n+8>>2];c[e+12>>2]=c[n+12>>2];h=e+16|0;o=0;c[m>>2]=c[h>>2];c[m+4>>2]=c[h+4>>2];c[m+8>>2]=c[h+8>>2];c[m+12>>2]=c[h+12>>2];ga(26,q|0,m|0);d=o;o=0;if((d|0)!=0&(p|0)!=0){g=SN(c[d>>2]|0,s|0,j|0)|0;if(!g)Ua(d|0,p|0);z=p}else g=-1;if((g|0)==1){d=z;continue};c[h>>2]=c[q>>2];c[h+4>>2]=c[q+4>>2];c[h+8>>2]=c[q+8>>2];c[h+12>>2]=c[q+12>>2];c[42490]=0;o=0;fa(93,4);d=o;o=0;if((d|0)!=0&(p|0)!=0){g=SN(c[d>>2]|0,s|0,j|0)|0;if(!g)Ua(d|0,p|0);z=p}else g=-1;if((g|0)==1){d=z;continue}g=c[42491]|0;d=c[42490]|0;c[42490]=d+1;d=g+(d<<4)|0;c[d>>2]=c[r>>2];c[d+4>>2]=c[r+4>>2];c[d+8>>2]=c[r+8>>2];c[d+12>>2]=c[r+12>>2];o=0;c[k>>2]=c[e>>2];c[k+4>>2]=c[e+4>>2];c[k+8>>2]=c[e+8>>2];c[k+12>>2]=c[e+12>>2];c[m>>2]=c[h>>2];c[m+4>>2]=c[h+4>>2];c[m+8>>2]=c[h+8>>2];c[m+12>>2]=c[h+12>>2];d=da(1,a|0,b|0,r|0,i|0,k|0,m|0)|0;g=o;o=0;if((g|0)!=0&(p|0)!=0){h=SN(c[g>>2]|0,s|0,j|0)|0;if(!h)Ua(g|0,p|0);z=p}else h=-1;if((h|0)==1)d=z;else{t=8;break}}if((t|0)==8)if((d|0)==-1)d=-1;else{c[f+4>>2]=c[42490];c[f>>2]=c[42491];d=0}_I(s|0);l=u;return d|0}function iI(a,b){a=a|0;b=b|0;var d=0.0,e=0,f=0.0,g=0.0,i=0.0;d=+h[b>>3];e=b+8|0;f=+h[e>>3];i=f*f+d*d;g=+C(+i);if(i>1.0e-06){h[b>>3]=d/g;h[e>>3]=f/g};c[a>>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];c[a+12>>2]=c[b+12>>2];return}function jI(a){a=a|0;var b=0,d=0,e=0,f=0;f=l;l=l+32|0;e=f+16|0;d=f;if((c[42494]|0)<(a|0)){b=c[42491]|0;if(!b){e=ZI(a<<4)|0;c[42491]=e;if(!e){e=c[13918]|0;c[d>>2]=125476;c[d+4>>2]=531;c[d+8>>2]=125611;zL(e,125484,d)|0;Ua(169804,1)}}else{d=aJ(b,a<<4)|0;c[42491]=d;if(!d){d=c[13918]|0;c[e>>2]=125476;c[e+4>>2]=537;c[e+8>>2]=125629;zL(d,125484,e)|0;Ua(169804,1)}}c[42494]=a}l=f;return}function kI(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var i=0,j=0.0,k=0,m=0.0,n=0,o=0.0,p=0.0,q=0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0.0,U=0.0,V=0.0,W=0.0;R=l;l=l+336|0;J=R+320|0;I=R+304|0;w=R+144|0;q=R+128|0;G=R+112|0;H=R+96|0;Q=R+80|0;A=R+64|0;C=R+48|0;K=R+32|0;L=R+16|0;M=R;x=R+288|0;y=R+272|0;z=R+256|0;B=R+240|0;D=R+224|0;E=R+208|0;N=R+192|0;O=R+176|0;P=R+160|0;i=c[42493]|0;do if((c[42492]|0)<(e|0)){if(!i){i=ZI(e*40|0)|0;c[42493]=i;if(!i){i=-1;break}}else{i=aJ(i,e*40|0)|0;c[42493]=i;if(!i){i=-1;break}}c[42492]=e;k=6}else k=6;while(0);if((k|0)==6){h[i>>3]=0.0;k=1;j=0.0;while(1){if((k|0)>=(e|0))break;n=d+(k<<4)|0;F=d+(k+-1<<4)|0;c[I>>2]=c[n>>2];c[I+4>>2]=c[n+4>>2];c[I+8>>2]=c[n+8>>2];c[I+12>>2]=c[n+12>>2];c[J>>2]=c[F>>2];c[J+4>>2]=c[F+4>>2];c[J+8>>2]=c[F+8>>2];c[J+12>>2]=c[F+12>>2];v=+lI(I,J)+j;h[i+(k*40|0)>>3]=v;k=k+1|0;j=v}F=e+-1|0;n=i+(F*40|0)|0;k=1;while(1){if((k|0)>=(e|0))break;S=i+(k*40|0)|0;h[S>>3]=+h[S>>3]/+h[n>>3];k=k+1|0}k=0;while(1){if((k|0)>=(e|0))break;S=i+(k*40|0)+8|0;n=i+(k*40|0)|0;v=+mI(+h[n>>3]);c[J>>2]=c[f>>2];c[J+4>>2]=c[f+4>>2];c[J+8>>2]=c[f+8>>2];c[J+12>>2]=c[f+12>>2];nI(x,J,v);c[S>>2]=c[x>>2];c[S+4>>2]=c[x+4>>2];c[S+8>>2]=c[x+8>>2];c[S+12>>2]=c[x+12>>2];S=i+(k*40|0)+24|0;v=+oI(+h[n>>3]);c[J>>2]=c[g>>2];c[J+4>>2]=c[g+4>>2];c[J+8>>2]=c[g+8>>2];c[J+12>>2]=c[g+12>>2];nI(y,J,v);c[S>>2]=c[y>>2];c[S+4>>2]=c[y+4>>2];c[S+8>>2]=c[y+8>>2];c[S+12>>2]=c[y+12>>2];k=k+1|0}c[I>>2]=c[f>>2];c[I+4>>2]=c[f+4>>2];c[I+8>>2]=c[f+8>>2];c[I+12>>2]=c[f+12>>2];c[J>>2]=c[g>>2];c[J+4>>2]=c[g+4>>2];c[J+8>>2]=c[g+8>>2];c[J+12>>2]=c[g+12>>2];pI(d,e,i,I,J,G,A,H,C);c[q>>2]=c[G>>2];c[q+4>>2]=c[G+4>>2];c[q+8>>2]=c[G+8>>2];c[q+12>>2]=c[G+12>>2];c[w>>2]=c[A>>2];c[w+4>>2]=c[A+4>>2];c[w+8>>2]=c[A+8>>2];c[w+12>>2]=c[A+12>>2];c[I>>2]=c[H>>2];c[I+4>>2]=c[H+4>>2];c[I+8>>2]=c[H+8>>2];c[I+12>>2]=c[H+12>>2];c[J>>2]=c[C>>2];c[J+4>>2]=c[C+4>>2];c[J+8>>2]=c[C+8>>2];c[J+12>>2]=c[C+12>>2];if(!(qI(a,b,q,w,I,J,d,e)|0)){c[J>>2]=c[A>>2];c[J+4>>2]=c[A+4>>2];c[J+8>>2]=c[A+8>>2];c[J+12>>2]=c[A+12>>2];nI(z,J,.3333333333333333);c[I>>2]=c[G>>2];c[I+4>>2]=c[G+4>>2];c[I+8>>2]=c[G+8>>2];c[I+12>>2]=c[G+12>>2];c[J>>2]=c[z>>2];c[J+4>>2]=c[z+4>>2];c[J+8>>2]=c[z+8>>2];c[J+12>>2]=c[z+12>>2];rI(B,I,J);v=+h[B>>3];u=+h[B+8>>3];c[J>>2]=c[C>>2];c[J+4>>2]=c[C+4>>2];c[J+8>>2]=c[C+8>>2];c[J+12>>2]=c[C+12>>2];nI(D,J,.3333333333333333);c[I>>2]=c[H>>2];c[I+4>>2]=c[H+4>>2];c[I+8>>2]=c[H+8>>2];c[I+12>>2]=c[H+12>>2];c[J>>2]=c[D>>2];c[J+4>>2]=c[D+4>>2];c[J+8>>2]=c[D+8>>2];c[J+12>>2]=c[D+12>>2];sI(E,I,J);t=+h[E>>3];p=+h[E+8>>3];q=c[42493]|0;r=+h[G>>3];s=+h[H>>3];o=+h[G+8>>3];m=+h[H+8>>3];n=Q+8|0;i=-1;j=-1.0;k=1;while(1){if((k|0)>=(F|0))break;T=+h[q+(k*40|0)>>3];U=+tI(T);V=+mI(T);W=+oI(T);T=+uI(T);h[Q>>3]=V*v+r*U+W*t+s*T;h[n>>3]=W*p+V*u+o*U+m*T;S=d+(k<<4)|0;c[I>>2]=c[Q>>2];c[I+4>>2]=c[Q+4>>2];c[I+8>>2]=c[Q+8>>2];c[I+12>>2]=c[Q+12>>2];c[J>>2]=c[S>>2];c[J+4>>2]=c[S+4>>2];c[J+8>>2]=c[S+8>>2];c[J+12>>2]=c[S+12>>2];T=+lI(I,J);S=T>j;i=S?k:i;j=S?T:j;k=k+1|0}S=d+(i<<4)|0;Q=d+(i+-1<<4)|0;c[I>>2]=c[S>>2];c[I+4>>2]=c[S+4>>2];c[I+8>>2]=c[S+8>>2];c[I+12>>2]=c[S+12>>2];c[J>>2]=c[Q>>2];c[J+4>>2]=c[Q+4>>2];c[J+8>>2]=c[Q+8>>2];c[J+12>>2]=c[Q+12>>2];sI(N,I,J);c[J>>2]=c[N>>2];c[J+4>>2]=c[N+4>>2];c[J+8>>2]=c[N+8>>2];c[J+12>>2]=c[N+12>>2];iI(L,J);Q=i+1|0;N=d+(Q<<4)|0;c[I>>2]=c[N>>2];c[I+4>>2]=c[N+4>>2];c[I+8>>2]=c[N+8>>2];c[I+12>>2]=c[N+12>>2];c[J>>2]=c[S>>2];c[J+4>>2]=c[S+4>>2];c[J+8>>2]=c[S+8>>2];c[J+12>>2]=c[S+12>>2];sI(O,I,J);c[J>>2]=c[O>>2];c[J+4>>2]=c[O+4>>2];c[J+8>>2]=c[O+8>>2];c[J+12>>2]=c[O+12>>2];iI(M,J);c[I>>2]=c[L>>2];c[I+4>>2]=c[L+4>>2];c[I+8>>2]=c[L+8>>2];c[I+12>>2]=c[L+12>>2];c[J>>2]=c[M>>2];c[J+4>>2]=c[M+4>>2];c[J+8>>2]=c[M+8>>2];c[J+12>>2]=c[M+12>>2];rI(P,I,J);c[J>>2]=c[P>>2];c[J+4>>2]=c[P+4>>2];c[J+8>>2]=c[P+8>>2];c[J+12>>2]=c[P+12>>2];iI(K,J);c[I>>2]=c[f>>2];c[I+4>>2]=c[f+4>>2];c[I+8>>2]=c[f+8>>2];c[I+12>>2]=c[f+12>>2];c[J>>2]=c[K>>2];c[J+4>>2]=c[K+4>>2];c[J+8>>2]=c[K+8>>2];c[J+12>>2]=c[K+12>>2];kI(a,b,d,Q,I,J)|0;c[I>>2]=c[K>>2];c[I+4>>2]=c[K+4>>2];c[I+8>>2]=c[K+8>>2];c[I+12>>2]=c[K+12>>2];c[J>>2]=c[g>>2];c[J+4>>2]=c[g+4>>2];c[J+8>>2]=c[g+8>>2];c[J+12>>2]=c[g+12>>2];kI(a,b,S,e-i|0,I,J)|0;i=0}else i=0}l=R;return i|0}function lI(a,b){a=a|0;b=b|0;var c=0.0,d=0.0;c=+h[b>>3]-+h[a>>3];d=+h[b+8>>3]-+h[a+8>>3];return +(+C(+(d*d+c*c)))}function mI(a){a=+a;var b=0.0;b=1.0-a;return +(b*b*(a*3.0))}function nI(a,b,d){a=a|0;b=b|0;d=+d;var e=0;h[b>>3]=+h[b>>3]*d;e=b+8|0;h[e>>3]=+h[e>>3]*d;c[a>>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];c[a+12>>2]=c[b+12>>2];return}function oI(a){a=+a;return +(a*a*3.0*(1.0-a))}function pI(a,b,d,e,f,g,i,j,k){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;i=i|0;j=j|0;k=k|0;var m=0.0,n=0.0,o=0.0,p=0.0,q=0,r=0,s=0,t=0,u=0,v=0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0,C=0,D=0,E=0,F=0,G=0,H=0.0,I=0.0,J=0,K=0,L=0,M=0;G=l;l=l+128|0;B=G+112|0;v=G+80|0;u=G;r=G+96|0;s=G+64|0;t=G+48|0;C=G+32|0;D=G+16|0;E=a+(b+-1<<4)|0;q=0;w=0.0;x=0.0;y=0.0;z=0.0;A=0.0;while(1){if((q|0)>=(b|0))break;K=d+(q*40|0)+8|0;c[v>>2]=c[K>>2];c[v+4>>2]=c[K+4>>2];c[v+8>>2]=c[K+8>>2];c[v+12>>2]=c[K+12>>2];c[B>>2]=c[K>>2];c[B+4>>2]=c[K+4>>2];c[B+8>>2]=c[K+8>>2];c[B+12>>2]=c[K+12>>2];H=+AI(v,B)+x;J=d+(q*40|0)+24|0;c[v>>2]=c[K>>2];c[v+4>>2]=c[K+4>>2];c[v+8>>2]=c[K+8>>2];c[v+12>>2]=c[K+12>>2];c[B>>2]=c[J>>2];c[B+4>>2]=c[J+4>>2];c[B+8>>2]=c[J+8>>2];c[B+12>>2]=c[J+12>>2];p=+AI(v,B)+A;c[v>>2]=c[J>>2];c[v+4>>2]=c[J+4>>2];c[v+8>>2]=c[J+8>>2];c[v+12>>2]=c[J+12>>2];c[B>>2]=c[J>>2];c[B+4>>2]=c[J+4>>2];c[B+8>>2]=c[J+8>>2];c[B+12>>2]=c[J+12>>2];o=+AI(v,B)+y;L=a+(q<<4)|0;M=d+(q*40|0)|0;I=+BI(+h[M>>3]);c[B>>2]=c[a>>2];c[B+4>>2]=c[a+4>>2];c[B+8>>2]=c[a+8>>2];c[B+12>>2]=c[a+12>>2];nI(s,B,I);I=+CI(+h[M>>3]);c[B>>2]=c[E>>2];c[B+4>>2]=c[E+4>>2];c[B+8>>2]=c[E+8>>2];c[B+12>>2]=c[E+12>>2];nI(t,B,I);c[v>>2]=c[s>>2];c[v+4>>2]=c[s+4>>2];c[v+8>>2]=c[s+8>>2];c[v+12>>2]=c[s+12>>2];c[B>>2]=c[t>>2];c[B+4>>2]=c[t+4>>2];c[B+8>>2]=c[t+8>>2];c[B+12>>2]=c[t+12>>2];rI(r,v,B);c[v>>2]=c[L>>2];c[v+4>>2]=c[L+4>>2];c[v+8>>2]=c[L+8>>2];c[v+12>>2]=c[L+12>>2];c[B>>2]=c[r>>2];c[B+4>>2]=c[r+4>>2];c[B+8>>2]=c[r+8>>2];c[B+12>>2]=c[r+12>>2];sI(u,v,B);c[v>>2]=c[K>>2];c[v+4>>2]=c[K+4>>2];c[v+8>>2]=c[K+8>>2];c[v+12>>2]=c[K+12>>2];c[B>>2]=c[u>>2];c[B+4>>2]=c[u+4>>2];c[B+8>>2]=c[u+8>>2];c[B+12>>2]=c[u+12>>2];I=+AI(v,B)+w;c[v>>2]=c[J>>2];c[v+4>>2]=c[J+4>>2];c[v+8>>2]=c[J+8>>2];c[v+12>>2]=c[J+12>>2];c[B>>2]=c[u>>2];c[B+4>>2]=c[u+4>>2];c[B+8>>2]=c[u+8>>2];c[B+12>>2]=c[u+12>>2];q=q+1|0;w=I;x=H;y=o;z=+AI(v,B)+z;A=p}o=y*x-A*A;p=o>=0.0?o:-o;if(!(p>=1.0e-06?(m=(y*w-A*z)/o,n=(x*z-A*w)/o,!(p<1.0e-06|m<=0.0|n<=0.0)):0))F=6;if((F|0)==6){c[v>>2]=c[a>>2];c[v+4>>2]=c[a+4>>2];c[v+8>>2]=c[a+8>>2];c[v+12>>2]=c[a+12>>2];c[B>>2]=c[E>>2];c[B+4>>2]=c[E+4>>2];c[B+8>>2]=c[E+8>>2];c[B+12>>2]=c[E+12>>2];m=+lI(v,B)*.3333333333333333;n=m};c[g>>2]=c[a>>2];c[g+4>>2]=c[a+4>>2];c[g+8>>2]=c[a+8>>2];c[g+12>>2]=c[a+12>>2];c[B>>2]=c[e>>2];c[B+4>>2]=c[e+4>>2];c[B+8>>2]=c[e+8>>2];c[B+12>>2]=c[e+12>>2];nI(C,B,m);c[i>>2]=c[C>>2];c[i+4>>2]=c[C+4>>2];c[i+8>>2]=c[C+8>>2];c[i+12>>2]=c[C+12>>2];c[j>>2]=c[E>>2];c[j+4>>2]=c[E+4>>2];c[j+8>>2]=c[E+8>>2];c[j+12>>2]=c[E+12>>2];c[B>>2]=c[f>>2];c[B+4>>2]=c[f+4>>2];c[B+8>>2]=c[f+8>>2];c[B+12>>2]=c[f+12>>2];nI(D,B,n);c[k>>2]=c[D>>2];c[k+4>>2]=c[D+4>>2];c[k+8>>2]=c[D+8>>2];c[k+12>>2]=c[D+12>>2];l=G;return}function qI(a,b,d,e,f,g,i,j){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;i=i|0;j=j|0;var k=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0,r=0.0,s=0.0,t=0,u=0.0,v=0,w=0.0,x=0,y=0.0,z=0,A=0,B=0,C=0,D=0.0,E=0;C=l;l=l+64|0;B=C;z=(j|0)==2;y=+h[d>>3];u=+h[d+8>>3];v=B+8|0;w=+h[e>>3];x=B+16|0;p=+h[e+8>>3];q=B+24|0;r=+h[f>>3];s=+h[g>>3];t=B+32|0;o=+h[f+8>>3];n=+h[g+8>>3];e=B+40|0;f=B+48|0;g=B+56|0;d=1;k=4.0;m=4.0;while(1){h[B>>3]=y;h[v>>3]=u;D=m*.3333333333333333;h[x>>3]=D*w+y;h[q>>3]=D*p+u;D=k*.3333333333333333;h[t>>3]=r-D*s;h[e>>3]=o-D*n;h[f>>3]=r;h[g>>3]=o;if(d?(D=+vI(B,4),D<+vI(i,j)+-.001):0){d=0;break}if(wI(a,b,B)|0){A=5;break}if(m==0.0&k==0.0){A=9;break}E=m>.01;d=0;k=E?k*.5:0.0;m=E?m*.5:0.0}a:do if((A|0)==5){jI((c[42490]|0)+4|0);e=c[42491]|0;d=1;while(1){if((d|0)==4){d=1;break a}E=c[42490]|0;h[e+(E<<4)>>3]=+h[B+(d<<4)>>3];D=+h[B+(d<<4)+8>>3];c[42490]=E+1;h[e+(E<<4)+8>>3]=D;d=d+1|0}}else if((A|0)==9)if(z){jI((c[42490]|0)+4|0);e=c[42491]|0;d=1;while(1){if((d|0)==4){d=1;break a}E=c[42490]|0;h[e+(E<<4)>>3]=+h[B+(d<<4)>>3];D=+h[B+(d<<4)+8>>3];c[42490]=E+1;h[e+(E<<4)+8>>3]=D;d=d+1|0}}else d=0;while(0);l=C;return d|0}function rI(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;h[b>>3]=+h[b>>3]+ +h[d>>3];e=b+8|0;h[e>>3]=+h[e>>3]+ +h[d+8>>3];c[a>>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];c[a+12>>2]=c[b+12>>2];return}function sI(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;h[b>>3]=+h[b>>3]-+h[d>>3];e=b+8|0;h[e>>3]=+h[e>>3]-+h[d+8>>3];c[a>>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];c[a+12>>2]=c[b+12>>2];return}function tI(a){a=+a;a=1.0-a;return +(a*a*a)}function uI(a){a=+a;return +(a*a*a)}function vI(a,b){a=a|0;b=b|0;var c=0.0,d=0,e=0.0,f=0.0,g=0;c=0.0;d=1;while(1){if((d|0)>=(b|0))break;g=d+-1|0;e=+h[a+(d<<4)>>3]-+h[a+(g<<4)>>3];f=+h[a+(d<<4)+8>>3]-+h[a+(g<<4)+8>>3];c=+C(+(f*f+e*e))+c;d=d+1|0}return +c}function wI(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0,u=0,v=0.0,w=0,x=0.0,y=0,z=0,A=0,B=0,C=0,D=0.0,E=0.0;C=l;l=l+64|0;t=C+32|0;u=C;w=u+16|0;y=d+16|0;z=d+32|0;A=d+48|0;B=d+8|0;g=d+24|0;i=d+40|0;j=d+56|0;k=u+8|0;m=u+24|0;f=0;a:while(1){if((f|0)>=(b|0)){e=1;break}n=a+(f<<5)|0;c[u>>2]=c[n>>2];c[u+4>>2]=c[n+4>>2];c[u+8>>2]=c[n+8>>2];c[u+12>>2]=c[n+12>>2];n=a+(f<<5)+16|0;c[w>>2]=c[n>>2];c[w+4>>2]=c[n+4>>2];c[w+8>>2]=c[n+8>>2];c[w+12>>2]=c[n+12>>2];n=xI(d,u,t)|0;b:do if((n|0)!=4){o=+h[u>>3];p=+h[k>>3];q=+h[w>>3];r=+h[m>>3];e=0;while(1){if((e|0)>=(n|0))break b;s=+h[t+(e<<3)>>3];if((!(s<1.0e-06|s>.999999)?(x=s*s*s,E=s*3.0,D=1.0-s,s=E*s*D,v=D*D,E=v*E,D=v*D,v=+h[y>>3]*E+ +h[d>>3]*D+ +h[z>>3]*s+ +h[A>>3]*x,x=+h[g>>3]*E+ +h[B>>3]*D+ +h[i>>3]*s+ +h[j>>3]*x,s=v-o,D=x-p,!(D*D+s*s<.001)):0)?(E=v-q,D=x-r,!(D*D+E*E<.001)):0){e=0;break a}e=e+1|0}}while(0);f=f+1|0}l=C;return e|0}function xI(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0.0,i=0,j=0.0,k=0,m=0,n=0,o=0,p=0.0,q=0.0,r=0,s=0,t=0,u=0,v=0;v=l;l=l+96|0;s=v+48|0;t=v+24|0;k=v;u=v+80|0;p=+h[b>>3];g=+h[b+16>>3]-p;q=+h[b+8>>3];j=+h[b+24>>3]-q;c[u>>2]=0;a:do if(!(g==0.0)){j=j/g;m=a+16|0;n=a+32|0;o=a+48|0;yI(+h[a+8>>3]-+h[a>>3]*j,+h[a+24>>3]-+h[m>>3]*j,+h[a+40>>3]-+h[n>>3]*j,+h[a+56>>3]-+h[o>>3]*j,s);h[s>>3]=j*p-q+ +h[s>>3];e=UI(s,t)|0;if((e|0)==4)b=4;else{f=s+8|0;i=s+16|0;k=s+24|0;g=1.0/g;b=0;while(1){if((b|0)>=(e|0))break;j=+h[t+(b<<3)>>3];if(j>=0.0&j<=1.0?(yI(+h[a>>3],+h[m>>3],+h[n>>3],+h[o>>3],s),q=(+h[s>>3]-p+((+h[k>>3]*j+ +h[i>>3])*j+ +h[f>>3])*j)*g,q>=0.0&q<=1.0):0)zI(j,d,u);b=b+1|0}b=c[u>>2]|0}}else{yI(+h[a>>3],+h[a+16>>3],+h[a+32>>3],+h[a+48>>3],s);h[s>>3]=+h[s>>3]-p;r=UI(s,t)|0;if(!(j==0.0)){if((r|0)==4){b=4;break}m=a+8|0;n=a+24|0;o=a+40|0;e=a+56|0;f=s+8|0;i=s+16|0;k=s+24|0;g=1.0/j;b=0;while(1){if((b|0)>=(r|0))break;j=+h[t+(b<<3)>>3];if(j>=0.0&j<=1.0?(yI(+h[m>>3],+h[n>>3],+h[o>>3],+h[e>>3],s),p=(+h[s>>3]-q+((+h[k>>3]*j+ +h[i>>3])*j+ +h[f>>3])*j)*g,p>=0.0&p<=1.0):0)zI(j,d,u);b=b+1|0}b=c[u>>2]|0;break}yI(+h[a+8>>3],+h[a+24>>3],+h[a+40>>3],+h[a+56>>3],s);h[s>>3]=+h[s>>3]-q;i=UI(s,k)|0;b=(i|0)==4;b:do if((r|0)==4){if(b){b=4;break a}else b=0;while(1){if((b|0)>=(i|0))break b;zI(+h[k+(b<<3)>>3],d,u);b=b+1|0}}else{if(b){b=0;while(1){if((b|0)>=(r|0))break b;zI(+h[t+(b<<3)>>3],d,u);b=b+1|0}}else e=0;while(1){if((e|0)>=(r|0))break b;f=t+(e<<3)|0;b=0;while(1){if((b|0)>=(i|0))break;g=+h[f>>3];if(g==+h[k+(b<<3)>>3])zI(g,d,u);b=b+1|0}e=e+1|0}}while(0);b=c[u>>2]|0}while(0);l=v;return b|0}function yI(a,b,c,d,e){a=+a;b=+b;c=+c;d=+d;e=e|0;h[e+24>>3]=d-a+(b-c)*3.0;h[e+16>>3]=(c+a)*3.0-b*6.0;h[e+8>>3]=(b-a)*3.0;h[e>>3]=a;return}function zI(a,b,d){a=+a;b=b|0;d=d|0;var e=0;if(a>=0.0&a<=1.0){e=c[d>>2]|0;h[b+(e<<3)>>3]=a;c[d>>2]=e+1}return}function AI(a,b){a=a|0;b=b|0;return +(+h[b+8>>3]*+h[a+8>>3]+ +h[b>>3]*+h[a>>3])}function BI(a){a=+a;var b=0.0;b=1.0-a;return +(b*b*(b+a*3.0))}function CI(a){a=+a;return +(a*a*((1.0-a)*3.0+a))} +function sx(d,f,g){d=d|0;f=f|0;g=g|0;var i=0,j=0,k=0,m=0.0,n=0,o=0.0,p=0,q=0.0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0;Y=l;l=l+2288|0;W=Y+208|0;V=Y+192|0;U=Y+176|0;T=Y+160|0;S=Y+144|0;R=Y+128|0;P=Y+112|0;O=Y+96|0;N=Y+80|0;M=Y+64|0;L=Y+56|0;K=Y+48|0;X=Y+32|0;Q=Y+24|0;J=Y;G=Y+1264|0;H=Y+224|0;I=d+16|0;C=(e[(c[I>>2]|0)+178>>1]|0)>2;Fv(1);jx(d);cm(H,1024,Y+240|0);tB(d,1,87657,174181)|0;tB(d,1,87661,174181)|0;c[42190]=tB(d,1,96043,174181)|0;c[42189]=tB(d,1,96049,174181)|0;tB(d,2,87657,174181)|0;i=a[(c[I>>2]|0)+113>>0]|0;if(i&16){tB(d,1,87667,174181)|0;i=a[(c[I>>2]|0)+113>>0]|0}if(i&1){tB(d,2,87671,174181)|0;i=a[(c[I>>2]|0)+113>>0]|0}if(i&32){tB(d,2,87667,174181)|0;i=a[(c[I>>2]|0)+113>>0]|0}if(i&2){tB(d,2,87674,174181)|0;i=a[(c[I>>2]|0)+113>>0]|0}if(i&4){tB(d,2,87682,174181)|0;i=a[(c[I>>2]|0)+113>>0]|0}if(!(i&8)){v=0;w=0;x=0}else{x=tB(d,0,87671,174181)|0;w=tB(d,0,87690,174181)|0;v=tB(d,0,87697,174181)|0}z=tB(d,0,87705,174181)|0;A=H+4|0;B=H+8|0;u=0;i=0;y=co(d)|0;while(1){if(!y)break;t=y+16|0;k=c[t>>2]|0;o=+h[k+16>>3];j=(c[42183]|0)==0;if(C){if(j)m=+h[k+24>>3];else m=+h[20895]-+h[k+24>>3];q=+h[(c[k+132>>2]|0)+16>>3]*72.0;h[J>>3]=o;h[J+8>>3]=m;h[J+16>>3]=q;pL(G,87708,J)|0;fm(H,G)|0;j=3;while(1){if((j|0)>=(e[(c[I>>2]|0)+178>>1]|0))break;h[Q>>3]=+h[(c[(c[t>>2]|0)+132>>2]|0)+(j<<3)>>3]*72.0;pL(G,87723,Q)|0;fm(H,G)|0;j=j+1|0}j=c[A>>2]|0;if(j>>>0>=(c[B>>2]|0)>>>0){dm(H,1)|0;j=c[A>>2]|0}a[j>>0]=0;s=c[H>>2]|0;c[A>>2]=s;Km(y,87657,s)|0;s=y}else{if(j)m=+h[k+24>>3];else m=+h[20895]-+h[k+24>>3];h[X>>3]=o;h[X+8>>3]=m;pL(G,87729,X)|0;Km(y,87657,G)|0;s=y}h[K>>3]=+h[(c[t>>2]|0)+80>>3]*.013888888888888888;pL(G,87652,K)|0;Cm(s,c[42189]|0,G)|0;j=c[t>>2]|0;h[L>>3]=(+h[j+96>>3]+ +h[j+88>>3])*.013888888888888888;pL(G,87652,L)|0;Cm(s,c[42190]|0,G)|0;j=c[t>>2]|0;k=c[j+108>>2]|0;if((k|0)!=0?(a[k+81>>0]|0)!=0:0){q=+h[k+64>>3];q=(c[42183]|0)==0?q:+h[20895]-q;h[M>>3]=+h[k+56>>3];h[M+8>>3]=q;pL(G,87729,M)|0;Km(s,87667,G)|0;j=c[t>>2]|0}if(xJ(c[c[j+8>>2]>>2]|0,91264)|0){if(c[42214]|0?(Oy(y)|0)<<24>>24:0){k=c[(c[t>>2]|0)+12>>2]|0;r=k+8|0;j=c[r>>2]|0;if((j|0)<3){j=Im(s,87739)|0;if(!j)j=8;else j=rM(j)|0;j=(j|0)<3?8:j}p=k+44|0;q=1.0/+(j|0);n=0;while(1){if((n|0)>=(j|0))break;if((n|0)>0){k=c[A>>2]|0;if(k>>>0>=(c[B>>2]|0)>>>0){dm(H,1)|0;k=c[A>>2]|0}c[A>>2]=k+1;a[k>>0]=32}if((c[r>>2]|0)>2){k=c[p>>2]|0;if(!(c[42183]|0))m=+h[k+(n<<4)+8>>3]*.013888888888888888;else m=+h[20896]-+h[k+(n<<4)+8>>3]*.013888888888888888;h[N>>3]=+h[k+(n<<4)>>3]*.013888888888888888;h[N+8>>3]=m;pL(G,87752,N)|0}else{k=c[t>>2]|0;m=q*+(n|0)*6.283185307179586;o=+h[k+32>>3]*.5*+E(+m);if(!(c[42183]|0))m=+h[k+40>>3]*.5*+F(+m);else m=+h[20896]-+h[k+40>>3]*.5*+F(+m);h[O>>3]=o;h[O+8>>3]=m;pL(G,87752,O)|0}fm(H,G)|0;n=n+1|0}k=c[42214]|0;j=c[A>>2]|0;if(j>>>0>=(c[B>>2]|0)>>>0){dm(H,1)|0;j=c[A>>2]|0}a[j>>0]=0;t=c[H>>2]|0;c[A>>2]=t;Cm(s,k,t)|0}}else{tx(y,c[j+12>>2]|0,H);hm(H)|0;j=c[A>>2]|0;if(j>>>0>=(c[B>>2]|0)>>>0){dm(H,1)|0;j=c[A>>2]|0}a[j>>0]=0;t=c[H>>2]|0;c[A>>2]=t;Km(s,87661,t)|0}a:do if((c[42181]|0)>0){t=Pm(d,y)|0;j=u;while(1){if(!t)break a;s=t+16|0;k=c[s>>2]|0;do if((a[k+112>>0]|0)!=6?(D=c[k+8>>2]|0,(D|0)!=0):0){r=0;k=D;while(1){if((r|0)>=(c[k+4>>2]|0))break;if((r|0)>0){k=c[A>>2]|0;if(k>>>0>=(c[B>>2]|0)>>>0){dm(H,1)|0;k=c[A>>2]|0}c[A>>2]=k+1;a[k>>0]=59;k=c[(c[s>>2]|0)+8>>2]|0}k=c[k>>2]|0;if(c[k+(r*48|0)+8>>2]|0){if(!(c[42183]|0))m=+h[k+(r*48|0)+24>>3];else m=+h[20895]-+h[k+(r*48|0)+24>>3];h[P>>3]=+h[k+(r*48|0)+16>>3];h[P+8>>3]=m;pL(G,87762,P)|0;fm(H,G)|0;i=1;k=c[c[(c[s>>2]|0)+8>>2]>>2]|0}if(c[k+(r*48|0)+12>>2]|0){if(!(c[42183]|0))m=+h[k+(r*48|0)+40>>3];else m=+h[20895]-+h[k+(r*48|0)+40>>3];h[R>>3]=+h[k+(r*48|0)+32>>3];h[R+8>>3]=m;pL(G,87775,R)|0;fm(H,G)|0;j=1}p=0;while(1){k=c[(c[s>>2]|0)+8>>2]|0;n=c[k>>2]|0;if((p|0)>=(c[n+(r*48|0)+4>>2]|0))break;if((p|0)>0){k=c[A>>2]|0;if(k>>>0>=(c[B>>2]|0)>>>0){dm(H,1)|0;k=c[A>>2]|0}c[A>>2]=k+1;a[k>>0]=32;k=c[c[(c[s>>2]|0)+8>>2]>>2]|0}else k=n;u=c[k+(r*48|0)>>2]|0;q=+h[u+(p<<4)+8>>3];q=(c[42183]|0)==0?q:+h[20895]-q;h[S>>3]=+h[u+(p<<4)>>3];h[S+8>>3]=q;pL(G,87729,S)|0;fm(H,G)|0;p=p+1|0}r=r+1|0}k=c[A>>2]|0;if(k>>>0>=(c[B>>2]|0)>>>0){dm(H,1)|0;k=c[A>>2]|0}a[k>>0]=0;k=c[H>>2]|0;c[A>>2]=k;Km(t,87657,k)|0;k=c[s>>2]|0;n=c[k+96>>2]|0;if(n){q=+h[n+64>>3];q=(c[42183]|0)==0?q:+h[20895]-q;h[T>>3]=+h[n+56>>3];h[T+8>>3]=q;pL(G,87729,T)|0;Km(t,87671,G)|0;k=c[s>>2]|0}n=c[k+108>>2]|0;do if(n){if(!(a[n+81>>0]|0))break;q=+h[n+64>>3];q=(c[42183]|0)==0?q:+h[20895]-q;h[U>>3]=+h[n+56>>3];h[U+8>>3]=q;pL(G,87729,U)|0;Km(t,87667,G)|0;k=c[s>>2]|0}while(0);n=c[k+100>>2]|0;if(n){q=+h[n+64>>3];q=(c[42183]|0)==0?q:+h[20895]-q;h[V>>3]=+h[n+56>>3];h[V+8>>3]=q;pL(G,87729,V)|0;Km(t,87674,G)|0;k=c[s>>2]|0}k=c[k+104>>2]|0;if(!k)break;q=+h[k+64>>3];q=(c[42183]|0)==0?q:+h[20895]-q;h[W>>3]=+h[k+56>>3];h[W+8>>3]=q;pL(G,87729,W)|0;Km(t,87682,G)|0}while(0);t=Rm(d,t)|0}}else j=u;while(0);u=j;y=eo(d,y)|0}ux(d,z,x,w,v);gm(H);if(b[(c[I>>2]|0)+136>>1]&1)nB(d);c[f>>2]=i;c[g>>2]=u;Fv(0);l=Y;return}function tx(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0.0,g=0.0,i=0.0,j=0,k=0,m=0,n=0,o=0.0;n=l;l=l+1056|0;k=n;j=n+32|0;m=b+48|0;if(!(c[m>>2]|0)){e=c[a+16>>2]|0;i=+h[e+16>>3];if(!(c[42183]|0)){g=+h[e+24>>3];f=g+ +h[b+24>>3];g=g+ +h[b+40>>3]}else{g=+h[e+24>>3];f=+h[20895]-+h[b+24>>3]-g;g=+h[20895]-+h[b+40>>3]-g}o=i+ +h[b+32>>3];h[k>>3]=i+ +h[b+16>>3];h[k+8>>3]=f;h[k+16>>3]=o;h[k+24>>3]=g;pL(j,87813,k)|0;fm(d,j)|0}b=b+56|0;e=0;while(1){if((e|0)>=(c[m>>2]|0))break;tx(a,c[(c[b>>2]|0)+(e<<2)>>2]|0,d);e=e+1|0}l=n;return}function ux(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var i=0,j=0,k=0.0,m=0.0,n=0,o=0,p=0,q=0,r=0,s=0,t=0.0;s=l;l=l+1088|0;o=s+56|0;q=s+48|0;p=s+32|0;j=s;n=s+64|0;r=b+16|0;i=c[r>>2]|0;if(!(c[42183]|0)){k=+h[i+24>>3];m=+h[i+40>>3]}else{m=+h[20895];k=m-+h[i+24>>3];m=m-+h[i+40>>3]}t=+h[i+32>>3];h[j>>3]=+h[i+16>>3];h[j+8>>3]=k;h[j+16>>3]=t;h[j+24>>3]=m;pL(n,87788,j)|0;Cm(b,d,n)|0;i=c[(c[r>>2]|0)+12>>2]|0;if((i|0)!=0?(a[c[i>>2]>>0]|0)!=0:0){t=+h[i+64>>3];t=(c[42183]|0)==0?t:+h[20895]-t;h[p>>3]=+h[i+56>>3];h[p+8>>3]=t;pL(n,87729,p)|0;Cm(b,e,n)|0;i=c[(c[r>>2]|0)+12>>2]|0;t=+h[i+32>>3];h[q>>3]=+h[i+24>>3]*.013888888888888888;pL(n,87808,q)|0;Cm(b,f,n)|0;h[o>>3]=t*.013888888888888888;pL(n,87808,o)|0;Cm(b,g,n)|0;i=1}else i=1;while(1){j=c[r>>2]|0;if((i|0)>(c[j+180>>2]|0))break;ux(c[(c[j+184>>2]|0)+(i<<2)>>2]|0,d,e,f,g);i=i+1|0}l=s;return}function vx(a){a=a|0;var b=0;b=l;l=l+16|0;sx(a,b,b+4|0);l=b;return}function wx(){return Ql(19796,c[4345]|0)|0}function xx(a,b,c){a=a|0;b=b|0;c=c|0;_I(b);return}function yx(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;a=c[b>>2]|0;e=c[d>>2]|0;if((a|0)<=(e|0))if((a|0)<(e|0))a=-1;else{b=c[b+4>>2]|0;d=c[d+4>>2]|0;return ((b|0)>(d|0)?1:((b|0)<(d|0))<<31>>31)|0}else a=1;return a|0}function zx(a){a=a|0;Kl(a)|0;return}function Ax(a,b){a=a|0;b=b|0;var d=0,e=0;d=l;l=l+16|0;e=d;c[e>>2]=c[b>>2];c[e+4>>2]=c[b+4>>2];b=Bx(e)|0;if((bb[c[a>>2]&31](a,b,1)|0)!=(b|0))_I(b);l=d;return}function Bx(a){a=a|0;var b=0,d=0,e=0;b=vw(16)|0;e=a;d=c[e+4>>2]|0;a=b+8|0;c[a>>2]=c[e>>2];c[a+4>>2]=d;return b|0}function Cx(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;e=l;l=l+16|0;f=e+8|0;g=e;c[g>>2]=b;c[g+4>>2]=d;c[f>>2]=c[g>>2];c[f+4>>2]=c[g+4>>2];b=Bx(f)|0;if((bb[c[a>>2]&31](a,b,1)|0)!=(b|0))_I(b);l=e;return}function Dx(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;d=l;l=l+16|0;e=d;g=b;f=c[g+4>>2]|0;b=e+8|0;c[b>>2]=c[g>>2];c[b+4>>2]=f;b=(bb[c[a>>2]&31](a,e,4)|0)!=0&1;l=d;return b|0}function Ex(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=l;l=l+16|0;f=e;c[f+8>>2]=b;c[f+12>>2]=d;d=(bb[c[a>>2]&31](a,f,4)|0)!=0&1;l=e;return d|0}function Fx(a){a=a|0;return Sl(a)|0}function Gx(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;d=vw((Sl(a)|0)<<3)|0;b=d;a=Ol(a)|0;while(1){if(!a)break;g=a+8|0;f=c[g+4>>2]|0;e=b;c[e>>2]=c[g>>2];c[e+4>>2]=f;b=b+8|0;a=c[a>>2]|0}return d|0}function Hx(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,g=0.0,i=0.0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;t=l;l=l+160|0;q=t+144|0;d=t+48|0;j=t+128|0;k=t+112|0;m=t+96|0;n=t+80|0;o=t+32|0;p=t+16|0;r=t;s=a+16|0;a=c[s>>2]|0;e=+h[a+16>>3];f=+h[a+24>>3];g=+h[a+32>>3];i=+h[a+40>>3];if((b+-1|0)>>>0<2){Ix(j,e,i);c[q>>2]=c[j>>2];c[q+4>>2]=c[j+4>>2];c[q+8>>2]=c[j+8>>2];c[q+12>>2]=c[j+12>>2];Jx(d,q);p=d+16|0;Ix(k,g,f);c[q>>2]=c[k>>2];c[q+4>>2]=c[k+4>>2];c[q+8>>2]=c[k+8>>2];c[q+12>>2]=c[k+12>>2];Jx(m,q);c[p>>2]=c[m>>2];c[p+4>>2]=c[m+4>>2];c[p+8>>2]=c[m+8>>2];c[p+12>>2]=c[m+12>>2]}else{Ix(n,e,f);c[q>>2]=c[n>>2];c[q+4>>2]=c[n+4>>2];c[q+8>>2]=c[n+8>>2];c[q+12>>2]=c[n+12>>2];Jx(d,q);n=d+16|0;Ix(o,g,i);c[q>>2]=c[o>>2];c[q+4>>2]=c[o+4>>2];c[q+8>>2]=c[o+8>>2];c[q+12>>2]=c[o+12>>2];Jx(p,q);c[n>>2]=c[p>>2];c[n+4>>2]=c[p+4>>2];c[n+8>>2]=c[p+8>>2];c[n+12>>2]=c[p+12>>2]}a=(c[s>>2]|0)+16|0;c[a>>2]=c[d>>2];c[a+4>>2]=c[d+4>>2];c[a+8>>2]=c[d+8>>2];c[a+12>>2]=c[d+12>>2];c[a+16>>2]=c[d+16>>2];c[a+20>>2]=c[d+20>>2];c[a+24>>2]=c[d+24>>2];c[a+28>>2]=c[d+28>>2];a=c[(c[s>>2]|0)+12>>2]|0;if(!a)a=1;else{a=a+56|0;c[q>>2]=c[a>>2];c[q+4>>2]=c[a+4>>2];c[q+8>>2]=c[a+8>>2];c[q+12>>2]=c[a+12>>2];Jx(r,q);c[a>>2]=c[r>>2];c[a+4>>2]=c[r+4>>2];c[a+8>>2]=c[r+8>>2];c[a+12>>2]=c[r+12>>2];a=1}while(1){d=c[s>>2]|0;if((a|0)>(c[d+180>>2]|0))break;Hx(c[(c[d+184>>2]|0)+(a<<2)>>2]|0,b);a=a+1|0}l=t;return}function Ix(a,b,c){a=a|0;b=+b;c=+c;h[a>>3]=b;h[a+8>>3]=c;return}function Jx(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;d=l;l=l+32|0;g=d+16|0;e=d;f=(c[42309]|0)*90|0;c[g>>2]=c[b>>2];c[g+4>>2]=c[b+4>>2];c[g+8>>2]=c[b+8>>2];c[g+12>>2]=c[b+12>>2];aw(e,g,f);c[b>>2]=c[e>>2];c[b+4>>2]=c[e+4>>2];c[b+8>>2]=c[e+8>>2];c[b+12>>2]=c[e+12>>2];h[b>>3]=+h[b>>3]-+h[20897];e=b+8|0;h[e>>3]=+h[e>>3]-+h[20898];c[a>>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];c[a+12>>2]=c[b+12>>2];l=d;return}function Kx(b,d){b=b|0;d=d|0;var e=0,f=0.0,g=0,i=0,j=0.0,k=0.0,m=0,n=0.0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;w=l;l=l+1168|0;s=w+144|0;v=w+96|0;u=w+64|0;t=w+48|0;o=w+32|0;p=w+16|0;q=w;c[t>>2]=0;c[t+4>>2]=0;c[t+8>>2]=0;c[t+12>>2]=0;r=b+16|0;m=c[(c[r>>2]|0)+116>>2]|0;c[42309]=m&3;m=m&1;a[174079]=m;if(!(m<<24>>24))Mx(b);else Lx(b);Nx(b);m=c[r>>2]|0;e=c[m+12>>2]|0;do if(e|0?(a[e+81>>0]|0)==0:0){g=e+24|0;c[t>>2]=c[g>>2];c[t+4>>2]=c[g+4>>2];c[t+8>>2]=c[g+8>>2];c[t+12>>2]=c[g+12>>2];n=+h[t>>3]+16.0;h[t>>3]=n;g=t+8|0;f=+h[g>>3]+8.0;h[g>>3]=f;g=(a[m+275>>0]&1)!=0;if(a[174079]|0){if(g){i=m+32|0;h[i>>3]=+h[i>>3]+f}else{i=m+16|0;h[i>>3]=+h[i>>3]-f}g=m+40|0;f=+h[g>>3];i=m+24|0;j=+h[i>>3];k=f-j;if(!(n>k))break;n=(n-k)*.5;h[i>>3]=j-n;h[g>>3]=f+n;break}i=(c[42309]|0)==0;do if(g)if(i){i=m+40|0;h[i>>3]=+h[i>>3]+f;break}else{i=m+24|0;h[i>>3]=+h[i>>3]-f;break}else if(i){i=m+24|0;h[i>>3]=+h[i>>3]-f;break}else{i=m+40|0;h[i>>3]=+h[i>>3]+f;break}while(0);g=m+32|0;f=+h[g>>3];i=m+16|0;j=+h[i>>3];k=f-j;if(n>k){n=(n-k)*.5;h[i>>3]=j-n;h[g>>3]=f+n}}while(0);if(d){switch(c[42309]|0){case 0:{q=m+16|0;c[41794]=c[q>>2];c[41795]=c[q+4>>2];c[41796]=c[q+8>>2];c[41797]=c[q+12>>2];break}case 1:{Ix(o,-+h[m+40>>3],+h[m+16>>3]);c[41794]=c[o>>2];c[41795]=c[o+4>>2];c[41796]=c[o+8>>2];c[41797]=c[o+12>>2];break}case 2:{Ix(p,+h[m+16>>3],-+h[m+40>>3]);c[41794]=c[p>>2];c[41795]=c[p+4>>2];c[41796]=c[p+8>>2];c[41797]=c[p+12>>2];break}case 3:{Ix(q,+h[m+24>>3],+h[m+16>>3]);c[41794]=c[q>>2];c[41795]=c[q+4>>2];c[41796]=c[q+8>>2];c[41797]=c[q+12>>2];break}default:{}}Ox(b);e=c[(c[r>>2]|0)+12>>2]|0}if(e|0?(a[e+81>>0]|0)==0:0){c[s>>2]=c[t>>2];c[s+4>>2]=c[t+4>>2];c[s+8>>2]=c[t+8>>2];c[s+12>>2]=c[t+12>>2];Px(b,s)}if(!0){l=w;return}if(!(a[174079]|0)){n=+h[20898];k=+h[20897];h[v>>3]=n;h[v+8>>3]=k;h[v+16>>3]=n;h[v+24>>3]=k;h[v+32>>3]=-k;h[v+40>>3]=-n;pL(s,88049,v)|0}else{k=+h[20897];n=+h[20898];h[u>>3]=k;h[u+8>>3]=n;h[u+16>>3]=k;h[u+24>>3]=n;pL(s,87834,u)|0}GL(s)|0;Ta()}function Lx(b){b=b|0;var d=0,e=0.0,f=0.0,g=0,i=0,j=0;j=b+16|0;if(((so(b)|0)!=(b|0)?(g=c[j>>2]|0,i=c[g+12>>2]|0,(i|0)!=0):0)?(a[i+81>>0]|0)==0:0){d=a[g+275>>0]|0;if(!(d&1)){f=+h[g+16>>3]+ +h[g+96>>3]*.5;b=g+104|0}else{f=+h[g+32>>3]-+h[g+64>>3]*.5;b=g+72|0}e=+h[b>>3];b=d<<24>>24;do if(!(b&4))if(!(b&2)){e=(+h[g+40>>3]+ +h[g+24>>3])*.5;break}else{e=+h[g+40>>3]-e*.5;break}else e=+h[g+24>>3]+e*.5;while(0);h[i+56>>3]=f;h[i+64>>3]=e;a[(c[(c[j>>2]|0)+12>>2]|0)+81>>0]=1;b=1}else b=1;while(1){d=c[j>>2]|0;if((b|0)>(c[d+180>>2]|0))break;Lx(c[(c[d+184>>2]|0)+(b<<2)>>2]|0);b=b+1|0}return}function Mx(b){b=b|0;var d=0,e=0.0,f=0.0,g=0.0,i=0,j=0,k=0;k=b+16|0;if(((so(b)|0)!=(b|0)?(i=c[k>>2]|0,j=c[i+12>>2]|0,(j|0)!=0):0)?(a[j+81>>0]|0)==0:0){d=a[i+275>>0]|0;if(!(d&1)){g=+h[i+24>>3]+ +h[i+56>>3]*.5;b=i+48|0}else{g=+h[i+40>>3]-+h[i+88>>3]*.5;b=i+80|0}f=+h[b>>3];b=d<<24>>24;do if(!(b&4)){e=+h[i+16>>3];if(!(b&2)){e=(+h[i+32>>3]+e)*.5;break}else{e=e+f*.5;break}}else e=+h[i+32>>3]-f*.5;while(0);h[j+56>>3]=e;h[j+64>>3]=g;a[(c[(c[k>>2]|0)+12>>2]|0)+81>>0]=1;b=1}else b=1;while(1){d=c[k>>2]|0;if((b|0)>(c[d+180>>2]|0))break;Mx(c[(c[d+184>>2]|0)+(b<<2)>>2]|0);b=b+1|0}return}function Nx(e){e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0;S=l;l=l+544|0;L=S+504|0;R=S+416|0;Q=S+376|0;K=S+352|0;J=S+312|0;I=S+288|0;H=S+248|0;M=S+200|0;B=S+152|0;O=S+96|0;p=S+488|0;C=S+456|0;D=S+424|0;E=S+384|0;F=S+360|0;G=S+320|0;w=S+296|0;x=S+256|0;y=S+232|0;z=S+168|0;A=S+136|0;f=S+56|0;N=S+16|0;P=S;o=e+16|0;u=c[o>>2]|0;g=b[u+136>>1]&14;u=d[u+113>>0]|0;if(!((u&54|0)==0?(u&1|0)==0|(c[42182]|0)!=0:0)){u=g<<16>>16==0;n=co(e)|0;h=0;j=0;i=0;while(1){if(!n)break;g=c[(c[n+16>>2]|0)+108>>2]|0;do if(g)if(!(a[g+81>>0]|0)){i=i+1|0;break}else{h=h+1|0;break}while(0);m=Pm(e,n)|0;g=j;while(1){if(!m)break;k=c[m+16>>2]|0;j=c[k+108>>2]|0;do if(j){if(a[j+81>>0]|0){h=h+1|0;break}if(!u)g=g+((c[k+8>>2]|0)!=0&1)|0}while(0);j=c[k+100>>2]|0;do if(j){if(a[j+81>>0]|0){h=h+1|0;break}if(!u)g=g+((c[k+8>>2]|0)!=0&1)|0}while(0);j=c[k+104>>2]|0;do if(j){if(a[j+81>>0]|0){h=h+1|0;break}if(!u)g=g+((c[k+8>>2]|0)!=0&1)|0}while(0);j=c[k+96>>2]|0;do if(j){if(a[j+81>>0]|0){h=h+1|0;break}if(!u)g=g+((c[k+8>>2]|0)!=0&1)|0}while(0);m=Rm(e,m)|0}n=eo(e,n)|0;j=g}if(!(a[(c[o>>2]|0)+113>>0]&8))o=0;else o=Rx(e)|0;t=j+i|0;if(t|0){q=h+j+o+(mn(e)|0)|0;r=vw(q*40|0)|0;s=vw(t*40|0)|0;Ix(M,2147483647.0,2147483647.0);g=M+16|0;Ix(p,-2147483647.0,-2147483647.0);c[g>>2]=c[p>>2];c[g+4>>2]=c[p+4>>2];c[g+8>>2]=c[p+8>>2];c[g+12>>2]=c[p+12>>2];g=s;i=r;n=co(e)|0;while(1){if(!n)break;c[L>>2]=c[M>>2];c[L+4>>2]=c[M+4>>2];c[L+8>>2]=c[M+8>>2];c[L+12>>2]=c[M+12>>2];c[L+16>>2]=c[M+16>>2];c[L+20>>2]=c[M+20>>2];c[L+24>>2]=c[M+24>>2];c[L+28>>2]=c[M+28>>2];Sx(C,n,i,L);c[M>>2]=c[C>>2];c[M+4>>2]=c[C+4>>2];c[M+8>>2]=c[C+8>>2];c[M+12>>2]=c[C+12>>2];c[M+16>>2]=c[C+16>>2];c[M+20>>2]=c[C+20>>2];c[M+24>>2]=c[C+24>>2];c[M+28>>2]=c[C+28>>2];h=c[(c[n+16>>2]|0)+108>>2]|0;do if(h)if(!(a[h+81>>0]|0)){c[L>>2]=c[B>>2];c[L+4>>2]=c[B+4>>2];c[L+8>>2]=c[B+8>>2];c[L+12>>2]=c[B+12>>2];Ux(h,i,g,0,L);g=g+40|0;break}else{i=i+40|0;c[L>>2]=c[M>>2];c[L+4>>2]=c[M+4>>2];c[L+8>>2]=c[M+8>>2];c[L+12>>2]=c[M+12>>2];c[L+16>>2]=c[M+16>>2];c[L+20>>2]=c[M+20>>2];c[L+24>>2]=c[M+24>>2];c[L+28>>2]=c[M+28>>2];Tx(D,h,i,L);c[M>>2]=c[D>>2];c[M+4>>2]=c[D+4>>2];c[M+8>>2]=c[D+8>>2];c[M+12>>2]=c[D+12>>2];c[M+16>>2]=c[D+16>>2];c[M+20>>2]=c[D+20>>2];c[M+24>>2]=c[D+24>>2];c[M+28>>2]=c[D+28>>2];break}while(0);m=Pm(e,n)|0;i=i+40|0;while(1){if(!m)break;k=m+16|0;h=c[k>>2]|0;j=c[h+96>>2]|0;a:do if(!j)v=52;else{do if(!(a[j+81>>0]|0)){if(!u?c[h+8>>2]|0:0){$z(F,e,m);c[L>>2]=c[F>>2];c[L+4>>2]=c[F+4>>2];c[L+8>>2]=c[F+8>>2];c[L+12>>2]=c[F+12>>2];Ux(j,i,g,1,L);g=g+40|0;break}c[H>>2]=c[j>>2];_l(0,88861,H)|0;break a}else{c[L>>2]=c[M>>2];c[L+4>>2]=c[M+4>>2];c[L+8>>2]=c[M+8>>2];c[L+12>>2]=c[M+12>>2];c[L+16>>2]=c[M+16>>2];c[L+20>>2]=c[M+20>>2];c[L+24>>2]=c[M+24>>2];c[L+28>>2]=c[M+28>>2];Tx(E,j,i,L);c[M>>2]=c[E>>2];c[M+4>>2]=c[E+4>>2];c[M+8>>2]=c[E+8>>2];c[M+12>>2]=c[E+12>>2];c[M+16>>2]=c[E+16>>2];c[M+20>>2]=c[E+20>>2];c[M+24>>2]=c[E+24>>2];c[M+28>>2]=c[E+28>>2]}while(0);i=i+40|0;h=c[k>>2]|0;v=52}while(0);b:do if((v|0)==52){v=0;j=c[h+104>>2]|0;if(j){do if(!(a[j+81>>0]|0)){if(!u?c[h+8>>2]|0:0){Vx(w,m);c[L>>2]=c[w>>2];c[L+4>>2]=c[w+4>>2];c[L+8>>2]=c[w+8>>2];c[L+12>>2]=c[w+12>>2];Ux(j,i,g,1,L);g=g+40|0;break}c[I>>2]=c[j>>2];_l(0,88896,I)|0;break b}else{c[L>>2]=c[M>>2];c[L+4>>2]=c[M+4>>2];c[L+8>>2]=c[M+8>>2];c[L+12>>2]=c[M+12>>2];c[L+16>>2]=c[M+16>>2];c[L+20>>2]=c[M+20>>2];c[L+24>>2]=c[M+24>>2];c[L+28>>2]=c[M+28>>2];Tx(G,j,i,L);c[M>>2]=c[G>>2];c[M+4>>2]=c[G+4>>2];c[M+8>>2]=c[G+8>>2];c[M+12>>2]=c[G+12>>2];c[M+16>>2]=c[G+16>>2];c[M+20>>2]=c[G+20>>2];c[M+24>>2]=c[G+24>>2];c[M+28>>2]=c[G+28>>2]}while(0);i=i+40|0;h=c[k>>2]|0}j=c[h+100>>2]|0;if(j){do if(!(a[j+81>>0]|0)){if(!u?c[h+8>>2]|0:0){Wx(y,m);c[L>>2]=c[y>>2];c[L+4>>2]=c[y+4>>2];c[L+8>>2]=c[y+8>>2];c[L+12>>2]=c[y+12>>2];Ux(j,i,g,1,L);g=g+40|0;break}c[J>>2]=c[j>>2];_l(0,88936,J)|0;break b}else{c[L>>2]=c[M>>2];c[L+4>>2]=c[M+4>>2];c[L+8>>2]=c[M+8>>2];c[L+12>>2]=c[M+12>>2];c[L+16>>2]=c[M+16>>2];c[L+20>>2]=c[M+20>>2];c[L+24>>2]=c[M+24>>2];c[L+28>>2]=c[M+28>>2];Tx(x,j,i,L);c[M>>2]=c[x>>2];c[M+4>>2]=c[x+4>>2];c[M+8>>2]=c[x+8>>2];c[M+12>>2]=c[x+12>>2];c[M+16>>2]=c[x+16>>2];c[M+20>>2]=c[x+20>>2];c[M+24>>2]=c[x+24>>2];c[M+28>>2]=c[x+28>>2]}while(0);i=i+40|0;h=c[k>>2]|0}j=c[h+108>>2]|0;if(j){do if(!(a[j+81>>0]|0)){if(!u?c[h+8>>2]|0:0){$z(A,e,m);c[L>>2]=c[A>>2];c[L+4>>2]=c[A+4>>2];c[L+8>>2]=c[A+8>>2];c[L+12>>2]=c[A+12>>2];Ux(j,i,g,1,L);g=g+40|0;break}c[K>>2]=c[j>>2];_l(0,88976,K)|0;break b}else{c[L>>2]=c[M>>2];c[L+4>>2]=c[M+4>>2];c[L+8>>2]=c[M+8>>2];c[L+12>>2]=c[M+12>>2];c[L+16>>2]=c[M+16>>2];c[L+20>>2]=c[M+20>>2];c[L+24>>2]=c[M+24>>2];c[L+28>>2]=c[M+28>>2];Tx(z,j,i,L);c[M>>2]=c[z>>2];c[M+4>>2]=c[z+4>>2];c[M+8>>2]=c[z+8>>2];c[M+12>>2]=c[z+12>>2];c[M+16>>2]=c[z+16>>2];c[M+20>>2]=c[z+20>>2];c[M+24>>2]=c[z+24>>2];c[M+28>>2]=c[z+28>>2]}while(0);i=i+40|0}}while(0);m=Rm(e,m)|0}n=eo(e,n)|0}if(o|0){c[f>>2]=c[M>>2];c[f+4>>2]=c[M+4>>2];c[f+8>>2]=c[M+8>>2];c[f+12>>2]=c[M+12>>2];c[f+16>>2]=c[M+16>>2];c[f+20>>2]=c[M+20>>2];c[f+24>>2]=c[M+24>>2];c[f+28>>2]=c[M+28>>2];c[f+32>>2]=i;h=L;g=h+40|0;do{c[h>>2]=c[f>>2];h=h+4|0;f=f+4|0}while((h|0)<(g|0));Xx(N,e,L);c[M>>2]=c[N>>2];c[M+4>>2]=c[N+4>>2];c[M+8>>2]=c[N+8>>2];c[M+12>>2]=c[N+12>>2];c[M+16>>2]=c[N+16>>2];c[M+20>>2]=c[N+20>>2];c[M+24>>2]=c[N+24>>2];c[M+28>>2]=c[N+28>>2]}a[O+32>>0]=HA(e,ym(e,0,89012,0)|0,1)|0;c[O>>2]=c[M>>2];c[O+4>>2]=c[M+4>>2];c[O+8>>2]=c[M+8>>2];c[O+12>>2]=c[M+12>>2];c[O+16>>2]=c[M+16>>2];c[O+20>>2]=c[M+20>>2];c[O+24>>2]=c[M+24>>2];c[O+28>>2]=c[M+28>>2];zE(r,q,s,t,O)|0;if(0)Yx(r,q,s,t,O);f=0;g=0;h=s;while(1){if((g|0)>=(t|0))break;if(a[h+36>>0]|0){O=c[h+32>>2]|0;a[O+81>>0]=1;N=O+56|0;Zx(P,h);c[N>>2]=c[P>>2];c[N+4>>2]=c[P+4>>2];c[N+8>>2]=c[P+8>>2];c[N+12>>2]=c[P+12>>2];bB(e,O);f=f+1|0}g=g+1|0;h=h+40|0}if(!0){if((f|0)!=(t|0)){c[R>>2]=f;c[R+4>>2]=t;_l(0,89057,R)|0}}else{R=c[13918]|0;c[Q>>2]=f;c[Q+4>>2]=t;zL(R,89024,Q)|0}_I(r);_I(s)}}l=S;return}function Ox(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,i=0,j=0;i=l;l=l+48|0;e=i+32|0;f=i+16|0;g=i;if(+h[20897]!=0.0|+h[20898]!=0.0|(c[42309]|0)!=0){d=co(a)|0;while(1){if(!d)break;if(c[42309]|0)KB(d,0);b=d+16|0;j=(c[b>>2]|0)+16|0;c[e>>2]=c[j>>2];c[e+4>>2]=c[j+4>>2];c[e+8>>2]=c[j+8>>2];c[e+12>>2]=c[j+12>>2];Jx(f,e);c[j>>2]=c[f>>2];c[j+4>>2]=c[f+4>>2];c[j+8>>2]=c[f+8>>2];c[j+12>>2]=c[f+12>>2];b=c[(c[b>>2]|0)+108>>2]|0;if(b|0){j=b+56|0;c[e>>2]=c[j>>2];c[e+4>>2]=c[j+4>>2];c[e+8>>2]=c[j+8>>2];c[e+12>>2]=c[j+12>>2];Jx(g,e);c[j>>2]=c[g>>2];c[j+4>>2]=c[g+4>>2];c[j+8>>2]=c[g+8>>2];c[j+12>>2]=c[g+12>>2]}a:do if((c[42181]|0)==1){b=Pm(a,d)|0;while(1){if(!b)break a;Qx(b);b=Rm(a,b)|0}}while(0);d=eo(a,d)|0}Hx(a,c[(c[a+16>>2]|0)+116>>2]&3)}l=i;return}function Px(b,d){b=b|0;d=d|0;var e=0.0,f=0.0,g=0,i=0,j=0;i=b+16|0;j=c[i>>2]|0;g=a[j+275>>0]|0;b=g<<24>>24;do if(!(b&4)){e=+h[j+16>>3];if(!(b&2)){f=(+h[j+32>>3]+e)*.5;break}else{f=+h[d>>3]*.5+e;break}}else f=+h[j+32>>3]-+h[d>>3]*.5;while(0);if(!(g&1))e=+h[d+8>>3]*.5+ +h[j+24>>3];else e=+h[j+40>>3]-+h[d+8>>3]*.5;j=c[j+12>>2]|0;h[j+56>>3]=f;h[j+64>>3]=e;a[(c[(c[i>>2]|0)+12>>2]|0)+81>>0]=1;return}function Qx(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;s=l;l=l+144|0;q=s+120|0;e=s+16|0;i=s+104|0;j=s+88|0;k=s+72|0;m=s+56|0;n=s+40|0;o=s+24|0;r=s;p=b+16|0;d=c[p>>2]|0;f=c[d+8>>2]|0;if(!f){if((a[174076]|0)==0?(a[d+112>>0]|0)!=6:0){q=Dn(c[((c[b>>2]&3|0)==3?b:b+48|0)+40>>2]|0)|0;r=Dn(c[((c[b>>2]&3|0)==2?b:b+-48|0)+40>>2]|0)|0;c[e>>2]=q;c[e+4>>2]=r;_l(1,88844,e)|0}}else{h=0;b=f;while(1){if((h|0)>=(c[b+4>>2]|0))break;g=c[b>>2]|0;b=c[g+(h*48|0)>>2]|0;e=c[g+(h*48|0)+4>>2]|0;f=c[g+(h*48|0)+8>>2]|0;g=c[g+(h*48|0)+12>>2]|0;d=0;while(1){if((d|0)>=(e|0))break;t=b+(d<<4)|0;c[q>>2]=c[t>>2];c[q+4>>2]=c[t+4>>2];c[q+8>>2]=c[t+8>>2];c[q+12>>2]=c[t+12>>2];Jx(i,q);c[t>>2]=c[i>>2];c[t+4>>2]=c[i+4>>2];c[t+8>>2]=c[i+8>>2];c[t+12>>2]=c[i+12>>2];d=d+1|0}if(f|0){t=(c[c[(c[p>>2]|0)+8>>2]>>2]|0)+(h*48|0)+16|0;c[q>>2]=c[t>>2];c[q+4>>2]=c[t+4>>2];c[q+8>>2]=c[t+8>>2];c[q+12>>2]=c[t+12>>2];Jx(j,q);c[t>>2]=c[j>>2];c[t+4>>2]=c[j+4>>2];c[t+8>>2]=c[j+8>>2];c[t+12>>2]=c[j+12>>2]}if(g|0){t=(c[c[(c[p>>2]|0)+8>>2]>>2]|0)+(h*48|0)+32|0;c[q>>2]=c[t>>2];c[q+4>>2]=c[t+4>>2];c[q+8>>2]=c[t+8>>2];c[q+12>>2]=c[t+12>>2];Jx(k,q);c[t>>2]=c[k>>2];c[t+4>>2]=c[k+4>>2];c[t+8>>2]=c[k+8>>2];c[t+12>>2]=c[k+12>>2]}d=c[p>>2]|0;h=h+1|0;b=c[d+8>>2]|0}b=c[d+96>>2]|0;if(b){d=b+56|0;c[q>>2]=c[d>>2];c[q+4>>2]=c[d+4>>2];c[q+8>>2]=c[d+8>>2];c[q+12>>2]=c[d+12>>2];Jx(m,q);c[d>>2]=c[m>>2];c[d+4>>2]=c[m+4>>2];c[d+8>>2]=c[m+8>>2];c[d+12>>2]=c[m+12>>2];d=c[p>>2]|0}b=c[d+108>>2]|0;if(b){d=b+56|0;c[q>>2]=c[d>>2];c[q+4>>2]=c[d+4>>2];c[q+8>>2]=c[d+8>>2];c[q+12>>2]=c[d+12>>2];Jx(n,q);c[d>>2]=c[n>>2];c[d+4>>2]=c[n+4>>2];c[d+8>>2]=c[n+8>>2];c[d+12>>2]=c[n+12>>2];d=c[p>>2]|0}b=c[d+100>>2]|0;if(b){d=b+56|0;c[q>>2]=c[d>>2];c[q+4>>2]=c[d+4>>2];c[q+8>>2]=c[d+8>>2];c[q+12>>2]=c[d+12>>2];Jx(o,q);c[d>>2]=c[o>>2];c[d+4>>2]=c[o+4>>2];c[d+8>>2]=c[o+8>>2];c[d+12>>2]=c[o+12>>2];d=c[p>>2]|0}d=c[d+104>>2]|0;if(d|0){t=d+56|0;c[q>>2]=c[t>>2];c[q+4>>2]=c[t+4>>2];c[q+8>>2]=c[t+8>>2];c[q+12>>2]=c[t+12>>2];Jx(r,q);c[t>>2]=c[r>>2];c[t+4>>2]=c[r+4>>2];c[t+8>>2]=c[r+8>>2];c[t+12>>2]=c[r+12>>2]}}l=s;return}function Rx(b){b=b|0;var d=0,e=0,f=0;f=b+16|0;if((so(b)|0)!=(b|0)?(d=c[(c[f>>2]|0)+12>>2]|0,(d|0)!=0):0){e=1;b=(a[d+81>>0]|0)!=0&1}else{e=1;b=0}while(1){d=c[f>>2]|0;if((e|0)>(c[d+180>>2]|0))break;d=(Rx(c[(c[d+184>>2]|0)+(e<<2)>>2]|0)|0)+b|0;e=e+1|0;b=d}return b|0}function Sx(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,i=0,j=0.0,k=0.0,m=0,n=0;g=l;l=l+32|0;i=g;n=(a[174079]|0)==0;d=d+16|0;m=c[d>>2]|0;k=+h[(n?m+32|0:m+40|0)>>3];h[e+16>>3]=k*72.0;j=+h[(n?m+40|0:m+32|0)>>3];h[e+24>>3]=j*72.0;d=(c[d>>2]|0)+16|0;c[e>>2]=c[d>>2];c[e+4>>2]=c[d+4>>2];c[e+8>>2]=c[d+8>>2];c[e+12>>2]=c[d+12>>2];h[e>>3]=+h[e>>3]-k*36.0;d=e+8|0;h[d>>3]=+h[d>>3]-j*36.0;c[i>>2]=c[f>>2];c[i+4>>2]=c[f+4>>2];c[i+8>>2]=c[f+8>>2];c[i+12>>2]=c[f+12>>2];c[i+16>>2]=c[f+16>>2];c[i+20>>2]=c[f+20>>2];c[i+24>>2]=c[f+24>>2];c[i+28>>2]=c[f+28>>2];_x(b,e,i);l=g;return}function Tx(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,i=0,j=0.0,k=0.0,m=0,n=0;g=l;l=l+32|0;i=g;n=(a[174079]|0)==0;m=d+24|0;k=+h[(n?m:d+32|0)>>3];h[e+16>>3]=k;j=+h[(n?d+32|0:m)>>3];h[e+24>>3]=j;d=d+56|0;c[e>>2]=c[d>>2];c[e+4>>2]=c[d+4>>2];c[e+8>>2]=c[d+8>>2];c[e+12>>2]=c[d+12>>2];h[e>>3]=+h[e>>3]-k*.5;d=e+8|0;h[d>>3]=+h[d>>3]-j*.5;c[i>>2]=c[f>>2];c[i+4>>2]=c[f+4>>2];c[i+8>>2]=c[f+8>>2];c[i+12>>2]=c[f+12>>2];c[i+16>>2]=c[f+16>>2];c[i+20>>2]=c[f+20>>2];c[i+24>>2]=c[f+24>>2];c[i+28>>2]=c[f+28>>2];_x(b,e,i);l=g;return}function Ux(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;if(f|0){f=d+16|0;c[f>>2]=0;c[f+4>>2]=0;c[f+8>>2]=0;c[f+12>>2]=0;c[d>>2]=c[g>>2];c[d+4>>2]=c[g+4>>2];c[d+8>>2]=c[g+8>>2];c[d+12>>2]=c[g+12>>2]}if(!(a[174079]|0)){g=b+24|0;c[e>>2]=c[g>>2];c[e+4>>2]=c[g+4>>2];c[e+8>>2]=c[g+8>>2];c[e+12>>2]=c[g+12>>2]}else{h[e>>3]=+h[b+32>>3];h[e+8>>3]=+h[b+24>>3]}c[e+32>>2]=b;a[e+36>>0]=0;c[d+32>>2]=e;return}function Vx(a,b){a=a|0;b=b|0;b=_z(b)|0;do if(b){b=c[b>>2]|0;if(!(c[b+8>>2]|0)){b=c[b>>2]|0;c[a>>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];c[a+12>>2]=c[b+12>>2];break}else{b=b+16|0;c[a>>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];c[a+12>>2]=c[b+12>>2];break}}else{c[a>>2]=0;c[a+4>>2]=0;c[a+8>>2]=0;c[a+12>>2]=0}while(0);return}function Wx(a,b){a=a|0;b=b|0;var d=0;b=_z(b)|0;do if(b){d=c[b>>2]|0;b=(c[b+4>>2]|0)+-1|0;if(!(c[d+(b*48|0)+12>>2]|0)){d=(c[d+(b*48|0)>>2]|0)+((c[d+(b*48|0)+4>>2]|0)+-1<<4)|0;c[a>>2]=c[d>>2];c[a+4>>2]=c[d+4>>2];c[a+8>>2]=c[d+8>>2];c[a+12>>2]=c[d+12>>2];break}else{d=d+(b*48|0)+32|0;c[a>>2]=c[d>>2];c[a+4>>2]=c[d+4>>2];c[a+8>>2]=c[d+8>>2];c[a+12>>2]=c[d+12>>2];break}}else{c[a>>2]=0;c[a+4>>2]=0;c[a+8>>2]=0;c[a+12>>2]=0}while(0);return}function Xx(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0;q=l;l=l+112|0;k=q+72|0;n=q+32|0;o=q;p=d+16|0;j=1;while(1){f=c[p>>2]|0;if((j|0)>(c[f+180>>2]|0))break;f=c[(c[f+184>>2]|0)+(j<<2)>>2]|0;g=k;h=e;i=g+40|0;do{c[g>>2]=c[h>>2];g=g+4|0;h=h+4|0}while((g|0)<(i|0));Xx(n,f,k);g=e;h=n;i=g+40|0;do{c[g>>2]=c[h>>2];g=g+4|0;h=h+4|0}while((g|0)<(i|0));j=j+1|0}if(((so(d)|0)!=(d|0)?(m=c[(c[p>>2]|0)+12>>2]|0,m|0):0)?a[m+81>>0]|0:0){p=e+32|0;n=c[p>>2]|0;c[k>>2]=c[e>>2];c[k+4>>2]=c[e+4>>2];c[k+8>>2]=c[e+8>>2];c[k+12>>2]=c[e+12>>2];c[k+16>>2]=c[e+16>>2];c[k+20>>2]=c[e+20>>2];c[k+24>>2]=c[e+24>>2];c[k+28>>2]=c[e+28>>2];Tx(o,m,n,k);c[e>>2]=c[o>>2];c[e+4>>2]=c[o+4>>2];c[e+8>>2]=c[o+8>>2];c[e+12>>2]=c[o+12>>2];c[e+16>>2]=c[o+16>>2];c[e+20>>2]=c[o+20>>2];c[e+24>>2]=c[o+24>>2];c[e+28>>2]=c[o+28>>2];c[p>>2]=(c[p>>2]|0)+40}g=b;h=e;i=g+40|0;do{c[g>>2]=c[h>>2];g=g+4|0;h=h+4|0}while((g|0)<(i|0));l=q;return}function Yx(a,b,e,f,g){a=a|0;b=b|0;e=e|0;f=f|0;g=g|0;var i=0.0,j=0.0,k=0.0,m=0.0,n=0,o=0,p=0,q=0,r=0,s=0;s=l;l=l+160|0;r=s+96|0;p=s+48|0;o=s;q=c[13918]|0;n=d[g+32>>0]|0;i=+h[g>>3];j=+h[g+8>>3];k=+h[g+16>>3];m=+h[g+24>>3];c[o>>2]=b;c[o+4>>2]=f;c[o+8>>2]=n;h[o+16>>3]=i;h[o+24>>3]=j;h[o+32>>3]=k;h[o+40>>3]=m;zL(q,89099,o)|0;a:do if(0>=2){XL(89159,8,1,q)|0;o=0;while(1){if((o|0)>=(b|0))break;g=c[a+32>>2]|0;i=+h[a>>3];j=+h[a+8>>3];k=+h[a+16>>3];m=+h[a+24>>3];if(!g)n=174181;else n=c[c[g+32>>2]>>2]|0;c[p>>2]=o;h[p+8>>3]=i;h[p+16>>3]=j;h[p+24>>3]=k;h[p+32>>3]=m;c[p+40>>2]=g;c[p+44>>2]=n;zL(q,89168,p)|0;o=o+1|0;a=a+40|0}XL(89211,8,1,q)|0;g=0;while(1){if((g|0)>=(f|0))break a;b=d[e+36>>0]|0;i=+h[e+16>>3];j=+h[e+24>>3];k=+h[e>>3];m=+h[e+8>>3];p=c[c[e+32>>2]>>2]|0;c[r>>2]=g;c[r+4>>2]=e;c[r+8>>2]=b;h[r+16>>3]=i;h[r+24>>3]=j;h[r+32>>3]=k;h[r+40>>3]=m;c[r+48>>2]=p;zL(q,89220,r)|0;e=e+40|0;g=g+1|0}}while(0);l=s;return}function Zx(a,b){a=a|0;b=b|0;var c=0.0;c=+h[b+8>>3]*.5+ +h[b+24>>3];h[a>>3]=+h[b>>3]*.5+ +h[b+16>>3];h[a+8>>3]=c;return}function _x(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,i=0.0,j=0.0;e=l;l=l+16|0;f=e;j=+h[b>>3];h[d>>3]=+h[(+h[d>>3]>3];g=d+8|0;i=+h[b+8>>3];h[g>>3]=+h[(+h[g>>3]>3];j=+h[b+16>>3]+j;h[f>>3]=j;i=+h[b+24>>3]+i;h[f+8>>3]=i;g=d+16|0;h[g>>3]=+h[(+h[g>>3]>j?g:f)>>3];b=d+24|0;h[b>>3]=+h[(+h[b>>3]>i?g:f)+8>>3];c[a>>2]=c[d>>2];c[a+4>>2]=c[d+4>>2];c[a+8>>2]=c[d+8>>2];c[a+12>>2]=c[d+12>>2];c[a+16>>2]=c[d+16>>2];c[a+20>>2]=c[d+20>>2];c[a+24>>2]=c[d+24>>2];c[a+28>>2]=c[d+28>>2];l=e;return}function $x(a){a=a|0;Kx(a,1);return}function ay(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;e=l;l=l+16|0;d=e;b=RA(Im(a,90560)|0)|0;if(b){b=by(b)|0;if(b|0){f=c[b+40>>2]|0;d=c[b+44>>2]|0;g=a+16|0;a=c[g>>2]|0;h[a+32>>3]=+(f|0)*.013888888888888888;h[a+40>>3]=+(d|0)*.013888888888888888;a=vw(12)|0;c[(c[g>>2]|0)+12>>2]=a;c[a>>2]=c[b+12>>2];c[a+4>>2]=((f|0)/-2|0)-(c[b+32>>2]|0);c[a+8>>2]=((d|0)/-2|0)-(c[b+36>>2]|0)}}else{c[d>>2]=Dn(a)|0;_l(0,89268,d)|0}l=e;return}function by(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0;p=l;l=l+1152|0;i=p+24|0;h=p+8|0;e=p;f=p+120|0;j=p+44|0;k=p+40|0;m=p+36|0;n=p+32|0;o=p+28|0;d=c[42310]|0;if(!d){d=Ql(19832,c[4345]|0)|0;c[42310]=d}d=bb[c[d>>2]&31](d,b,512)|0;do if(!d){g=aM(b,123632)|0;if(!g){c[e>>2]=b;_l(0,89317,e)|0;d=0;break}else{d=0;e=0}while(1){if(!(gL(f,1024,g)|0)){f=11;break}c[h>>2]=k;c[h+4>>2]=m;c[h+8>>2]=n;c[h+12>>2]=o;q=(cM(f,89345,h)|0)==4;e=q?1:e;if((a[f>>0]|0)!=37){q=(hL(f,89374)|0)==0;d=q?d:1}if((e|0)!=0&(d|0)!=0){f=12;break}}if((f|0)==11)if(!e){c[i>>2]=b;_l(0,89379,i)|0;d=0}else f=12;if((f|0)==12){q=ww(64)|0;k=c[k>>2]|0;c[q+32>>2]=k;m=c[m>>2]|0;c[q+40>>2]=(c[n>>2]|0)-k;c[q+36>>2]=(c[o>>2]|0)-m;c[q+8>>2]=b;o=c[42311]|0;c[42311]=o+1;c[q+12>>2]=o;_L(zN(g)|0,j)|0;o=c[j+36>>2]|0;n=ww(o+1|0)|0;c[q+52>>2]=n;oM(g,0,0)|0;wN(n,o,1,g)|0;a[n+o>>0]=0;o=c[42310]|0;bb[c[o>>2]&31](o,q,1)|0;a[q+16>>0]=d;d=q}LL(g)|0}while(0);l=p;return d|0}function cy(a,b,d){a=a|0;b=b|0;d=d|0;_I(c[b+52>>2]|0);return}function dy(a){a=a|0;_I(c[(c[a+16>>2]|0)+12>>2]|0);return}function ey(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0;n=l;l=l+16|0;m=n+8|0;k=n;j=(d|0)!=0;a:do if(j){h=0;f=0;b:while(1)while(1){if(h)break a;g=c[d+(f<<2)>>2]|0;if(!g){i=6;break a}f=f+1|0;if(!(a[g>>0]|0)){h=1;continue b}}}else i=6;while(0);c:do if((i|0)==6)while(1){f=c[e>>2]|0;if(!f)break c;mr(b,f)|0;mr(b,134901)|0;e=e+4|0;i=6}while(0);d:do if(j){h=0;while(1){f=c[d+(h<<2)>>2]|0;if(!f)break d;do if(a[f>>0]|0){e=RA(f)|0;if(!e){c[k>>2]=f;_l(0,89418,k)|0;break}g=aM(e,123632)|0;if(!g){c[m>>2]=e;_l(0,89446,m)|0;break}while(1){f=QA(g)|0;if(!f)break;mr(b,f)|0}mr(b,134901)|0;LL(g)|0}while(0);h=h+1|0}}while(0);l=n;return}function fy(b,d){b=b|0;d=d|0;var e=0,f=0,g=0;d=c[d+52>>2]|0;a:while(1){e=a[d>>0]|0;b:do switch(e<<24>>24){case 0:break a;case 37:{if((a[d+1>>0]|0)==37){e=d+2|0;if((((pK(e,89474,3)|0)!=0?(pK(e,89478,5)|0)!=0:0)?(pK(e,89484,3)|0)!=0:0)?(pK(e,89488,7)|0)!=0:0){e=37;break b}else g=37;c:while(1){switch(g<<24>>24){case 13:{f=10;break c}case 10:case 0:{f=12;break c}default:{}}g=d+1|0;d=g;g=a[g>>0]|0}if((f|0)==10){e=d+1|0;if((a[e>>0]|0)==10){d=d+2|0;continue a}}else if((f|0)==12)e=d+1|0;d=g<<24>>24==0?d:e;continue a}else e=37;break}default:{}}while(0);d:while(1){switch(e<<24>>24){case 10:case 13:case 0:break d;default:{}}nr(b,e<<24>>24)|0;g=d+1|0;d=g;e=a[g>>0]|0}f=d+1|0;if(e<<24>>24==13?(a[f>>0]|0)==10:0)d=d+2|0;else d=e<<24>>24==0?d:f;nr(b,10)|0}return}function gy(b){b=b|0;var d=0,e=0,f=0,g=0;f=l;l=l+16|0;e=f;d=c[42310]|0;a:do if(d|0){d=bb[c[d>>2]&31](d,0,128)|0;while(1){if(!d)break a;if(!(a[d+16>>0]|0)){c[e>>2]=c[d+12>>2];sr(b,89496,e);mr(b,89514)|0;fy(b,d);mr(b,89532)|0;mr(b,89547)|0}g=c[42310]|0;d=bb[c[g>>2]&31](g,d,8)|0}}while(0);l=f;return}function hy(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0;g=l;l=l+16|0;e=g;a:do switch(d|0){case 0:{f=b;break}case 1:{f=zB(b)|0;break}default:{switch(iy(b)|0){case 2:break;case 1:{f=zB(b)|0;break a}default:{f=b;break a}}if(!(c[42312]|0)){_l(0,89559,e)|0;c[42312]=1;f=b}else f=b}}while(0);if(!(c[42313]|0))cm(169252,0,0);d=c[42314]|0;if(d>>>0>=(c[42315]|0)>>>0){dm(169252,1)|0;d=c[42314]|0}c[42314]=d+1;a[d>>0]=40;e=f;b:while(1){switch(a[e>>0]|0){case 0:break b;case 92:case 41:case 40:{d=c[42314]|0;if(d>>>0>=(c[42315]|0)>>>0){dm(169252,1)|0;d=c[42314]|0}c[42314]=d+1;a[d>>0]=92;break}default:{}}d=c[42314]|0;if(d>>>0>=(c[42315]|0)>>>0){dm(169252,1)|0;d=c[42314]|0}h=a[e>>0]|0;c[42314]=d+1;a[d>>0]=h;e=e+1|0}d=c[42314]|0;if(d>>>0>=(c[42315]|0)>>>0){dm(169252,1)|0;d=c[42314]|0}c[42314]=d+1;a[d>>0]=41;if((f|0)!=(b|0))_I(f);d=c[42314]|0;if(d>>>0>=(c[42315]|0)>>>0){dm(169252,1)|0;d=c[42314]|0}a[d>>0]=0;h=c[42313]|0;c[42314]=h;l=g;return h|0}function iy(b){b=b|0;var c=0,d=0;c=0;a:while(1){while(1){d=a[b>>0]|0;if(!(d<<24>>24))break a;if((d&255)<127)b=b+1|0;else break}if((d&-4)<<24>>24==-64){c=1;b=b+2|0}else{c=2;break}}return c|0}function jy(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0;n=l;l=l+96|0;i=n+80|0;j=n+72|0;m=n+64|0;g=n+32|0;k=n;h[g>>3]=+h[a>>3];h[g+8>>3]=+h[a+8>>3];h[g+16>>3]=+h[b>>3];h[g+24>>3]=+h[b+8>>3];do if((DI(d,g,j)|0)>=0){if(!f){b=d+4|0;a=c[b>>2]|0;f=c[42318]|0;if((a|0)>(c[42317]|0)){if(!f)a=ww(a<<5)|0;else a=yw(f,a<<5)|0;c[42318]=a;g=c[b>>2]|0;c[42317]=g;f=a}else g=a;b=c[d>>2]|0;a=0;while(1){if((a|0)>=(g|0))break;o=f+(a<<5)|0;d=b+(a<<4)|0;c[o>>2]=c[d>>2];c[o+4>>2]=c[d+4>>2];c[o+8>>2]=c[d+8>>2];c[o+12>>2]=c[d+12>>2];o=f+(a<<5)+16|0;d=a+1|0;p=b+(((d|0)%(g|0)|0)<<4)|0;c[o>>2]=c[p>>2];c[o+4>>2]=c[p+4>>2];c[o+8>>2]=c[p+8>>2];c[o+12>>2]=c[p+12>>2];a=d}c[k>>2]=0;c[k+4>>2]=0;c[k+8>>2]=0;c[k+12>>2]=0;c[k+16>>2]=0;c[k+20>>2]=0;c[k+24>>2]=0;c[k+28>>2]=0;c[i>>2]=c[j>>2];c[i+4>>2]=c[j+4>>2];if((hI(f,g,i,k,m)|0)<0){a=0;break}}else{c[i>>2]=c[j>>2];c[i+4>>2]=c[j+4>>2];YI(i,m)}a=m+4|0;if(!(ky(c[a>>2]|0)|0)){g=c[a>>2]|0;a=c[42319]|0;f=c[m>>2]|0;b=0;while(1){if((b|0)>=(g|0))break;p=a+(b<<4)|0;o=f+(b<<4)|0;c[p>>2]=c[o>>2];c[p+4>>2]=c[o+4>>2];c[p+8>>2]=c[o+8>>2];c[p+12>>2]=c[o+12>>2];b=b+1|0}c[e>>2]=g}else a=0}else a=0;while(0);l=n;return a|0}function ky(a){a=a|0;var b=0,d=0,e=0;e=l;l=l+16|0;d=e;b=c[42320]|0;do if((b|0)<(a|0)){a=a+300-((a|0)%300|0)+b|0;b=yw(c[42319]|0,a<<4)|0;c[42319]=b;if(!b){_l(1,89649,d)|0;a=1;break}else{c[42320]=a;a=0;break}}else a=0;while(0);l=e;return a|0}function ly(){var a=0,b=0,d=0;b=l;l=l+16|0;a=b;d=c[42321]|0;c[42321]=d+1;do if((d|0)<=0){d=ww(4800)|0;c[42319]=d;if(!d){_l(1,89672,a)|0;a=1;break}c[42320]=300;c[42322]=0;c[42323]=0;if(0){xA();a=0}else a=0}else a=0;while(0);l=b;return a|0}function my(){var a=0,b=0,d=0,e=0.0,f=0,g=0;b=l;l=l+16|0;a=b;d=c[42321]|0;c[42321]=d+-1;if((d|0)<=1?(_I(c[42319]|0),0):0){d=c[13918]|0;g=c[42322]|0;f=c[42323]|0;e=+yA();c[a>>2]=g;c[a+4>>2]=f;h[a+8>>3]=e;zL(d,89710,a)|0}l=b;return}function ny(a,b){a=a|0;b=b|0;return oy(a,b,0)|0}function oy(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0.0,m=0.0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0;L=l;l=l+176|0;G=L+168|0;K=L+128|0;x=L+120|0;v=L+112|0;i=L+104|0;s=L+88|0;n=L+72|0;g=L+64|0;t=L+160|0;I=L+152|0;y=L+144|0;u=L+32|0;w=L;J=L+136|0;c[42322]=(c[42322]|0)+1;H=c[b+80>>2]|0;c[42323]=(c[42323]|0)+H;f=b+88|0;while(1){C=c[f>>2]|0;if(!C){D=4;break}f=c[C+16>>2]|0;if(!(a[f+112>>0]|0)){D=5;break}else f=f+116|0}do if((D|0)==4){_l(1,89753,g)|0;f=0}else if((D|0)==5){B=c[b+84>>2]|0;if(!(py(H,B,b)|0)){g=H<<3;if((g|0)>(c[42324]|0)){f=c[42325]|0;if(!f)f=ww(H<<7)|0;else f=yw(f,H<<7)|0;c[42325]=f;c[42324]=g}a:do if((H|0)>1?+h[B+8>>3]>+h[B+40>>3]:0){f=0;while(1){if((f|0)==(H|0)){p=1;break a}z=B+(f<<5)+24|0;m=+h[z>>3];A=B+(f<<5)+8|0;h[z>>3]=-+h[A>>3];h[A>>3]=-m;f=f+1|0}}else p=0;while(0);r=c[C>>2]&3;z=C+48|0;f=c[((r|0)==3?C:z)+40>>2]|0;A=C+-48|0;if((f|0)==(c[((r|0)==2?C:A)+40>>2]|0)){c[i>>2]=Dn(f)|0;_l(1,89860,i)|0;f=0;break}o=H+-1|0;q=c[42325]|0;r=q;f=0;j=0;b:while(1){if((j|0)>=(H|0)){j=o;n=f;break}if((j|0)>0)g=+h[B+(j<<5)+8>>3]>+h[B+(j+-1<<5)+8>>3]?-1:1;else g=0;if((j|0)<(o|0))i=+h[B+(j+1<<5)+8>>3]>+h[B+(j<<5)+8>>3]?1:-1;else i=0;c:do if((g|0)!=(i|0))if((g|0)==1|(i|0)==-1){g=B+(j<<5)|0;h[q+(f<<4)>>3]=+h[g>>3];i=f+1|0;h[q+(f<<4)+8>>3]=+h[B+(j<<5)+24>>3];h[q+(i<<4)>>3]=+h[g>>3];g=B+(j<<5)+8|0;D=29;break}else{g=B+(j<<5)+16|0;h[q+(f<<4)>>3]=+h[g>>3];i=f+1|0;h[q+(f<<4)+8>>3]=+h[B+(j<<5)+8>>3];h[q+(i<<4)>>3]=+h[g>>3];g=B+(j<<5)+24|0;D=29;break}else{switch(g|0){case -1:break c;case 0:break;default:{D=28;break b}}g=B+(j<<5)|0;h[q+(f<<4)>>3]=+h[g>>3];i=f+1|0;h[q+(f<<4)+8>>3]=+h[B+(j<<5)+24>>3];h[q+(i<<4)>>3]=+h[g>>3];g=B+(j<<5)+8|0;D=29}while(0);if((D|0)==29){D=0;h[q+(i<<4)+8>>3]=+h[g>>3];f=f+2|0}j=j+1|0}if((D|0)==28){c[n>>2]=g;c[n+4>>2]=g;c[n+8>>2]=480;_l(1,89795,n)|0;f=0;break}d:while(1){if((j|0)<=-1)break;if((j|0)<(o|0))f=+h[B+(j<<5)+8>>3]>+h[B+(j+1<<5)+8>>3]?-1:1;else f=0;if((j|0)>0)g=+h[B+(j+-1<<5)+8>>3]>+h[B+(j<<5)+8>>3]?1:-1;else g=0;e:do if((f|0)!=(g|0))if((f|0)==1|(g|0)==-1){f=B+(j<<5)|0;h[q+(n<<4)>>3]=+h[f>>3];g=n+1|0;h[q+(n<<4)+8>>3]=+h[B+(j<<5)+24>>3];h[q+(g<<4)>>3]=+h[f>>3];f=B+(j<<5)+8|0;i=2;break}else{f=B+(j<<5)+16|0;h[q+(n<<4)>>3]=+h[f>>3];g=n+1|0;h[q+(n<<4)+8>>3]=+h[B+(j<<5)+8>>3];h[q+(g<<4)>>3]=+h[f>>3];f=B+(j<<5)+24|0;i=2;break}else switch(f|0){case 0:{f=B+(j<<5)+16|0;h[q+(n<<4)>>3]=+h[f>>3];g=n+1|0;h[q+(n<<4)+8>>3]=+h[B+(j<<5)+8>>3];h[q+(g<<4)>>3]=+h[f>>3];f=B+(j<<5)+24|0;i=2;break e}case -1:{N=B+(j<<5)+16|0;h[q+(n<<4)>>3]=+h[N>>3];f=B+(j<<5)+8|0;i=n+1|0;h[q+(n<<4)+8>>3]=+h[f>>3];h[q+(i<<4)>>3]=+h[N>>3];N=B+(j<<5)+24|0;M=n+2|0;h[q+(i<<4)+8>>3]=+h[N>>3];i=B+(j<<5)|0;h[q+(M<<4)>>3]=+h[i>>3];g=n+3|0;h[q+(M<<4)+8>>3]=+h[N>>3];h[q+(g<<4)>>3]=+h[i>>3];i=4;break e}default:{D=42;break d}}while(0);h[q+(g<<4)+8>>3]=+h[f>>3];j=j+-1|0;n=n+i|0}if((D|0)==42){c[s>>2]=f;c[s+4>>2]=f;c[s+8>>2]=513;_l(1,89795,s)|0;f=0;break}f:do if(!p)f=0;else{f=0;while(1){if((f|0)>=(H|0)){f=0;break}M=B+(f<<5)+24|0;m=+h[M>>3];N=B+(f<<5)+8|0;h[M>>3]=-+h[N>>3];h[N>>3]=-m;f=f+1|0}while(1){if((f|0)>=(n|0)){f=0;break f}N=q+(f<<4)+8|0;h[N>>3]=-+h[N>>3];f=f+1|0}}while(0);while(1){if((f|0)>=(H|0))break;h[B+(f<<5)>>3]=2147483647.0;h[B+(f<<5)+16>>3]=-2147483648.0;f=f+1|0}c[t>>2]=r;i=t+4|0;c[i>>2]=n;h[u>>3]=+h[b>>3];h[u+8>>3]=+h[b+8>>3];h[u+16>>3]=+h[b+40>>3];h[u+24>>3]=+h[b+48>>3];if((DI(t,u,I)|0)<0){_l(1,89899,v)|0;f=0;break}if(!e){g=c[i>>2]|0;f=c[42318]|0;if((g|0)>(c[42317]|0)){if(!f)f=ww(g<<5)|0;else f=yw(f,g<<5)|0;c[42318]=f;g=c[i>>2]|0;c[42317]=g}j=c[42325]|0;i=0;while(1){if((i|0)>=(g|0))break;M=f+(i<<5)|0;N=j+(i<<4)|0;c[M>>2]=c[N>>2];c[M+4>>2]=c[N+4>>2];c[M+8>>2]=c[N+8>>2];c[M+12>>2]=c[N+12>>2];M=f+(i<<5)+16|0;N=i+1|0;v=j+(((N|0)%(g|0)|0)<<4)|0;c[M>>2]=c[v>>2];c[M+4>>2]=c[v+4>>2];c[M+8>>2]=c[v+8>>2];c[M+12>>2]=c[v+12>>2];i=N}if(!(a[b+29>>0]|0)){k=0.0;m=0.0}else{m=+h[b+16>>3];k=+E(+m);m=+F(+m)}h[w+8>>3]=m;h[w>>3]=k;if(!(a[b+69>>0]|0)){k=0.0;m=0.0}else{m=+h[b+56>>3];k=-+E(+m);m=-+F(+m)}h[w+24>>3]=m;h[w+16>>3]=k;c[G>>2]=c[I>>2];c[G+4>>2]=c[I+4>>2];if((hI(f,g,G,w,y)|0)<0){_l(1,89938,x)|0;f=0;break}}else{c[G>>2]=c[I>>2];c[G+4>>2]=c[I+4>>2];YI(G,y)}n=y+4|0;if(!(ky(c[n>>2]|0)|0)){f=0;while(1){if((f|0)>=(H|0))break;h[B+(f<<5)>>3]=2147483647.0;h[B+(f<<5)+16>>3]=-2147483648.0;f=f+1|0}i=c[n>>2]|0;j=c[42319]|0;g=c[y>>2]|0;f=0;while(1){if((f|0)>=(i|0)){i=1;f=10;g=0;break}N=j+(f<<4)|0;M=g+(f<<4)|0;c[N>>2]=c[M>>2];c[N+4>>2]=c[M+4>>2];c[N+8>>2]=c[M+8>>2];c[N+12>>2]=c[M+12>>2];f=f+1|0}while(1){if(!((g|0)<15&i<<24>>24!=0))break;qy(B,H,c[42319]|0,c[n>>2]|0,f);j=0;while(1){if((j|0)>=(H|0))break;if(+h[B+(j<<5)>>3]==2147483647.0){D=82;break}if(+h[B+(j<<5)+16>>3]==-2147483648.0){D=82;break}j=j+1|0}if((D|0)==82){D=0;N=f<<1;f=N;g=(N|0)>(2147483647/(H|0)|0|0)?15:g}i=(j|0)==(H|0)?0:i;g=g+1|0}if(i<<24>>24){M=Dn(c[((c[C>>2]&3|0)==3?C:z)+40>>2]|0)|0;N=Dn(c[((c[C>>2]&3|0)==2?C:A)+40>>2]|0)|0;c[K>>2]=M;c[K+4>>2]=N;_l(0,89976,K)|0;c[G>>2]=c[I>>2];c[G+4>>2]=c[I+4>>2];YI(G,J);qy(B,H,c[J>>2]|0,c[J+4>>2]|0,10);_I(c[J>>2]|0)}c[d>>2]=c[n>>2];f=c[42319]|0}else f=0}else f=0}while(0);l=L;return f|0}function py(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0.0,g=0.0,i=0,j=0,k=0,m=0.0,n=0.0,o=0,p=0.0,q=0.0,r=0.0,s=0.0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0.0,L=0,M=0,N=0,O=0.0,P=0,Q=0,R=0;R=l;l=l+32|0;I=R+16|0;H=R+8|0;k=R;e=0;j=0;while(1){if((j|0)>=(a|0))break;i=b+(j<<5)|0;s=+h[b+(j<<5)+8>>3]-+h[b+(j<<5)+24>>3];if(!((s>=0.0?s:-s)<.01)?(s=+h[i>>3]-+h[b+(j<<5)+16>>3],!((s>=0.0?s:-s)<.01)):0){if((e|0)!=(j|0)){P=b+(e<<5)|0;c[P>>2]=c[i>>2];c[P+4>>2]=c[i+4>>2];c[P+8>>2]=c[i+8>>2];c[P+12>>2]=c[i+12>>2];c[P+16>>2]=c[i+16>>2];c[P+20>>2]=c[i+20>>2];c[P+24>>2]=c[i+24>>2];c[P+28>>2]=c[i+28>>2]}e=e+1|0}j=j+1|0}J=b+16|0;do if(!(+h[b>>3]>+h[J>>3])?(L=b+8|0,N=b+24|0,!(+h[L>>3]>+h[N>>3])):0){P=e+-1|0;M=c[13918]|0;w=0;while(1){if((w|0)>=(P|0))break;D=w+1|0;E=b+(D<<5)|0;f=+h[E>>3];F=b+(D<<5)+16|0;g=+h[F>>3];if(f>g){Q=16;break}A=b+(D<<5)+8|0;m=+h[A>>3];B=b+(D<<5)+24|0;n=+h[B>>3];if(m>n){Q=16;break}G=b+(w<<5)+16|0;v=+h[G>>3]>3]>g;a=u&1;z=b+(w<<5)+24|0;t=+h[z>>3]>3]>n;i=k&1;x=a+e+j+i|0;o=(x|0)!=0;if(!(0==0|o^1)){c[I>>2]=w;c[I+4>>2]=D;zL(M,90176,I)|0;ry(d)}a:do if(o){if(!v)if(!u)if(!t){if(k){k=0;o=e;e=B;i=y;Q=24}}else{k=i;j=0;o=e;e=A;i=z;Q=24}else{k=i;a=0;o=e;e=F;i=C;Q=24}else{k=i;o=0;e=E;i=G;Q=24}if((Q|0)==24){Q=0;w=~~+h[i>>3];h[i>>3]=+h[e>>3];h[e>>3]=+(w|0);i=k;e=o}o=x+-1|0;k=0;while(1){if((k|0)>=(o|0))break a;do if((e|0)!=1){if((a|0)==1){s=+(~~((+h[F>>3]+ +h[C>>3])*.5+.5)|0);h[F>>3]=s;h[C>>3]=s;a=0;break}if((j|0)==1){s=+(~~((+h[A>>3]+ +h[z>>3])*.5+.5)|0);h[A>>3]=s;h[z>>3]=s;j=0;break}if((i|0)==1){s=+(~~((+h[B>>3]+ +h[y>>3])*.5+.5)|0);h[B>>3]=s;h[y>>3]=s;i=0}}else{s=+(~~((+h[E>>3]+ +h[G>>3])*.5+.5)|0);h[E>>3]=s;h[G>>3]=s;e=0}while(0);k=k+1|0}}while(0);p=+h[C>>3];q=+h[G>>3];r=+h[E>>3];s=+h[F>>3];i=sy(~~p,~~q,~~r,~~s)|0;n=+h[y>>3];m=+h[z>>3];g=+h[A>>3];f=+h[B>>3];e=sy(~~n,~~m,~~g,~~f)|0;if(!((i|0)!=0&(e|0)!=0)){w=D;continue}if((i|0)<(e|0)){B=q-p>s-r;w=q>3]=B?(w?r:s):w?q:p;w=D;continue}else{B=m-n>f-g;w=m>3]=B?(w?g:f):w?m:n;w=D;continue}}if((Q|0)==16){c[H>>2]=D;_l(1,90130,H)|0;ry(d);e=1;break}f=+h[d>>3];g=+h[b>>3];if(!(((!(f+h[J>>3]):0)?(K=+h[d+8>>3],!(K<+h[L>>3])):0)?!(K>+h[N>>3]):0)){if(0){XL(90219,42,1,M)|0;ry(d);g=+h[b>>3];f=+h[d>>3]}if(f>3]=g;else g=f;f=+h[J>>3];if(g>f)h[d>>3]=f;e=d+8|0;g=+h[e>>3];f=+h[L>>3];if(g>3]=f;g=f}f=+h[N>>3];if(g>f)h[e>>3]=f}i=d+40|0;f=+h[i>>3];e=b+(P<<5)|0;g=+h[e>>3];if(((!(f+h[b+(P<<5)+16>>3]):0)?(O=+h[d+48>>3],!(O<+h[b+(P<<5)+8>>3])):0)?!(O>+h[b+(P<<5)+24>>3]):0){e=0;break}if(0){XL(90262,39,1,M)|0;ry(d);g=+h[e>>3];f=+h[i>>3]}if(f>3]=g;f=g}g=+h[b+(P<<5)+16>>3];if(f>g)h[i>>3]=g;e=d+48|0;f=+h[e>>3];g=+h[b+(P<<5)+8>>3];if(f>3]=g;else g=f;f=+h[b+(P<<5)+24>>3];if(g>f){h[e>>3]=f;e=0}else e=0}else Q=12;while(0);if((Q|0)==12){_l(1,90085,k)|0;ry(d);e=1}l=R;return e|0}function qy(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0,l=0,m=0.0,n=0.0,o=0,p=0,q=0,r=0,s=0,t=0.0,u=0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0;s=O(e,b)|0;t=1.0/+(s|0);e=0;a:while(1){u=e+3|0;if((u|0)>=(d|0))break;o=c+(e<<4)|0;p=c+(e<<4)+8|0;r=e+1|0;q=c+(r<<4)|0;r=c+(r<<4)+8|0;j=e+2|0;i=c+(j<<4)|0;j=c+(j<<4)+8|0;k=c+(u<<4)|0;l=c+(u<<4)+8|0;g=0;while(1){if((g|0)>(s|0)){e=u;continue a}v=t*+(g|0);m=+h[o>>3];n=+h[p>>3];y=+h[q>>3];w=+h[r>>3];z=+h[i>>3];x=+h[j>>3];m=(y-m)*v+m;n=(w-n)*v+n;y=(z-y)*v+y;w=(x-w)*v+w;m=(y-m)*v+m;n=(w-n)*v+n;m=((z-y+(+h[k>>3]-z)*v)*v+y-m)*v+m;n=((x-w+(+h[l>>3]-x)*v)*v+w-n)*v+n;f=0;while(1){if((f|0)>=(b|0))break;if(n<=+h[a+(f<<5)+24>>3]+.0001?n>=+h[a+(f<<5)+8>>3]+-.0001:0){e=a+(f<<5)|0;if(+h[e>>3]>m)h[e>>3]=m;e=a+(f<<5)+16|0;if(+h[e>>3]>3]=m}f=f+1|0}g=g+1|0}}return}function ry(b){b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0,k=0,m=0,n=0.0,o=0.0,p=0.0,q=0.0,r=0;m=l;l=l+112|0;j=m+80|0;k=m+48|0;i=m+8|0;g=m;e=c[13918]|0;f=b+80|0;c[g>>2]=c[f>>2];zL(e,90302,g)|0;g=b+84|0;d=0;while(1){if((d|0)>=(c[f>>2]|0))break;r=c[g>>2]|0;q=+h[r+(d<<5)>>3];p=+h[r+(d<<5)+8>>3];o=+h[r+(d<<5)+16>>3];n=+h[r+(d<<5)+24>>3];c[i>>2]=d;h[i+8>>3]=q;h[i+16>>3]=p;h[i+24>>3]=o;h[i+32>>3]=n;zL(e,90313,i)|0;d=d+1|0}q=+h[b+8>>3];p=+h[b+16>>3];r=a[b+29>>0]|0?90344:90356;h[k>>3]=+h[b>>3];h[k+8>>3]=q;h[k+16>>3]=p;c[k+24>>2]=r;zL(e,90372,k)|0;p=+h[b+48>>3];q=+h[b+56>>3];r=a[b+69>>0]|0?90344:90356;h[j>>3]=+h[b+40>>3];h[j+8>>3]=p;h[j+16>>3]=q;c[j+24>>2]=r;zL(e,90423,j)|0;l=m;return}function sy(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;do if((b|0)>(c|0)&(d|0)>(a|0)){if(!((c|0)>(a|0)|(d|0)<(a|0))){a=d-a|0;break}if((b|0)<(c|0)|(b|0)>(d|0)){b=b-a|0;a=d-c|0;a=(b|0)<(a|0)?b:a;break}else{a=b-c|0;break}}else a=0;while(0);return a|0}function ty(a,b){a=a|0;b=b|0;return oy(a,b,1)|0}function uy(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var i=0,j=0,k=0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0,s=0.0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0.0,M=0.0,N=0.0,P=0,Q=0;K=l;l=l+304|0;A=K+272|0;z=K+208|0;G=K+96|0;H=K+32|0;I=K+16|0;J=K;r=K+192|0;y=K+176|0;i=K+160|0;B=K+296|0;D=K+288|0;j=c[d>>2]|0;w=c[j>>2]&3;k=j+-48|0;E=c[((w|0)==2?j:k)+40>>2]|0;t=G+16|0;w=(c[(c[((w|0)==3?j:j+48|0)+40>>2]|0)+16>>2]|0)+16|0;x=j+16|0;F=(c[x>>2]|0)+16|0;c[z>>2]=c[w>>2];c[z+4>>2]=c[w+4>>2];c[z+8>>2]=c[w+8>>2];c[z+12>>2]=c[w+12>>2];c[A>>2]=c[F>>2];c[A+4>>2]=c[F+4>>2];c[A+8>>2]=c[F+8>>2];c[A+12>>2]=c[F+12>>2];vy(r,z,A);c[G>>2]=c[r>>2];c[G+4>>2]=c[r+4>>2];c[G+8>>2]=c[r+8>>2];c[G+12>>2]=c[r+12>>2];c[t>>2]=c[r>>2];c[t+4>>2]=c[r+4>>2];c[t+8>>2]=c[r+8>>2];c[t+12>>2]=c[r+12>>2];c[I>>2]=c[r>>2];c[I+4>>2]=c[r+4>>2];c[I+8>>2]=c[r+8>>2];c[I+12>>2]=c[r+12>>2];r=G+32|0;F=G+48|0;w=(c[E+16>>2]|0)+16|0;x=(c[x>>2]|0)+56|0;c[z>>2]=c[w>>2];c[z+4>>2]=c[w+4>>2];c[z+8>>2]=c[w+8>>2];c[z+12>>2]=c[w+12>>2];c[A>>2]=c[x>>2];c[A+4>>2]=c[x+4>>2];c[A+8>>2]=c[x+8>>2];c[A+12>>2]=c[x+12>>2];vy(y,z,A);c[F>>2]=c[y>>2];c[F+4>>2]=c[y+4>>2];c[F+8>>2]=c[y+8>>2];c[F+12>>2]=c[y+12>>2];c[r>>2]=c[y>>2];c[r+4>>2]=c[y+4>>2];c[r+8>>2]=c[y+8>>2];c[r+12>>2]=c[y+12>>2];c[J>>2]=c[y>>2];c[J+4>>2]=c[y+4>>2];c[J+8>>2]=c[y+8>>2];c[J+12>>2]=c[y+12>>2];a:do if((e|0)!=1&(a[174076]|0)==0){m=+h[G>>3];n=+h[F>>3];L=m-n;o=+h[G+8>>3];p=+h[G+56>>3];s=o-p;q=s*s;if(q+L*L<1.0e-06){c[t>>2]=c[G>>2];c[t+4>>2]=c[G+4>>2];c[t+8>>2]=c[G+8>>2];c[t+12>>2]=c[G+12>>2];c[r>>2]=c[F>>2];c[r+4>>2]=c[F+4>>2];c[r+8>>2]=c[F+8>>2];c[r+12>>2]=c[F+12>>2];y=G+24|0;x=G+40|0;n=0.0;m=0.0}else{M=n-m;L=+C(+(q+M*M));w=c[(c[(c[b+60>>2]|0)+16>>2]|0)+248>>2]|0;N=+((O(w,e+-1|0)|0)/2|0|0);q=s*N/L;h[t>>3]=q+m;m=M*N/L;y=G+24|0;h[y>>3]=m+o;h[r>>3]=q+n;x=G+40|0;h[x>>3]=p+m;m=+(0-w|0);n=M*m/L;m=s*m/L}f=(f|0)==6;u=D+4|0;v=B+4|0;j=0;while(1){if((j|0)>=(e|0))break a;w=c[d+(j<<2)>>2]|0;k=w+-48|0;b:do if((c[((c[w>>2]&3|0)==2?w:k)+40>>2]|0)==(E|0)){c[I>>2]=c[G>>2];c[I+4>>2]=c[G+4>>2];c[I+8>>2]=c[G+8>>2];c[I+12>>2]=c[G+12>>2];c[J>>2]=c[F>>2];c[J+4>>2]=c[F+4>>2];c[J+8>>2]=c[F+8>>2];c[J+12>>2]=c[F+12>>2];i=0;while(1){if((i|0)==4)break b;P=H+(i<<4)|0;Q=G+(i<<4)|0;c[P>>2]=c[Q>>2];c[P+4>>2]=c[Q+4>>2];c[P+8>>2]=c[Q+8>>2];c[P+12>>2]=c[Q+12>>2];i=i+1|0}}else{c[I>>2]=c[F>>2];c[I+4>>2]=c[F+4>>2];c[I+8>>2]=c[F+8>>2];c[I+12>>2]=c[F+12>>2];c[J>>2]=c[G>>2];c[J+4>>2]=c[G+4>>2];c[J+8>>2]=c[G+8>>2];c[J+12>>2]=c[G+12>>2];i=0;while(1){if((i|0)==4)break b;Q=H+(3-i<<4)|0;P=G+(i<<4)|0;c[Q>>2]=c[P>>2];c[Q+4>>2]=c[P+4>>2];c[Q+8>>2]=c[P+8>>2];c[Q+12>>2]=c[P+12>>2];i=i+1|0}}while(0);if(f){c[u>>2]=4;c[D>>2]=z;i=0;while(1){if((i|0)==4)break;Q=z+(i<<4)|0;P=H+(i<<4)|0;c[Q>>2]=c[P>>2];c[Q+4>>2]=c[P+4>>2];c[Q+8>>2]=c[P+8>>2];c[Q+12>>2]=c[P+12>>2];i=i+1|0}c[A>>2]=c[D>>2];c[A+4>>2]=c[D+4>>2];YI(A,B);Jz(w,c[((c[w>>2]&3|0)==2?w:k)+40>>2]|0,c[B>>2]|0,c[v>>2]|0,g)}else Jz(w,c[((c[w>>2]&3|0)==2?w:k)+40>>2]|0,H,4,g);c[z>>2]=c[I>>2];c[z+4>>2]=c[I+4>>2];c[z+8>>2]=c[I+8>>2];c[z+12>>2]=c[I+12>>2];c[A>>2]=c[J>>2];c[A+4>>2]=c[J+4>>2];c[A+8>>2]=c[J+8>>2];c[A+12>>2]=c[J+12>>2];cA(b,w,z,A);h[t>>3]=+h[t>>3]+m;h[y>>3]=+h[y>>3]+n;h[r>>3]=+h[r>>3]+m;h[x>>3]=+h[x>>3]+n;j=j+1|0}}else{if((f|0)==4){wy(i,b);c[A>>2]=c[i>>2];c[A+4>>2]=c[i+4>>2];c[A+8>>2]=c[i+8>>2];c[A+12>>2]=c[i+12>>2];xy(G,A)}Jz(j,c[((c[j>>2]&3|0)==2?j:k)+40>>2]|0,G,4,g);c[z>>2]=c[I>>2];c[z+4>>2]=c[I+4>>2];c[z+8>>2]=c[I+8>>2];c[z+12>>2]=c[I+12>>2];c[A>>2]=c[J>>2];c[A+4>>2]=c[J+4>>2];c[A+8>>2]=c[J+8>>2];c[A+12>>2]=c[J+12>>2];cA(b,j,z,A)}while(0);l=K;return}function vy(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0;d=+h[c+8>>3]+ +h[b+8>>3];h[a>>3]=+h[c>>3]+ +h[b>>3];h[a+8>>3]=d;return}function wy(a,b){a=a|0;b=b|0;b=c[b+16>>2]|0;h[20899]=(+h[b+32>>3]+ +h[b+16>>3])*.5;h[20900]=(+h[b+40>>3]+ +h[b+24>>3])*.5;c[a>>2]=c[41798];c[a+4>>2]=c[41799];c[a+8>>2]=c[41800];c[a+12>>2]=c[41801];return}function xy(a,b){a=a|0;b=b|0;var c=0.0,d=0.0,e=0.0,f=0.0,g=0.0,i=0.0;f=+h[a>>3];d=+h[a+48>>3];i=(d+f)*.5;g=+h[a+8>>3];c=+h[a+56>>3];e=(c+g)*.5;f=d-f;g=c-g;f=+C(+(g*g+f*f))*.2;g=+h[b>>3]-i;c=+h[b+8>>3]-e;d=+C(+(c*c+g*g));if(!(d==0.0)){g=i-g/d*f;i=e-c/d*f;h[a+32>>3]=g;h[a+16>>3]=g;h[a+40>>3]=i;h[a+24>>3]=i}return}function yy(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,i=0,j=0,k=0,m=0.0,n=0,o=0.0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,D=0,E=0,F=0.0,G=0,H=0.0,I=0.0,J=0.0;E=l;l=l+208|0;t=E+192|0;s=E+176|0;B=E+32|0;w=E+16|0;x=E;y=E+160|0;z=E+144|0;u=E+128|0;v=E+112|0;g=e&2130706432;A=(e&8|0)==0?((g|0)==0?4:g):8;if((A|0)==436207616)zy(a,b,d,f);else{D=vw((d<<6)+64|0)|0;p=d+-1|0;q=x+8|0;r=w+8|0;o=12.0;e=0;while(1){if((e|0)>=(d|0))break;n=b+(e<<4)|0;c[w>>2]=c[n>>2];c[w+4>>2]=c[n+4>>2];c[w+8>>2]=c[n+8>>2];c[w+12>>2]=c[n+12>>2];if((e|0)<(p|0)){e=e+1|0;n=b+(e<<4)|0;c[x>>2]=c[n>>2];c[x+4>>2]=c[n+4>>2];c[x+8>>2]=c[n+8>>2];c[x+12>>2]=c[n+12>>2]}else{c[x>>2]=c[b>>2];c[x+4>>2]=c[b+4>>2];c[x+8>>2]=c[b+8>>2];c[x+12>>2]=c[b+12>>2];e=e+1|0}m=+h[x>>3]-+h[w>>3];F=+h[q>>3]-+h[r>>3];m=+C(+(F*F+m*m))*.3333333333333333;o=o=(d|0))break;g=b+(i<<4)|0;c[w>>2]=c[g>>2];c[w+4>>2]=c[g+4>>2];c[w+8>>2]=c[g+8>>2];c[w+12>>2]=c[g+12>>2];if((i|0)<(p|0)){g=b+(i+1<<4)|0;c[x>>2]=c[g>>2];c[x+4>>2]=c[g+4>>2];c[x+8>>2]=c[g+8>>2];c[x+12>>2]=c[g+12>>2]}else{c[x>>2]=c[b>>2];c[x+4>>2]=c[b+4>>2];c[x+8>>2]=c[b+8>>2];c[x+12>>2]=c[b+12>>2]}m=+h[x>>3]-+h[w>>3];F=+h[q>>3]-+h[r>>3];m=o/+C(+(F*F+m*m));m=k?m*.3333333333333333:j?m*.5:m;g=D+(e<<4)|0;if(n){c[s>>2]=c[w>>2];c[s+4>>2]=c[w+4>>2];c[s+8>>2]=c[w+8>>2];c[s+12>>2]=c[w+12>>2];c[t>>2]=c[x>>2];c[t+4>>2]=c[x+4>>2];c[t+8>>2]=c[x+8>>2];c[t+12>>2]=c[x+12>>2];Ay(y,m*.5,s,t);c[g>>2]=c[y>>2];c[g+4>>2]=c[y+4>>2];c[g+8>>2]=c[y+8>>2];c[g+12>>2]=c[y+12>>2]}else{c[g>>2]=c[w>>2];c[g+4>>2]=c[w+4>>2];c[g+8>>2]=c[w+8>>2];c[g+12>>2]=c[w+12>>2]}g=D+(e+1<<4)|0;c[s>>2]=c[w>>2];c[s+4>>2]=c[w+4>>2];c[s+8>>2]=c[w+8>>2];c[s+12>>2]=c[w+12>>2];c[t>>2]=c[x>>2];c[t+4>>2]=c[x+4>>2];c[t+8>>2]=c[x+8>>2];c[t+12>>2]=c[x+12>>2];Ay(z,m,s,t);c[g>>2]=c[z>>2];c[g+4>>2]=c[z+4>>2];c[g+8>>2]=c[z+8>>2];c[g+12>>2]=c[z+12>>2];g=e+3|0;G=D+(e+2<<4)|0;c[s>>2]=c[w>>2];c[s+4>>2]=c[w+4>>2];c[s+8>>2]=c[w+8>>2];c[s+12>>2]=c[w+12>>2];c[t>>2]=c[x>>2];c[t+4>>2]=c[x+4>>2];c[t+8>>2]=c[x+8>>2];c[t+12>>2]=c[x+12>>2];Ay(u,1.0-m,s,t);c[G>>2]=c[u>>2];c[G+4>>2]=c[u+4>>2];c[G+8>>2]=c[u+8>>2];c[G+12>>2]=c[u+12>>2];if(n){G=D+(g<<4)|0;c[s>>2]=c[w>>2];c[s+4>>2]=c[w+4>>2];c[s+8>>2]=c[w+8>>2];c[s+12>>2]=c[w+12>>2];c[t>>2]=c[x>>2];c[t+4>>2]=c[x+4>>2];c[t+8>>2]=c[x+8>>2];c[t+12>>2]=c[x+12>>2];Ay(v,1.0-m*.5,s,t);c[G>>2]=c[v>>2];c[G+4>>2]=c[v+4>>2];c[G+8>>2]=c[v+8>>2];c[G+12>>2]=c[v+12>>2];e=e+4|0}else e=g;i=i+1|0}k=D+(e<<4)|0;c[k>>2]=c[D>>2];c[k+4>>2]=c[D+4>>2];c[k+8>>2]=c[D+8>>2];c[k+12>>2]=c[D+12>>2];k=D+(e+1<<4)|0;j=D+16|0;c[k>>2]=c[j>>2];c[k+4>>2]=c[j+4>>2];c[k+8>>2]=c[j+8>>2];c[k+12>>2]=c[j+12>>2];e=D+(e+2<<4)|0;k=D+32|0;c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];c[e+8>>2]=c[k+8>>2];c[e+12>>2]=c[k+12>>2];e=A&2147483647;a:do if((e|0)<201326592){if((e|0)>=83886080){if((e|0)<134217728){if((e|0)<100663296){switch(e|0){case 83886080:break;default:break a}if((d|0)==4){G=vw(192)|0;c[G>>2]=c[b>>2];c[G+4>>2]=c[b+4>>2];c[G+8>>2]=c[b+8>>2];c[G+12>>2]=c[b+12>>2];p=G+16|0;t=b+16|0;c[p>>2]=c[t>>2];c[p+4>>2]=c[t+4>>2];c[p+8>>2]=c[t+8>>2];c[p+12>>2]=c[t+12>>2];p=D+48|0;t=D+64|0;o=+h[t>>3];n=G+32|0;h[n>>3]=o;q=D+56|0;r=D+72|0;H=+h[r>>3];z=G+40|0;h[z>>3]=H;F=+h[p>>3]+o-+h[k>>3];u=G+48|0;h[u>>3]=F;J=+h[q>>3]+H-+h[D+40>>3];x=G+56|0;h[x>>3]=J;I=+h[t>>3]+F-+h[p>>3];p=G+64|0;h[p>>3]=I;m=+h[r>>3]+J-+h[q>>3];q=G+72|0;h[q>>3]=m;r=G+80|0;h[r>>3]=o+I-F;h[G+88>>3]=H+m-J;t=D+96|0;v=D+80|0;J=+h[v>>3];d=G+144|0;h[d>>3]=J;w=D+104|0;s=D+88|0;m=+h[s>>3];h[G+152>>3]=m;H=+h[t>>3]+J-+h[D+112>>3];y=G+128|0;h[y>>3]=H;F=+h[w>>3]+m-+h[D+120>>3];A=G+136|0;h[A>>3]=F;I=+h[v>>3]+H-+h[t>>3];t=G+112|0;h[t>>3]=I;o=+h[s>>3]+F-+h[w>>3];w=G+120|0;h[w>>3]=o;s=G+96|0;h[s>>3]=J+I-H;v=G+104|0;h[v>>3]=m+o-F;k=G+160|0;j=b+32|0;c[k>>2]=c[j>>2];c[k+4>>2]=c[j+4>>2];c[k+8>>2]=c[j+8>>2];c[k+12>>2]=c[j+12>>2];k=G+176|0;b=b+48|0;c[k>>2]=c[b>>2];c[k+4>>2]=c[b+4>>2];c[k+8>>2]=c[b+8>>2];c[k+12>>2]=c[b+12>>2];HD(a,G,12,f);c[B>>2]=c[n>>2];c[B+4>>2]=c[n+4>>2];c[B+8>>2]=c[n+8>>2];c[B+12>>2]=c[n+12>>2];F=+h[n>>3];o=+h[u>>3];F=F+F-o;u=B+16|0;h[u>>3]=F;m=+h[z>>3];H=+h[x>>3];m=m+m-H;x=B+24|0;h[x>>3]=m;z=B+32|0;h[z>>3]=+h[p>>3]+F-o;b=B+40|0;h[b>>3]=+h[q>>3]+m-H;f=B+48|0;c[f>>2]=c[r>>2];c[f+4>>2]=c[r+4>>2];c[f+8>>2]=c[r+8>>2];c[f+12>>2]=c[r+12>>2];KD(a,B,4);c[B>>2]=c[s>>2];c[B+4>>2]=c[s+4>>2];c[B+8>>2]=c[s+8>>2];c[B+12>>2]=c[s+12>>2];H=+h[s>>3];m=+h[t>>3];H=H-(m-H);h[u>>3]=H;o=+h[v>>3];F=+h[w>>3];o=o-(F-o);h[x>>3]=o;h[z>>3]=+h[y>>3]+H-m;h[b>>3]=+h[A>>3]+o-F;c[f>>2]=c[d>>2];c[f+4>>2]=c[d+4>>2];c[f+8>>2]=c[d+8>>2];c[f+12>>2]=c[d+12>>2];KD(a,B,4);_I(G);break}else ma(90472,90483,737,90492)}if((e|0)<117440512){switch(e|0){case 100663296:break;default:break a}y=d+5|0;G=vw(y<<4)|0;z=b+16|0;H=+h[z>>3];H=(+h[b>>3]-H)*.625+H;h[G>>3]=H;A=b+40|0;J=+h[A>>3];d=b+24|0;v=D+48|0;w=D+56|0;x=D+72|0;J=(+h[d>>3]-J)*.5+J+(+h[w>>3]-+h[x>>3])*1.5;h[G+8>>3]=J;I=+h[z>>3];I=(+h[b>>3]-I)*.25+I;h[G+16>>3]=I;h[G+24>>3]=J;h[G+32>>3]=I;F=+h[A>>3];h[G+40>>3]=(+h[d>>3]-F)*.5+F;I=(+h[k>>3]-+h[v>>3])*.5+I;h[G+48>>3]=I;F=+h[A>>3];h[G+56>>3]=(+h[d>>3]-F)*.5+F;h[G+64>>3]=I;I=+h[A>>3];I=(+h[d>>3]-I)*.5+I+(+h[w>>3]-+h[x>>3]);h[G+72>>3]=I;h[G+80>>3]=H;h[G+88>>3]=I;h[G+96>>3]=H;I=I-(+h[w>>3]-+h[x>>3])*.25;h[G+104>>3]=I;h[G+112>>3]=+h[k>>3]+H-+h[v>>3];h[G+120>>3]=(+h[w>>3]-+h[x>>3])*.5+I;h[G+128>>3]=+h[G>>3];h[G+136>>3]=(+h[w>>3]-+h[x>>3])*.25+J;HD(a,G,y,f);h[B>>3]=+h[z>>3];J=+h[A>>3];h[B+8>>3]=(+h[d>>3]-J)*.5+J;h[B+16>>3]=+h[b>>3];h[B+24>>3]=(+h[b+8>>3]-+h[b+56>>3])*.5+J;KD(a,B,2);_I(G);break}else{switch(e|0){case 117440512:break;default:break a}d=d+1|0;G=vw(d<<4)|0;h[G>>3]=+h[j>>3];z=D+56|0;A=D+72|0;h[G+8>>3]=+h[D+24>>3]-(+h[z>>3]-+h[A>>3])*.5;h[G+16>>3]=+h[D+48>>3];J=+h[z>>3];h[G+24>>3]=J-(J-+h[A>>3])*.5;h[G+32>>3]=+h[b+32>>3];B=b+40|0;h[G+40>>3]=(+h[z>>3]-+h[A>>3])*.5+ +h[B>>3];h[G+48>>3]=+h[j>>3];h[G+56>>3]=(+h[z>>3]-+h[A>>3])*.5+ +h[B>>3];J=+h[b+8>>3];h[G+72>>3]=J-(J-+h[b+56>>3])*.5;h[G+64>>3]=+h[b>>3];HD(a,G,d,f);_I(G);break}}if((e|0)<167772160)if((e|0)<150994944){switch(e|0){case 134217728:break;default:break a}y=d+4|0;G=vw(y<<4)|0;z=b+16|0;F=+h[z>>3];x=D+48|0;F=(+h[b>>3]-F)*.5+F+(+h[k>>3]-+h[x>>3])*.25;h[G>>3]=F;A=b+40|0;J=+h[A>>3];d=b+24|0;J=(+h[d>>3]-J)*.5+J;h[G+8>>3]=J;h[G+16>>3]=F;v=D+56|0;w=D+72|0;H=(+h[v>>3]-+h[w>>3])*.5+J;h[G+24>>3]=H;F=(+h[k>>3]-+h[x>>3])*.5+F;h[G+32>>3]=F;h[G+40>>3]=H;h[G+48>>3]=F;F=(+h[v>>3]-+h[w>>3])*.5+H;h[G+56>>3]=F;I=+h[z>>3];I=(+h[b>>3]-I)*.5+I+(+h[k>>3]-+h[x>>3])*-.75;h[G+64>>3]=I;h[G+72>>3]=F;h[G+80>>3]=I;h[G+88>>3]=H;I=+h[z>>3];I=(+h[b>>3]-I)*.5+I+(+h[k>>3]-+h[x>>3])*-.25;h[G+96>>3]=I;h[G+104>>3]=H;h[G+112>>3]=I;h[G+120>>3]=J;HD(a,G,y,f);h[B>>3]=+h[z>>3];J=+h[A>>3];h[B+8>>3]=(+h[d>>3]-J)*.5+J;h[B+16>>3]=+h[b>>3];h[B+24>>3]=(+h[b+8>>3]-+h[b+56>>3])*.5+J;KD(a,B,2);_I(G);break}else{switch(e|0){case 150994944:break;default:break a}y=d+2|0;G=vw(y<<4)|0;z=b+16|0;H=+h[z>>3];x=D+48|0;H=(+h[b>>3]-H)*.5+H+(+h[k>>3]-+h[x>>3])*.75;h[G>>3]=H;A=b+40|0;J=+h[A>>3];d=b+24|0;J=(+h[d>>3]-J)*.5+J;h[G+8>>3]=J;h[G+16>>3]=H;v=D+56|0;w=D+72|0;H=(+h[v>>3]-+h[w>>3])*.25+J;h[G+24>>3]=H;I=+h[z>>3];h[G+32>>3]=(+h[b>>3]-I)*.5+I+(+h[k>>3]-+h[x>>3])*.25;I=(+h[v>>3]-+h[w>>3])*.5+H;h[G+40>>3]=I;F=+h[z>>3];h[G+48>>3]=(+h[b>>3]-F)*.5+F+(+h[k>>3]-+h[x>>3])*-.25;h[G+56>>3]=I;I=+h[z>>3];I=(+h[b>>3]-I)*.5+I+(+h[k>>3]-+h[x>>3])*-.75;h[G+64>>3]=I;h[G+72>>3]=H;h[G+80>>3]=I;h[G+88>>3]=J;HD(a,G,y,f);h[B>>3]=+h[z>>3];J=+h[A>>3];h[B+8>>3]=(+h[d>>3]-J)*.5+J;h[B+16>>3]=+h[b>>3];h[B+24>>3]=(+h[b+8>>3]-+h[b+56>>3])*.5+J;KD(a,B,2);_I(G);break}else if((e|0)<184549376){switch(e|0){case 167772160:break;default:break a}y=d+1|0;G=vw(y<<4)|0;z=b+16|0;H=+h[z>>3];v=D+48|0;H=+h[k>>3]+H+(+h[b>>3]-H)*.5-+h[v>>3];h[G>>3]=H;A=b+40|0;J=+h[A>>3];d=b+24|0;w=D+56|0;x=D+72|0;J=(+h[d>>3]-J)*.5+J+(+h[w>>3]-+h[x>>3])*.25;h[G+8>>3]=J;H=H-+h[k>>3]+ +h[v>>3];h[G+16>>3]=H;h[G+24>>3]=+h[w>>3]+J-+h[x>>3];h[G+32>>3]=H;H=(+h[w>>3]-+h[x>>3])*.5+J;h[G+40>>3]=H;I=+h[z>>3];I=(+h[b>>3]-I)*.25+I;h[G+48>>3]=I;h[G+56>>3]=H;h[G+64>>3]=I;h[G+72>>3]=J;HD(a,G,y,f);h[B>>3]=+h[z>>3];J=+h[A>>3];h[B+8>>3]=(+h[d>>3]-J)*.5+J;h[B+16>>3]=+h[b>>3];h[B+24>>3]=(+h[b+8>>3]-+h[b+56>>3])*.5+J;KD(a,B,2);_I(G);break}else{switch(e|0){case 184549376:break;default:break a}z=d+4|0;G=vw(z<<4)|0;y=b+16|0;H=+h[y>>3];I=+h[b>>3]-H;u=D+48|0;I=I*.125+H+(+h[k>>3]-+h[u>>3]+I)*.5;h[G>>3]=I;w=b+40|0;H=+h[w>>3];x=b+24|0;d=D+56|0;v=D+72|0;H=(+h[x>>3]-H)*.5+H+(+h[d>>3]-+h[v>>3])*.25;h[G+8>>3]=H;J=+h[y>>3];J=(+h[b>>3]-J)*.375+J;h[G+16>>3]=J;h[G+24>>3]=H;h[G+32>>3]=J;H=(+h[d>>3]-+h[v>>3])*.5+H;h[G+40>>3]=H;J=J-(+h[k>>3]-+h[u>>3])*.5;h[G+48>>3]=J;h[G+56>>3]=H;A=G+64|0;h[A>>3]=J;J=+h[w>>3];J=(+h[x>>3]-J)*.5+J+(+h[d>>3]-+h[v>>3])*-.25;h[G+72>>3]=J;H=I-(+h[k>>3]-+h[u>>3])*.5;h[G+80>>3]=H;h[G+88>>3]=J;h[G+96>>3]=H;J=J-(+h[d>>3]-+h[v>>3])*.5;h[G+104>>3]=J;v=G+112|0;h[v>>3]=I;h[G+120>>3]=J;HD(a,G,z,f);h[B>>3]=+h[y>>3];J=+h[w>>3];y=B+8|0;h[y>>3]=(+h[x>>3]-J)*.5+J;z=B+16|0;h[z>>3]=+h[A>>3];A=b+8|0;d=b+56|0;f=B+24|0;h[f>>3]=(+h[A>>3]-+h[d>>3])*.5+J;KD(a,B,2);h[B>>3]=+h[v>>3];J=+h[w>>3];h[y>>3]=(+h[x>>3]-J)*.5+J;h[z>>3]=+h[b>>3];h[f>>3]=(+h[A>>3]-+h[d>>3])*.5+J;KD(a,B,2);_I(G);break}}if((e|0)<33554432){if((e|0)<8){switch(e|0){case 4:break;default:break a}i=ww((d*96|0)+32|0)|0;e=0;g=0;while(1){j=g|1;k=i+(g<<4)|0;if((e|0)>=(d|0))break;b=e<<2;G=D+(b<<4)|0;c[k>>2]=c[G>>2];c[k+4>>2]=c[G+4>>2];c[k+8>>2]=c[G+8>>2];c[k+12>>2]=c[G+12>>2];G=i+(j<<4)|0;B=D+((b|1)<<4)|0;c[G>>2]=c[B>>2];c[G+4>>2]=c[B+4>>2];c[G+8>>2]=c[B+8>>2];c[G+12>>2]=c[B+12>>2];G=i+(g+2<<4)|0;c[G>>2]=c[B>>2];c[G+4>>2]=c[B+4>>2];c[G+8>>2]=c[B+8>>2];c[G+12>>2]=c[B+12>>2];G=i+(g+3<<4)|0;B=D+((b|2)<<4)|0;c[G>>2]=c[B>>2];c[G+4>>2]=c[B+4>>2];c[G+8>>2]=c[B+8>>2];c[G+12>>2]=c[B+12>>2];G=i+(g+4<<4)|0;c[G>>2]=c[B>>2];c[G+4>>2]=c[B+4>>2];c[G+8>>2]=c[B+8>>2];c[G+12>>2]=c[B+12>>2];G=i+(g+5<<4)|0;b=D+((b|3)<<4)|0;c[G>>2]=c[b>>2];c[G+4>>2]=c[b+4>>2];c[G+8>>2]=c[b+8>>2];c[G+12>>2]=c[b+12>>2];e=e+1|0;g=g+6|0}c[k>>2]=c[i>>2];c[k+4>>2]=c[i+4>>2];c[k+8>>2]=c[i+8>>2];c[k+12>>2]=c[i+12>>2];d=i+(j<<4)|0;G=i+16|0;c[d>>2]=c[G>>2];c[d+4>>2]=c[G+4>>2];c[d+8>>2]=c[G+8>>2];c[d+12>>2]=c[G+12>>2];JD(a,G,j,0,0,f&255);_I(i);break}if((e|0)<16777216){switch(e|0){case 8:break;default:break a}HD(a,b,d,f);g=B+16|0;e=0;while(1){if((e|0)>=(d|0))break a;G=e*3|0;f=D+(G+2<<4)|0;c[B>>2]=c[f>>2];c[B+4>>2]=c[f+4>>2];c[B+8>>2]=c[f+8>>2];c[B+12>>2]=c[f+12>>2];G=D+(G+4<<4)|0;c[g>>2]=c[G>>2];c[g+4>>2]=c[G+4>>2];c[g+8>>2]=c[G+8>>2];c[g+12>>2]=c[G+12>>2];KD(a,B,2);e=e+1|0}}switch(e|0){case 16777216:break;default:break a}g=d+1|0;i=vw(g<<4)|0;e=1;while(1){if((e|0)>=(d|0))break;G=i+(e<<4)|0;A=b+(e<<4)|0;c[G>>2]=c[A>>2];c[G+4>>2]=c[A+4>>2];c[G+8>>2]=c[A+8>>2];c[G+12>>2]=c[A+12>>2];e=e+1|0}b=d*3|0;A=D+(b+1<<4)|0;c[i>>2]=c[A>>2];c[i+4>>2]=c[A+4>>2];c[i+8>>2]=c[A+8>>2];c[i+12>>2]=c[A+12>>2];d=i+(d<<4)|0;G=D+(b+-1<<4)|0;c[d>>2]=c[G>>2];c[d+4>>2]=c[G+4>>2];c[d+8>>2]=c[G+8>>2];c[d+12>>2]=c[G+12>>2];HD(a,i,g,f);_I(i);c[B>>2]=c[G>>2];c[B+4>>2]=c[G+4>>2];c[B+8>>2]=c[G+8>>2];c[B+12>>2]=c[G+12>>2];G=B+16|0;c[G>>2]=c[A>>2];c[G+4>>2]=c[A+4>>2];c[G+8>>2]=c[A+8>>2];c[G+12>>2]=c[A+12>>2];f=B+32|0;h[f>>3]=+h[B>>3]+ +h[G>>3]-+h[D+(b<<4)>>3];h[B+40>>3]=+h[B+8>>3]+ +h[B+24>>3]-+h[D+(b<<4)+8>>3];KD(a,G,2);c[G>>2]=c[f>>2];c[G+4>>2]=c[f+4>>2];c[G+8>>2]=c[f+8>>2];c[G+12>>2]=c[f+12>>2];KD(a,B,2);break}else{if((e|0)<50331648){switch(e|0){case 33554432:break;default:break a}g=d+2|0;i=vw(g<<4)|0;c[i>>2]=c[b>>2];c[i+4>>2]=c[b+4>>2];c[i+8>>2]=c[b+8>>2];c[i+12>>2]=c[b+12>>2];j=i+16|0;c[j>>2]=c[k>>2];c[j+4>>2]=c[k+4>>2];c[j+8>>2]=c[k+8>>2];c[j+12>>2]=c[k+12>>2];j=D+48|0;d=D+64|0;h[i+32>>3]=(+h[j>>3]-+h[d>>3])*.3333333333333333+ +h[k>>3];G=D+56|0;e=D+72|0;h[i+40>>3]=(+h[G>>3]-+h[e>>3])*.3333333333333333+ +h[D+40>>3];J=+h[j>>3];h[i+48>>3]=(J-+h[d>>3])*.3333333333333333+J;J=+h[G>>3];h[i+56>>3]=(J-+h[e>>3])*.3333333333333333+J;e=4;while(1){if((e|0)>=(g|0))break;G=i+(e<<4)|0;d=b+(e+-2<<4)|0;c[G>>2]=c[d>>2];c[G+4>>2]=c[d+4>>2];c[G+8>>2]=c[d+8>>2];c[G+12>>2]=c[d+12>>2];e=e+1|0}HD(a,i,g,f);_I(i);c[B>>2]=c[j>>2];c[B+4>>2]=c[j+4>>2];c[B+8>>2]=c[j+8>>2];c[B+12>>2]=c[j+12>>2];G=B+16|0;c[G>>2]=c[k>>2];c[G+4>>2]=c[k+4>>2];c[G+8>>2]=c[k+8>>2];c[G+12>>2]=c[k+12>>2];KD(a,B,2);break}if((e|0)>=67108864){switch(e|0){case 67108864:break;default:break a}if((d|0)==4){G=vw(96)|0;c[G>>2]=c[b>>2];c[G+4>>2]=c[b+4>>2];c[G+8>>2]=c[b+8>>2];c[G+12>>2]=c[b+12>>2];d=G+16|0;c[d>>2]=c[k>>2];c[d+4>>2]=c[k+4>>2];c[d+8>>2]=c[k+8>>2];c[d+12>>2]=c[k+12>>2];d=G+32|0;A=D+64|0;c[d>>2]=c[A>>2];c[d+4>>2]=c[A+4>>2];c[d+8>>2]=c[A+8>>2];c[d+12>>2]=c[A+12>>2];d=G+48|0;b=b+32|0;c[d>>2]=c[b>>2];c[d+4>>2]=c[b+4>>2];c[d+8>>2]=c[b+8>>2];c[d+12>>2]=c[b+12>>2];b=G+64|0;d=D+128|0;c[b>>2]=c[d>>2];c[b+4>>2]=c[d+4>>2];c[b+8>>2]=c[d+8>>2];c[b+12>>2]=c[d+12>>2];b=G+80|0;z=D+160|0;c[b>>2]=c[z>>2];c[b+4>>2]=c[z+4>>2];c[b+8>>2]=c[z+8>>2];c[b+12>>2]=c[z+12>>2];HD(a,G,6,f);_I(G);h[B>>3]=+h[D+176>>3]+ +h[j>>3]-+h[D>>3];h[B+8>>3]=+h[D+184>>3]+ +h[D+24>>3]-+h[D+8>>3];G=B+16|0;c[G>>2]=c[A>>2];c[G+4>>2]=c[A+4>>2];c[G+8>>2]=c[A+8>>2];c[G+12>>2]=c[A+12>>2];KD(a,B,2);c[G>>2]=c[d>>2];c[G+4>>2]=c[d+4>>2];c[G+8>>2]=c[d+8>>2];c[G+12>>2]=c[d+12>>2];KD(a,B,2);c[G>>2]=c[D>>2];c[G+4>>2]=c[D+4>>2];c[G+8>>2]=c[D+8>>2];c[G+12>>2]=c[D+12>>2];KD(a,B,2);break}else ma(90472,90483,714,90492)}switch(e|0){case 50331648:break;default:break a}g=d+3|0;i=vw(g<<4)|0;c[i>>2]=c[b>>2];c[i+4>>2]=c[b+4>>2];c[i+8>>2]=c[b+8>>2];c[i+12>>2]=c[b+12>>2];J=+h[b>>3];h[i+16>>3]=J-(J-+h[j>>3])*.25;e=D+56|0;J=(+h[e>>3]-+h[D+72>>3])*.3333333333333333+ +h[b+8>>3];h[i+24>>3]=J;I=+h[b>>3];h[i+32>>3]=I-(I-+h[j>>3])*2.0;h[i+40>>3]=J;J=+h[b>>3];h[i+48>>3]=J-(J-+h[j>>3])*2.25;h[i+56>>3]=+h[e>>3];h[i+64>>3]=+h[D+48>>3];h[i+72>>3]=+h[e>>3];e=4;while(1){if((e|0)>=(g|0))break;G=i+(e<<4)|0;d=b+(e+-3<<4)|0;c[G>>2]=c[d>>2];c[G+4>>2]=c[d+4>>2];c[G+8>>2]=c[d+8>>2];c[G+12>>2]=c[d+12>>2];e=e+1|0}HD(a,i,g,f);_I(i);break}}else if((e|0)<318767104){if((e|0)<251658240){if((e|0)<218103808){switch(e|0){case 201326592:break;default:break a}G=d<<4;u=vw(G)|0;v=b+16|0;J=+h[v>>3];h[u>>3]=J;z=b+40|0;I=+h[z>>3];A=b+24|0;y=D+48|0;w=D+56|0;x=D+72|0;I=(+h[A>>3]-I)*.5+I+(+h[w>>3]-+h[x>>3])*.125;h[u+8>>3]=I;H=(+h[k>>3]-+h[y>>3])*2.0+J;h[u+16>>3]=H;h[u+24>>3]=I;h[u+32>>3]=H;I=(+h[w>>3]-+h[x>>3])*.5+I;h[u+40>>3]=I;h[u+48>>3]=J;h[u+56>>3]=I;HD(a,u,d,f);_I(u);G=vw(G)|0;I=+h[k>>3]+ +h[v>>3]-+h[y>>3];h[G>>3]=I;J=+h[z>>3];J=(+h[A>>3]-J)*.5+J+(+h[w>>3]-+h[x>>3])*-.625;h[G+8>>3]=J;H=+h[k>>3]-+h[y>>3]+I;y=G+16|0;h[y>>3]=H;h[G+24>>3]=J;h[G+32>>3]=H;J=(+h[w>>3]-+h[x>>3])*.5+J;h[G+40>>3]=J;h[G+48>>3]=I;h[G+56>>3]=J;HD(a,G,d,f);h[B>>3]=+h[y>>3];J=+h[z>>3];h[B+8>>3]=(+h[A>>3]-J)*.5+J;h[B+16>>3]=+h[b>>3];h[B+24>>3]=(+h[b+8>>3]-+h[b+56>>3])*.5+J;KD(a,B,2);_I(G);break}if((e|0)<234881024){switch(e|0){case 218103808:break;default:break a}G=d<<4;w=vw(G)|0;J=+h[b>>3];h[w>>3]=J;y=b+40|0;I=+h[y>>3];z=b+24|0;x=D+56|0;A=D+72|0;I=(+h[z>>3]-I)*.5+I+(+h[x>>3]-+h[A>>3])*.125;h[w+8>>3]=I;h[w+16>>3]=J;H=(+h[x>>3]-+h[A>>3])*.5+I;h[w+24>>3]=H;J=J-(+h[x>>3]-+h[A>>3])*2.0;h[w+32>>3]=J;h[w+40>>3]=H;h[w+48>>3]=J;h[w+56>>3]=I;HD(a,w,d,f);_I(w);G=vw(G)|0;I=+h[b>>3]-+h[k>>3]+ +h[D+48>>3];h[G>>3]=I;J=+h[y>>3];J=(+h[z>>3]-J)*.5+J+(+h[x>>3]-+h[A>>3])*-.625;h[G+8>>3]=J;h[G+16>>3]=I;H=(+h[x>>3]-+h[A>>3])*.5+J;h[G+24>>3]=H;I=I-(+h[x>>3]-+h[A>>3]);h[G+32>>3]=I;h[G+40>>3]=H;A=G+48|0;h[A>>3]=I;h[G+56>>3]=J;HD(a,G,d,f);h[B>>3]=+h[b+16>>3];J=+h[y>>3];h[B+8>>3]=(+h[z>>3]-J)*.5+J;h[B+16>>3]=+h[A>>3];h[B+24>>3]=(+h[b+8>>3]-+h[b+56>>3])*.5+J;KD(a,B,2);_I(G);break}else{switch(e|0){case 234881024:break;default:break a}G=d<<4;y=vw(G)|0;u=b+16|0;I=+h[u>>3];v=D+48|0;I=(+h[b>>3]-I)*.5+I+(+h[k>>3]-+h[v>>3])*-1.125;h[y>>3]=I;w=b+40|0;J=+h[w>>3];x=b+24|0;A=D+56|0;z=D+72|0;J=(+h[x>>3]-J)*.5+J+(+h[A>>3]-+h[z>>3])*.125;h[y+8>>3]=J;H=+h[k>>3]-+h[v>>3]+I;h[y+16>>3]=H;h[y+24>>3]=J;h[y+32>>3]=H;J=(+h[A>>3]-+h[z>>3])*.5+J;h[y+40>>3]=J;h[y+48>>3]=I;h[y+56>>3]=J;HD(a,y,d,f);_I(y);y=vw(G)|0;J=+h[u>>3];J=(+h[b>>3]-J)*.5+J+(+h[k>>3]-+h[v>>3])*-1.125;h[y>>3]=J;I=+h[w>>3];I=(+h[x>>3]-I)*.5+I+(+h[A>>3]-+h[z>>3])*-.625;h[y+8>>3]=I;H=+h[k>>3]-+h[v>>3]+J;h[y+16>>3]=H;h[y+24>>3]=I;h[y+32>>3]=H;I=(+h[A>>3]-+h[z>>3])*.5+I;h[y+40>>3]=I;h[y+48>>3]=J;h[y+56>>3]=I;HD(a,y,d,f);_I(y);y=vw(G)|0;I=+h[u>>3];I=(+h[b>>3]-I)*.5+I+(+h[k>>3]-+h[v>>3])*.125;h[y>>3]=I;J=+h[w>>3];J=(+h[x>>3]-J)*.5+J+(+h[A>>3]-+h[z>>3])*-.625;h[y+8>>3]=J;H=+h[k>>3]-+h[v>>3]+I;h[y+16>>3]=H;h[y+24>>3]=J;h[y+32>>3]=H;J=(+h[A>>3]-+h[z>>3])*.5+J;h[y+40>>3]=J;h[y+48>>3]=I;h[y+56>>3]=J;HD(a,y,d,f);_I(y);G=vw(G)|0;J=+h[u>>3];J=(+h[b>>3]-J)*.5+J+(+h[k>>3]-+h[v>>3])*.125;h[G>>3]=J;I=+h[w>>3];I=(+h[x>>3]-I)*.5+I+(+h[A>>3]-+h[z>>3])*.125;h[G+8>>3]=I;H=+h[k>>3]-+h[v>>3]+J;y=G+16|0;h[y>>3]=H;h[G+24>>3]=I;h[G+32>>3]=H;I=(+h[A>>3]-+h[z>>3])*.5+I;h[G+40>>3]=I;h[G+48>>3]=J;h[G+56>>3]=I;HD(a,G,d,f);h[B>>3]=+h[y>>3];I=+h[w>>3];y=B+8|0;h[y>>3]=(+h[x>>3]-I)*.5+I;z=B+16|0;h[z>>3]=+h[b>>3];A=b+8|0;d=b+56|0;f=B+24|0;h[f>>3]=(+h[A>>3]-+h[d>>3])*.5+I;KD(a,B,2);I=+h[u>>3];h[B>>3]=(+h[b>>3]-I)*.5+I+(+h[k>>3]-+h[v>>3])*-1.125;J=+h[w>>3];h[y>>3]=(+h[x>>3]-J)*.5+J;h[z>>3]=I;h[f>>3]=(+h[A>>3]-+h[d>>3])*.5+J;KD(a,B,2);_I(G);break}}if((e|0)<285212672)if((e|0)<268435456){switch(e|0){case 251658240:break;default:break a}G=d<<4;u=vw(G)|0;v=b+16|0;J=+h[v>>3];y=D+48|0;J=J-+h[k>>3]+(+h[b>>3]-J)*.5+ +h[y>>3];h[u>>3]=J;w=b+40|0;I=+h[w>>3];x=b+24|0;A=D+56|0;z=D+72|0;I=(+h[x>>3]-I)*.5+I+(+h[A>>3]-+h[z>>3])*.125;h[u+8>>3]=I;H=(+h[k>>3]-+h[y>>3])*2.0+J;h[u+16>>3]=H;h[u+24>>3]=I;h[u+32>>3]=H;I=(+h[A>>3]-+h[z>>3])*.5+I;h[u+40>>3]=I;h[u+48>>3]=J;h[u+56>>3]=I;HD(a,u,d,f);_I(u);G=vw(G)|0;I=+h[v>>3];I=I-+h[k>>3]+(+h[b>>3]-I)*.5+ +h[y>>3];h[G>>3]=I;J=+h[w>>3];J=(+h[x>>3]-J)*.5+J+(+h[A>>3]-+h[z>>3])*-.625;h[G+8>>3]=J;H=(+h[k>>3]-+h[y>>3])*2.0+I;y=G+16|0;h[y>>3]=H;h[G+24>>3]=J;h[G+32>>3]=H;J=(+h[A>>3]-+h[z>>3])*.5+J;h[G+40>>3]=J;h[G+48>>3]=I;h[G+56>>3]=J;HD(a,G,d,f);h[B>>3]=+h[y>>3];J=+h[w>>3];y=B+8|0;h[y>>3]=(+h[x>>3]-J)*.5+J;z=B+16|0;h[z>>3]=+h[b>>3];A=b+8|0;d=b+56|0;f=B+24|0;h[f>>3]=(+h[A>>3]-+h[d>>3])*.5+J;KD(a,B,2);h[B>>3]=+h[v>>3];J=+h[w>>3];h[y>>3]=(+h[x>>3]-J)*.5+J;h[z>>3]=+h[G>>3];h[f>>3]=(+h[A>>3]-+h[d>>3])*.5+J;KD(a,B,2);_I(G);break}else{switch(e|0){case 268435456:break;default:break a}G=vw(d<<4)|0;h[G>>3]=+h[b>>3];v=D+48|0;x=D+56|0;y=D+72|0;h[G+8>>3]=+h[D+24>>3]-(+h[x>>3]-+h[y>>3])*.5;h[G+16>>3]=+h[v>>3];J=+h[x>>3];h[G+24>>3]=J-(J-+h[y>>3])*.5;h[G+32>>3]=+h[b+32>>3];z=b+40|0;h[G+40>>3]=(+h[x>>3]-+h[y>>3])*.5+ +h[z>>3];h[G+48>>3]=+h[b>>3];h[G+56>>3]=(+h[x>>3]-+h[y>>3])*.5+ +h[z>>3];HD(a,G,d,f);w=b+16|0;J=(+h[k>>3]-+h[v>>3])*.25;I=J+ +h[w>>3];h[B>>3]=I;H=+h[z>>3];u=b+24|0;F=+h[x>>3]-+h[y>>3];H=(+h[u>>3]-H)*.5+H+F*.125;A=B+8|0;h[A>>3]=H;d=B+16|0;h[d>>3]=J+I;f=B+24|0;h[f>>3]=H-F*.25;KD(a,B,2);F=(+h[k>>3]-+h[v>>3])*.25;H=F+ +h[w>>3];h[B>>3]=H;I=+h[z>>3];J=+h[x>>3]-+h[y>>3];I=(+h[u>>3]-I)*.5+I+J*-.125;h[A>>3]=I;h[d>>3]=F+H;h[f>>3]=J*.25+I;KD(a,B,2);I=(+h[k>>3]-+h[v>>3])*.25;h[B>>3]=I+ +h[w>>3];J=(+h[x>>3]-+h[y>>3])*.75+ +h[z>>3];h[A>>3]=J;h[d>>3]=+h[b>>3]-I;h[f>>3]=J;KD(a,B,2);_I(G);break}else if((e|0)<301989888){switch(e|0){case 285212672:break;default:break a}y=vw(d<<4)|0;v=b+16|0;I=+h[v>>3];z=D+48|0;I=(+h[k>>3]-+h[z>>3]+(+h[b>>3]-I))*.5+I;h[y>>3]=I;w=b+40|0;F=+h[w>>3];x=b+24|0;F=(+h[k>>3]-+h[z>>3]+(+h[x>>3]-F))*.5+F;h[y+8>>3]=F;h[y+16>>3]=I;I=+h[w>>3];o=+h[k>>3]-+h[z>>3];I=(+h[x>>3]-I-o)*.5+I;h[y+24>>3]=I;J=+h[v>>3];J=(+h[b>>3]-J-o)*.5+J;h[y+32>>3]=J;h[y+40>>3]=I;h[y+48>>3]=J;h[y+56>>3]=F;HD(a,y,d,f);_I(y);F=+h[v>>3];F=(+h[b>>3]-F)*.5+F;J=+h[k>>3]-+h[z>>3];I=J*.75;o=F+I;h[B>>3]=o;H=+h[w>>3];H=(+h[x>>3]-H)*.5+H;I=H+I;y=B+8|0;h[y>>3]=I;A=B+16|0;h[A>>3]=o;J=J*-.75;H=H+J;G=B+24|0;h[G>>3]=H;J=F+J;h[B+32>>3]=J;h[B+40>>3]=H;h[B+48>>3]=J;h[B+56>>3]=I;d=B+64|0;c[d>>2]=c[B>>2];c[d+4>>2]=c[B+4>>2];c[d+8>>2]=c[B+8>>2];c[d+12>>2]=c[B+12>>2];KD(a,B,5);I=+h[v>>3];J=+h[b>>3];h[B>>3]=(J-I)*.5+I+(+h[k>>3]-+h[z>>3])*.75;I=+h[w>>3];h[y>>3]=(+h[x>>3]-I)*.5+I;h[A>>3]=J;d=b+8|0;f=b+56|0;h[G>>3]=(+h[d>>3]-+h[f>>3])*.5+I;KD(a,B,2);I=+h[v>>3];h[B>>3]=I;J=+h[w>>3];h[y>>3]=(+h[x>>3]-J)*.5+J;h[A>>3]=(+h[b>>3]-I)*.5+I+(+h[k>>3]-+h[z>>3])*-.75;h[G>>3]=(+h[d>>3]-+h[f>>3])*.5+J;KD(a,B,2);break}else{switch(e|0){case 301989888:break;default:break a}A=d+12|0;G=vw(A<<4)|0;x=b+16|0;m=+h[x>>3];s=D+48|0;m=(+h[b>>3]-m)*.5+m+(+h[k>>3]-+h[s>>3])*.25;h[G>>3]=m;y=b+40|0;F=+h[y>>3];z=b+24|0;v=D+56|0;w=D+72|0;F=(+h[v>>3]-+h[w>>3]+(+h[z>>3]-F))*.5+F;u=G+8|0;h[u>>3]=F;h[G+16>>3]=m;F=(+h[v>>3]-+h[w>>3])*.125+F;t=G+24|0;h[t>>3]=F;H=m-(+h[k>>3]-+h[s>>3])*.125;d=G+32|0;h[d>>3]=H;o=(+h[v>>3]-+h[w>>3])*.125+F;h[G+40>>3]=o;h[G+48>>3]=m;I=(+h[v>>3]-+h[w>>3])*.125+o;h[G+56>>3]=I;h[G+64>>3]=m;m=(+h[v>>3]-+h[w>>3])*.125+I;h[G+72>>3]=m;h[G+80>>3]=H;h[G+88>>3]=m;H=+h[x>>3];H=(+h[b>>3]-H)*.5+H;h[G+96>>3]=H;h[G+104>>3]=I;J=H-(+h[k>>3]-+h[s>>3])*.125;h[G+112>>3]=J;h[G+120>>3]=m;J=J-(+h[k>>3]-+h[s>>3])*.125;h[G+128>>3]=J;h[G+136>>3]=m;h[G+144>>3]=J;h[G+152>>3]=I;I=(+h[k>>3]-+h[s>>3])*.125+J;h[G+160>>3]=I;h[G+168>>3]=o;h[G+176>>3]=J;h[G+184>>3]=F;h[G+192>>3]=J;J=+h[u>>3];h[G+200>>3]=J;h[G+208>>3]=I;h[G+216>>3]=J;u=G+224|0;h[u>>3]=H;h[G+232>>3]=+h[t>>3];h[G+240>>3]=+h[d>>3];h[G+248>>3]=J;HD(a,G,A,f);J=+h[u>>3];h[B>>3]=J;H=+h[y>>3];H=(+h[z>>3]-H)*.5+H;A=B+8|0;h[A>>3]=H;d=B+16|0;h[d>>3]=J;f=B+24|0;h[f>>3]=(+h[v>>3]-+h[w>>3])*.125+H;KD(a,B,2);H=+h[u>>3];h[B>>3]=H;J=+h[y>>3];I=+h[v>>3]-+h[w>>3];J=(+h[z>>3]-J)*.5+J+I*.25;h[A>>3]=J;h[d>>3]=H;h[f>>3]=I*.125+J;KD(a,B,2);h[B>>3]=+h[x>>3];J=+h[y>>3];h[A>>3]=(+h[z>>3]-J)*.5+J;h[d>>3]=+h[b>>3];h[f>>3]=(+h[b+8>>3]-+h[b+56>>3])*.5+J;KD(a,B,2);_I(G);break}}else{if((e|0)<369098752){if((e|0)<335544320){switch(e|0){case 318767104:break;default:break a}A=d+4|0;G=vw(A<<4)|0;x=b+16|0;H=+h[x>>3];d=D+48|0;H=(+h[b>>3]-H)*.5+H+(+h[k>>3]-+h[d>>3])*.125;h[G>>3]=H;y=b+40|0;J=+h[y>>3];z=b+24|0;v=D+56|0;w=D+72|0;J=(+h[v>>3]-+h[w>>3]+(+h[z>>3]-J))*.5+J;h[G+8>>3]=J;o=(+h[k>>3]-+h[d>>3])*.125+H;h[G+16>>3]=o;I=(+h[v>>3]-+h[w>>3])*.125+J;h[G+24>>3]=I;h[G+32>>3]=o;o=(+h[v>>3]-+h[w>>3])*.25+I;h[G+40>>3]=o;h[G+48>>3]=H;F=(+h[v>>3]-+h[w>>3])*.125+o;h[G+56>>3]=F;H=H-(+h[k>>3]-+h[d>>3])*.25;h[G+64>>3]=H;h[G+72>>3]=F;F=H-(+h[k>>3]-+h[d>>3])*.125;h[G+80>>3]=F;h[G+88>>3]=o;h[G+96>>3]=F;h[G+104>>3]=I;h[G+112>>3]=H;h[G+120>>3]=J;HD(a,G,A,f);J=+h[x>>3];J=(+h[b>>3]-J)*.5+J;h[B>>3]=J;H=+h[y>>3];H=(+h[z>>3]-H)*.5+H;A=B+8|0;h[A>>3]=H;d=B+16|0;h[d>>3]=J;f=B+24|0;h[f>>3]=(+h[v>>3]-+h[w>>3])*.125+H;KD(a,B,2);H=+h[x>>3];H=(+h[b>>3]-H)*.5+H;h[B>>3]=H;J=+h[y>>3];I=+h[v>>3]-+h[w>>3];J=(+h[z>>3]-J)*.5+J+I*.25;h[A>>3]=J;h[d>>3]=H;h[f>>3]=I*.125+J;KD(a,B,2);h[B>>3]=+h[x>>3];J=+h[y>>3];h[A>>3]=(+h[z>>3]-J)*.5+J;h[d>>3]=+h[b>>3];h[f>>3]=(+h[b+8>>3]-+h[b+56>>3])*.5+J;KD(a,B,2);_I(G);break}if((e|0)<352321536){switch(e|0){case 335544320:break;default:break a}x=d+12|0;G=vw(x<<4)|0;y=b+16|0;m=+h[y>>3];u=D+48|0;m=(+h[b>>3]-m)*.5+m+(+h[k>>3]-+h[u>>3])*.25;h[G>>3]=m;z=b+40|0;F=+h[z>>3];A=b+24|0;s=D+56|0;t=D+72|0;F=(+h[s>>3]-+h[t>>3]+(+h[A>>3]-F))*.5+F;d=G+8|0;h[d>>3]=F;h[G+16>>3]=m;F=(+h[s>>3]-+h[t>>3])*.125+F;v=G+24|0;h[v>>3]=F;I=m-(+h[k>>3]-+h[u>>3])*.125;w=G+32|0;h[w>>3]=I;o=(+h[s>>3]-+h[t>>3])*.125+F;h[G+40>>3]=o;h[G+48>>3]=m;H=(+h[s>>3]-+h[t>>3])*.125+o;h[G+56>>3]=H;h[G+64>>3]=m;m=(+h[s>>3]-+h[t>>3])*.125+H;h[G+72>>3]=m;h[G+80>>3]=I;h[G+88>>3]=m;I=+h[y>>3];I=(+h[b>>3]-I)*.5+I;h[G+96>>3]=I;h[G+104>>3]=H;J=I-(+h[k>>3]-+h[u>>3])*.125;h[G+112>>3]=J;h[G+120>>3]=m;J=J-(+h[k>>3]-+h[u>>3])*.125;h[G+128>>3]=J;h[G+136>>3]=m;h[G+144>>3]=J;h[G+152>>3]=H;H=(+h[k>>3]-+h[u>>3])*.125+J;h[G+160>>3]=H;h[G+168>>3]=o;h[G+176>>3]=J;h[G+184>>3]=F;h[G+192>>3]=J;J=+h[d>>3];h[G+200>>3]=J;h[G+208>>3]=H;h[G+216>>3]=J;d=G+224|0;h[d>>3]=I;h[G+232>>3]=+h[v>>3];h[G+240>>3]=+h[w>>3];h[G+248>>3]=J;HD(a,G,x,f);c[B>>2]=c[d>>2];c[B+4>>2]=c[d+4>>2];c[B+8>>2]=c[d+8>>2];c[B+12>>2]=c[d+12>>2];d=B+16|0;h[d>>3]=+h[B>>3];J=+h[z>>3];f=B+24|0;h[f>>3]=(+h[A>>3]-J)*.5+J;KD(a,B,2);h[B>>3]=+h[y>>3];J=+h[z>>3];h[B+8>>3]=(+h[A>>3]-J)*.5+J;h[d>>3]=+h[b>>3];h[f>>3]=(+h[b+8>>3]-+h[b+56>>3])*.5+J;KD(a,B,2);_I(G);break}else{switch(e|0){case 352321536:break;default:break a}A=d+4|0;G=vw(A<<4)|0;x=b+16|0;I=+h[x>>3];w=D+48|0;I=(+h[b>>3]-I)*.5+I+(+h[k>>3]-+h[w>>3])*.125;h[G>>3]=I;y=b+40|0;J=+h[y>>3];z=b+24|0;u=D+56|0;v=D+72|0;J=(+h[u>>3]-+h[v>>3]+(+h[z>>3]-J))*.5+J;d=G+8|0;h[d>>3]=J;o=(+h[k>>3]-+h[w>>3])*.125+I;h[G+16>>3]=o;H=(+h[u>>3]-+h[v>>3])*.125+J;h[G+24>>3]=H;h[G+32>>3]=o;o=(+h[u>>3]-+h[v>>3])*.25+H;h[G+40>>3]=o;h[G+48>>3]=I;F=(+h[u>>3]-+h[v>>3])*.125+o;h[G+56>>3]=F;I=I-(+h[k>>3]-+h[w>>3])*.25;h[G+64>>3]=I;h[G+72>>3]=F;F=I-(+h[k>>3]-+h[w>>3])*.125;h[G+80>>3]=F;h[G+88>>3]=o;h[G+96>>3]=F;h[G+104>>3]=H;h[G+112>>3]=I;h[G+120>>3]=J;HD(a,G,A,f);J=+h[x>>3];J=(+h[b>>3]-J)*.5+J;h[B>>3]=J;A=B+8|0;h[A>>3]=+h[d>>3];d=B+16|0;h[d>>3]=J;J=+h[y>>3];f=B+24|0;h[f>>3]=(+h[z>>3]-J)*.5+J;KD(a,B,2);h[B>>3]=+h[x>>3];J=+h[y>>3];h[A>>3]=(+h[z>>3]-J)*.5+J;h[d>>3]=+h[b>>3];h[f>>3]=(+h[b+8>>3]-+h[b+56>>3])*.5+J;KD(a,B,2);_I(G);break}}if((e|0)<402653184)if((e|0)<385875968){switch(e|0){case 369098752:break;default:break a}d=d+5|0;G=vw(d<<4)|0;B=D+48|0;h[G>>3]=+h[j>>3]-(+h[k>>3]-+h[B>>3])*.5;y=D+56|0;A=D+72|0;h[G+8>>3]=+h[D+24>>3]-(+h[y>>3]-+h[A>>3])*.5;h[G+16>>3]=+h[B>>3];J=+h[y>>3];h[G+24>>3]=J-(J-+h[A>>3])*.5;h[G+32>>3]=+h[b+32>>3];z=b+40|0;h[G+40>>3]=+h[z>>3];J=+h[k>>3];h[G+48>>3]=(J-+h[B>>3])*.5+J;h[G+56>>3]=+h[z>>3];J=+h[k>>3];h[G+64>>3]=(J-+h[B>>3])*.5+J;h[G+72>>3]=(+h[y>>3]-+h[A>>3])*.5+ +h[z>>3];h[G+80>>3]=+h[j>>3]-(+h[k>>3]-+h[B>>3])*.5;h[G+88>>3]=(+h[y>>3]-+h[A>>3])*.5+ +h[z>>3];h[G+96>>3]=+h[j>>3]-(+h[k>>3]-+h[B>>3])*.5;z=b+56|0;h[G+104>>3]=+h[z>>3];A=b+8|0;J=+h[A>>3];h[G+120>>3]=J-(J-+h[z>>3])*.5;h[G+112>>3]=+h[b>>3];h[G+136>>3]=+h[A>>3];h[G+128>>3]=+h[j>>3]-(+h[k>>3]-+h[B>>3])*.5;HD(a,G,d,f);_I(G);break}else{switch(e|0){case 385875968:break;default:break a}d=d+3|0;G=vw(d<<4)|0;B=D+48|0;h[G>>3]=+h[j>>3]-(+h[k>>3]-+h[B>>3])*.5;y=D+56|0;A=D+72|0;h[G+8>>3]=+h[D+24>>3]-(+h[y>>3]-+h[A>>3])*.5;h[G+16>>3]=+h[B>>3];J=+h[y>>3];h[G+24>>3]=J-(J-+h[A>>3])*.5;h[G+32>>3]=+h[b+32>>3];z=b+40|0;h[G+40>>3]=(+h[y>>3]-+h[A>>3])*.5+ +h[z>>3];h[G+48>>3]=+h[j>>3]-(+h[k>>3]-+h[B>>3])*.5;h[G+56>>3]=(+h[y>>3]-+h[A>>3])*.5+ +h[z>>3];h[G+64>>3]=+h[j>>3]-(+h[k>>3]-+h[B>>3])*.5;z=b+56|0;h[G+72>>3]=+h[z>>3];A=b+8|0;J=+h[A>>3];h[G+88>>3]=J-(J-+h[z>>3])*.5;h[G+80>>3]=+h[b>>3];h[G+104>>3]=+h[A>>3];h[G+96>>3]=+h[j>>3]-(+h[k>>3]-+h[B>>3])*.5;HD(a,G,d,f);_I(G);break}else if((e|0)<419430400){switch(e|0){case 402653184:break;default:break a}d=d+3|0;G=vw(d<<4)|0;h[G>>3]=+h[b>>3];y=b+8|0;z=D+48|0;A=D+56|0;B=D+72|0;h[G+8>>3]=+h[y>>3]-(+h[A>>3]-+h[B>>3])*.5;J=+h[k>>3];h[G+16>>3]=(J-+h[z>>3])*.5+J;h[G+24>>3]=+h[y>>3]-(+h[A>>3]-+h[B>>3])*.5;J=+h[k>>3];h[G+32>>3]=(J-+h[z>>3])*.5+J;h[G+40>>3]=+h[D+40>>3];h[G+48>>3]=+h[b+16>>3];J=+h[b+24>>3];y=b+40|0;h[G+56>>3]=J-(J-+h[y>>3])*.5;J=+h[k>>3];h[G+64>>3]=(J-+h[z>>3])*.5+J;h[G+72>>3]=+h[y>>3];h[G+88>>3]=(+h[A>>3]-+h[B>>3])*.5+ +h[y>>3];J=+h[k>>3];h[G+80>>3]=(J-+h[z>>3])*.5+J;h[G+104>>3]=(+h[A>>3]-+h[B>>3])*.5+ +h[b+56>>3];h[G+96>>3]=+h[b>>3];HD(a,G,d,f);_I(G);break}else{switch(e|0){case 419430400:break;default:break a}d=d+5|0;G=vw(d<<4)|0;h[G>>3]=+h[b>>3];B=b+8|0;A=D+48|0;y=D+56|0;z=D+72|0;h[G+8>>3]=+h[B>>3]-(+h[y>>3]-+h[z>>3])*.5;J=+h[k>>3];h[G+16>>3]=(J-+h[A>>3])*.5+J;h[G+24>>3]=+h[B>>3]-(+h[y>>3]-+h[z>>3])*.5;J=+h[k>>3];h[G+32>>3]=(J-+h[A>>3])*.5+J;h[G+40>>3]=+h[D+40>>3];h[G+48>>3]=+h[b+16>>3];J=+h[b+24>>3];B=b+40|0;h[G+56>>3]=J-(J-+h[B>>3])*.5;J=+h[k>>3];h[G+64>>3]=(J-+h[A>>3])*.5+J;h[G+72>>3]=+h[B>>3];h[G+88>>3]=(+h[y>>3]-+h[z>>3])*.5+ +h[B>>3];J=+h[k>>3];h[G+80>>3]=(J-+h[A>>3])*.5+J;B=b+56|0;h[G+104>>3]=(+h[y>>3]-+h[z>>3])*.5+ +h[B>>3];h[G+96>>3]=+h[j>>3]-(+h[k>>3]-+h[A>>3])*.5;h[G+112>>3]=+h[j>>3]-(+h[k>>3]-+h[A>>3])*.5;h[G+120>>3]=+h[B>>3];h[G+128>>3]=+h[b+48>>3];h[G+136>>3]=+h[B>>3];HD(a,G,d,f);_I(G);break}}while(0);_I(D)}l=E;return}function zy(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0.0;f=l;l=l+112|0;g=f;k=+h[b+8>>3]*2.0;c[g>>2]=c[b>>2];c[g+4>>2]=c[b+4>>2];c[g+8>>2]=c[b+8>>2];c[g+12>>2]=c[b+12>>2];h[g+16>>3]=+h[b+16>>3];h[g+24>>3]=k-+h[b+24>>3];h[g+32>>3]=+h[b+32>>3];h[g+40>>3]=k-+h[b+40>>3];h[g+48>>3]=+h[b+48>>3];h[g+56>>3]=k-+h[b+56>>3];h[g+64>>3]=+h[b+64>>3];h[g+72>>3]=k-+h[b+72>>3];h[g+80>>3]=+h[b+80>>3];h[g+88>>3]=k-+h[b+88>>3];i=g+96|0;j=b+96|0;c[i>>2]=c[j>>2];c[i+4>>2]=c[j+4>>2];c[i+8>>2]=c[j+8>>2];c[i+12>>2]=c[j+12>>2];JD(a,b,d,0,0,e&255);JD(a,g,7,0,0,0);l=f;return}function Ay(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;var e=0.0,f=0.0;f=+h[c>>3];e=+h[c+8>>3];e=(+h[d+8>>3]-e)*b+e;h[a>>3]=(+h[d>>3]-f)*b+f;h[a+8>>3]=e;return}function By(a){a=a|0;a=c[(c[a+16>>2]|0)+8>>2]|0;if(a){a=c[c[a+4>>2]>>2]|0;if((a|0)!=75)if((a|0)==78)a=2;else return ((a|0)==77?3:(a|0)==80?4:0)|0;else a=1}else a=0;return a|0}function Cy(b){b=b|0;var d=0,e=0,f=0.0,g=0,i=0,j=0,k=0.0,m=0.0,n=0.0,o=0.0,p=0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0,D=0,G=0,H=0,I=0,J=0,L=0,M=0,N=0,P=0.0,Q=0.0,R=0,S=0,T=0.0,U=0.0,V=0.0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0.0;aa=l;l=l+144|0;J=aa+112|0;N=aa+104|0;G=aa+96|0;H=aa+88|0;i=aa+80|0;Y=aa+64|0;_=aa+48|0;R=aa+40|0;S=aa+32|0;j=aa+24|0;p=aa+16|0;D=aa+136|0;A=aa+128|0;L=aa;$=vw(48)|0;Z=b+16|0;W=c[(c[(c[Z>>2]|0)+8>>2]|0)+8>>2]|0;g=(W|0)==1552;X=c[W>>2]|0;d=c[W+4>>2]|0;e=c[W+8>>2]|0;m=+h[W+16>>3];n=+h[W+32>>3];o=+h[W+24>>3];X=X|(IA(Im(b,90545)|0)|0)&255;do if(!g){if(!X){W=c[Z>>2]|0;k=+h[W+32>>3]*72.0;f=+h[W+40>>3]*72.0;f=+(~~(f+(f>=0.0?.5:-.5))|0);k=+(~~(k+(k>=0.0?.5:-.5))|0);break}k=+My(b);if(k>0.0)f=k;else{W=c[Z>>2]|0;f=+h[W+32>>3];k=+h[W+40>>3];k=(f=0.0?.5:-.5))|0);f=k}}else{f=0.0;k=0.0}while(0);W=DA(b,c[42204]|0,d,0)|0;V=+EA(b,c[42206]|0,0.0,-360.0)+m;if(!e){U=+EA(b,c[42207]|0,0.0,-100.0);I=DA(b,c[42203]|0,4,0)|0;T=+EA(b,c[42208]|0,0.0,-100.0)}else{I=e;U=n;T=o}d=c[(c[Z>>2]|0)+104>>2]|0;e=d+24|0;c[Y>>2]=c[e>>2];c[Y+4>>2]=c[e+4>>2];c[Y+8>>2]=c[e+8>>2];c[Y+12>>2]=c[e+12>>2];q=+h[Y>>3];if(q>0.0){if(!g)M=11}else if(!(g|!(+h[Y+8>>3]>0.0)))M=11;if((M|0)==11){d=Im(b,90530)|0;do if(d){h[p>>3]=0.0;h[j>>3]=0.0;c[i>>2]=j;c[i+4>>2]=p;d=cM(d,90537,i)|0;m=+h[j>>3];if(m<0.0){h[j>>3]=0.0;m=0.0}n=+h[p>>3];if(n<0.0){h[p>>3]=0.0;o=0.0}else o=n;if((d|0)<=0){n=q+16.0;h[Y>>3]=n;m=8.0;break}m=m*72.0;m=+(~~(m+(m>=0.0?.5:-.5))<<1|0);n=q+m;h[Y>>3]=n;if((d|0)!=1){m=o*72.0;m=+(~~(m+(m>=0.0?.5:-.5))<<1|0)}}else{n=q+16.0;h[Y>>3]=n;m=8.0}while(0);d=Y+8|0;h[d>>3]=+h[d>>3]+m;d=c[(c[Z>>2]|0)+104>>2]|0;q=n}s=+h[d+24>>3];m=+h[c[(c[(ro(b)|0)+16>>2]|0)+8>>2]>>3];if(m>0.0){P=m*72.0;P=+(~~(P+(P>=0.0?.5:-.5))|0);Q=+Ny(q,P);h[Y>>3]=Q;p=Y+8|0;h[p>>3]=+Ny(+h[p>>3],P)}else Q=q;d=c[(c[Z>>2]|0)+8>>2]|0;do if(!(a[d+12>>0]|0)){e=Im(b,93847)|0;if((e|0)!=0?(a[e>>0]|0)!=0:0){Pr(A,ro(b)|0,e);d=c[A>>2]|0;g=c[A+4>>2]|0;if((g&d|0)==-1){d=Dn(b)|0;c[G>>2]=e;c[G+4>>2]=d;_l(0,90621,G)|0;e=0;d=0;break}else{a[(c[(ro(b)|0)+16>>2]|0)+114>>0]=1;e=d+2|0;d=g+2|0;break}}else{e=0;d=0}}else{d=c[d>>2]|0;if((a[d>>0]|0)==99?(xJ(d,90553)|0)==0:0){e=Im(b,90560)|0;Pr(D,ro(b)|0,e);d=c[D>>2]|0;g=c[D+4>>2]|0;if((g&d|0)==-1){d=Dn(b)|0;c[H>>2]=e|0?e:90570;c[H+4>>2]=d;_l(0,90576,H)|0;e=0;d=0;break}else{a[(c[(ro(b)|0)+16>>2]|0)+114>>0]=1;e=d+2|0;d=g+2|0;break}}else{e=0;d=0}}while(0);P=+(e|0);h[_>>3]=Q>P?Q:P;P=+h[Y+8>>3];r=+(d|0);d=_+8|0;h[d>>3]=P>r?P:r;e=(I|0)<3&(T!=0.0|U!=0.0)?120:I;g=Im(b,90662)|0;if(!g)i=99;else{i=a[g>>0]|0;i=i<<24>>24==116?116:i<<24>>24==98?98:99}g=c[Z>>2]|0;a[(c[g+104>>2]|0)+80>>0]=i;if((e|0)==4?(T==0.0?((~~(V+(V>=0.0?.5:-.5))|0)%90|0|0)==0:0)&U==0.0:0)p=1;else M=39;do if((M|0)==39){g=c[(c[(c[g+8>>2]|0)+8>>2]|0)+44>>2]|0;if(g|0){p=c[g>>2]|0;c[J>>2]=c[_>>2];c[J+4>>2]=c[_+4>>2];c[J+8>>2]=c[_+8>>2];c[J+12>>2]=c[_+12>>2];hb[p&31](L,J);c[_>>2]=c[L>>2];c[_+4>>2]=c[L+4>>2];c[_+8>>2]=c[L+8>>2];c[_+12>>2]=c[L+12>>2];p=0;break}m=+h[d>>3];n=m*1.4142135623730951;if(f>n&i<<24>>24==99){o=m/f;o=+C(+(1.0/(1.0-o*o)));o=+h[_>>3]*o;h[_>>3]=o}else{o=+h[_>>3]*1.4142135623730951;h[_>>3]=o;h[d>>3]=n;m=n}if((e|0)>2){z=+E(+(3.141592653589793/+(e|0)));h[_>>3]=o/z;h[d>>3]=m/z;p=0}else p=0}while(0);m=+h[d>>3];g=FA(b,c[42209]|0,122100)|0;if((a[g>>0]|0)==115?(xJ(g,90671)|0)==0:0){h[_>>3]=k;h[d>>3]=f;N=$+40|0;c[N>>2]=c[N>>2]|2048}else{if(!((IA(g)|0)<<24>>24)){z=+h[_>>3];k=k>z?k:z;h[_>>3]=k;z=+h[d>>3];f=f>z?f:z}else{M=c[(c[Z>>2]|0)+104>>2]|0;if(!(!(k<+h[M+24>>3])?!(f<+h[M+32>>3]):0)){L=Dn(b)|0;M=Dn(ro(b)|0)|0;c[N>>2]=L;c[N+4>>2]=M;_l(0,90677,N)|0}h[_>>3]=k}h[d>>3]=f}if(!X){z=f;y=k}else{y=k>f?k:f;h[d>>3]=y;h[_>>3]=y;z=y}do if(!((IA(FA(b,c[42200]|0,122100)|0)|0)<<24>>24)){if(p){f=+h[(Q>+h[_>>3]?Y:_)>>3];break}f=+h[d>>3];if(P>3]*+C(+(1.0-P*P/(f*f)));f=Q>f?Q:f}else f=Q}else f=Q;while(0);g=c[(c[Z>>2]|0)+104>>2]|0;h[g+40>>3]=s-q+f;A=$+40|0;if(!(c[A>>2]&2048)){x=+h[d>>3]-m;h[g+48>>3]=(P1;g=j?W:1;a:do if((e|0)<3){g=vw(g<<5)|0;k=+h[_>>3]*.5;f=+h[d>>3]*.5;h[g>>3]=-k;h[g+8>>3]=-f;h[g+16>>3]=k;h[g+24>>3]=f;if(j){e=1;i=2;while(1){if((e|0)==(W|0))break;y=k+4.0;z=f+4.0;h[g+(i<<4)>>3]=-y;h[g+(i<<4)+8>>3]=-z;S=i|1;h[g+(S<<4)>>3]=y;h[g+(S<<4)+8>>3]=z;e=e+1|0;i=i+2|0;k=y;f=z}h[_>>3]=k*2.0;h[d>>3]=f*2.0;e=2}else e=2}else{g=vw(O(g<<4,e)|0)|0;i=c[(c[(c[(c[Z>>2]|0)+8>>2]|0)+8>>2]|0)+44>>2]|0;b:do if(!i){q=6.283185307179586/+(e|0);t=q*.5;r=+F(+t);s=+QJ(+B(+U)+ +B(+T),1.0);t=T*1.4142135623730951/+E(+t);u=U*.5;SJ((q+-3.141592653589793)*.5,R,S);v=V*.017453292519943295;k=0.0;f=0.0;m=0.0;i=0;n=+h[S>>3]*.5;o=+h[R>>3]*.5;while(1){if((i|0)>=(e|0))break b;m=m+q;SJ(m,R,S);n=+h[S>>3]*r+n;o=+h[R>>3]*r+o;x=(o*t+s)*n+u*o;SJ(+K(+o,+x)+v,R,S);x=+QJ(x,o);w=+h[S>>3]*x*+h[_>>3];x=+h[R>>3]*x*+h[d>>3];ba=+B(+w);f=ba>f?ba:f;ba=+B(+x);k=ba>k?ba:k;h[g+(i<<4)>>3]=w;h[g+(i<<4)+8>>3]=x;if(p)break;else i=i+1|0}ba=-w;h[g+16>>3]=ba;h[g+24>>3]=x;h[g+32>>3]=ba;ba=-x;h[g+40>>3]=ba;h[g+48>>3]=w;h[g+56>>3]=ba}else{hb[c[i+4>>2]&31](g,_);k=+h[d>>3]*.5;f=+h[_>>3]*.5}while(0);f=f*2.0;k=k*2.0;y=y>f?y:f;h[_>>3]=y;ba=z>k?z:k;h[d>>3]=ba;f=y/f;k=ba/k;i=0;while(1){if((i|0)>=(e|0))break;N=g+(i<<4)|0;b=g+(i<<4)+8|0;ba=+h[b>>3]*k;h[N>>3]=+h[N>>3]*f;h[b>>3]=ba;i=i+1|0}if(j){j=e+-1|0;k=+h[g>>3];m=+h[g+8>>3];f=+K(+(m-+h[g+(j<<4)+8>>3]),+(k-+h[g+(j<<4)>>3]));j=0;c:while(1){if((j|0)>=(e|0))break;p=j+1|0;i=(p|0)%(e|0)|0;n=+h[g+(i<<4)>>3];o=+h[g+(i<<4)+8>>3];q=+K(+(o-m),+(n-k));z=(f+3.141592653589793-q)*.5;ba=4.0/+F(+z);SJ(f-z,R,S);h[R>>3]=+h[R>>3]*ba;h[S>>3]=+h[S>>3]*ba;i=1;f=m;while(1){if((i|0)==(W|0)){f=q;j=p;k=n;m=o;continue c}z=+h[S>>3]+k;ba=+h[R>>3]+f;b=(O(i,e)|0)+j|0;h[g+(b<<4)>>3]=z;h[g+(b<<4)+8>>3]=ba;i=i+1|0;k=z;f=ba}}j=O(e,W+-1|0)|0;i=0;while(1){if((i|0)>=(e|0))break a;S=i+j|0;z=+h[g+(S<<4)+8>>3];y=+B(+(+h[g+(S<<4)>>3]))*2.0;ba=+h[_>>3];h[_>>3]=y>ba?y:ba;z=+B(+z)*2.0;ba=+h[d>>3];h[d>>3]=z>ba?z:ba;i=i+1|0}}}while(0);c[$>>2]=X;c[$+4>>2]=W;c[$+8>>2]=e;h[$+16>>3]=V;h[$+32>>3]=U;h[$+24>>3]=T;c[$+44>>2]=g;f=+h[_>>3];if(!(c[A>>2]&2048)){e=c[Z>>2]|0;h[e+32>>3]=f*.013888888888888888}else{e=c[Z>>2]|0;h[e+32>>3]=+h[(Q>f?Y:_)>>3]*.013888888888888888;d=(P>+h[d>>3]?Y:_)+8|0}h[e+40>>3]=+h[d>>3]*.013888888888888888;c[e+12>>2]=$;l=aa;return}function Dy(a){a=a|0;var b=0,d=0,e=0,f=0,g=0.0,i=0.0,j=0,k=0,m=0,n=0,o=0;o=l;l=l+64|0;j=o+40|0;e=o+32|0;k=o+16|0;n=o;d=(c[(c[(ro(a)|0)+16>>2]|0)+116>>2]|0)>>>2&1^1;m=a+16|0;f=c[c[(c[m>>2]|0)+104>>2]>>2]|0;c[42326]=f;f=rJ(f)|0;f=vw(((f|0)>1?f:1)+1|0)|0;b=Fy(a,d,1,f)|0;if(!b){c[e>>2]=c[c[(c[m>>2]|0)+104>>2]>>2];_l(1,90506,e)|0;c[42326]=90527;b=Fy(a,d,1,f)|0}_I(f);Gy(j,a,b);d=c[m>>2]|0;i=+h[d+32>>3]*72.0;i=+(~~(i+(i>=0.0?.5:-.5))|0);h[n>>3]=i;g=+h[d+40>>3]*72.0;g=+(~~(g+(g>=0.0?.5:-.5))|0);d=n+8|0;h[d>>3]=g;if(!((IA(FA(a,c[42209]|0,122100)|0)|0)<<24>>24)){i=+h[(+h[b>>3]>i?b:n)>>3];h[n>>3]=i;e=b+8|0;g=+h[(+h[e>>3]>g?b:n)+8>>3];h[d>>3]=g;d=e;e=b}else{d=b+8|0;e=b}a=(IA(FA(a,c[42200]|0,122100)|0)|0)&255;c[j>>2]=c[n>>2];c[j+4>>2]=c[n+4>>2];c[j+8>>2]=c[n+8>>2];c[j+12>>2]=c[n+12>>2];Hy(b,j,a);Iy(k,i*-.5,g*.5);c[j>>2]=c[k>>2];c[j+4>>2]=c[k+4>>2];c[j+8>>2]=c[k+8>>2];c[j+12>>2]=c[k+12>>2];Jy(b,j,15);n=c[m>>2]|0;h[n+32>>3]=+h[e>>3]*.013888888888888888;h[n+40>>3]=(+h[d>>3]+1.0)*.013888888888888888;c[n+12>>2]=b;l=o;return}function Ey(a){a=a|0;var b=0.0,d=0,e=0.0,f=0.0,g=0,i=0,j=0,k=0,l=0.0,m=0;j=vw(48)|0;k=a+16|0;g=c[(c[(c[(c[k>>2]|0)+8>>2]|0)+8>>2]|0)+4>>2]|0;f=+EA(a,c[42190]|0,1797693134862315708145274.0e284,0.0);b=+EA(a,c[42189]|0,1797693134862315708145274.0e284,0.0);f=f0.0?(f>.0003?f:.0003):f;i=c[k>>2]|0;h[i+40>>3]=f;h[i+32>>3]=f;b=f*72.0;g=DA(a,c[42204]|0,g,0)|0;i=vw((g|0)<1?32:g<<5)|0;f=f*36.0;e=-f;h[i>>3]=e;h[i+8>>3]=e;h[i+16>>3]=f;h[i+24>>3]=f;if((g|0)>1){a=1;d=2;e=f;b=f;while(1){if((a|0)==(g|0))break;l=e+4.0;f=b+4.0;h[i+(d<<4)>>3]=-l;h[i+(d<<4)+8>>3]=-f;m=d|1;h[i+(m<<4)>>3]=l;h[i+(m<<4)+8>>3]=f;a=a+1|0;d=d+2|0;e=l;b=f}b=e*2.0}c[j>>2]=1;c[j+4>>2]=g;c[j+8>>2]=2;m=j+16|0;c[m>>2]=0;c[m+4>>2]=0;c[m+8>>2]=0;c[m+12>>2]=0;c[m+16>>2]=0;c[m+20>>2]=0;c[j+44>>2]=i;l=b*.013888888888888888;m=c[k>>2]|0;h[m+32>>3]=l;h[m+40>>3]=l;c[m+12>>2]=j;return}function Fy(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;g=vw(72)|0;n=c[(c[b+16>>2]|0)+104>>2]|0;m=0;i=1;j=c[42326]|0;a:while(1){k=a[j>>0]|0;switch(k<<24>>24){case 0:break a;case 92:{j=j+1|0;k=a[j>>0]|0;switch(k<<24>>24){case 124:case 125:case 123:case 92:{l=m;break}default:E=4}break}default:E=4}if((E|0)==4){E=0;switch(k<<24>>24){case 123:{l=m+1|0;break}case 125:{l=m+-1|0;break}default:{l=m;i=i+((m|0)==0&k<<24>>24==124&1)|0}}if((l|0)<0)break}m=l;j=j+1|0}B=g+56|0;c[B>>2]=vw(i<<2)|0;a[g+64>>0]=d;y=(d|0)==0&1;z=n+82|0;A=f+1|0;v=(e|0)!=0;w=n+16|0;x=n+4|0;u=n+8|0;k=0;m=0;d=0;t=0;l=0;e=0;n=f;i=0;j=0;b:while(1){p=k;k=0;c:while(1){d:while(1){s=e;e:while(1){r=k;o=i;f:while(1){q=m;g:while(1){while(1){if(t){E=78;break b}m=c[42326]|0;i=a[m>>0]|0;if((i+-1&255)>=31)break;c[42326]=m+1}switch(i<<24>>24|0){case 92:{E=53;break d}case 0:case 124:case 125:break e;case 60:break f;case 62:break g;case 123:break;default:{k=d;i=m;break d}}i=m+1|0;c[42326]=i;if(l|0){E=34;break b}if(!(a[i>>0]|0)){E=34;break b}e=Fy(b,y,0,f)|0;c[(c[B>>2]|0)+(q<<2)>>2]=e;if(!e){E=36;break b}else{q=q+1|0;l=4}}if(a[z>>0]|0){k=d;i=m;break d}if(!(l&16)){E=27;break b}if(o>>>0>A>>>0?(C=o+-1|0,(C|0)!=(s|0)):0)i=(a[C>>0]|0)==32?C:o;else i=o;a[i>>0]=0;r=GL(f)|0;c[42326]=(c[42326]|0)+1;m=q;l=l&-17;o=i}if(l&6|0){E=22;break b}if(a[z>>0]|0){k=d;i=m;break d}c[42326]=m+1;m=q;l=l|18;k=r;s=f;i=f}if(!((l&16|0)==0&(v|i<<24>>24!=0))){E=38;break b}if(!(l&4)){k=vw(72)|0;c[(c[B>>2]|0)+(q<<2)>>2]=k;m=q+1|0}else{k=p;m=q}if(r|0)c[k+60>>2]=r;if(!(l&5)){a[f+j>>0]=32;l=l|1;j=j+1|0}i=f+j|0;if(l&1){if((j|0)>1?(D=i+-1|0,(D|0)!=(n|0)):0)i=(a[D>>0]|0)==32?D:i;a[i>>0]=0;n=GL(f)|0;c[k+52>>2]=lw(b,n,a[z>>0]|0?2:0,+h[w>>3],c[x>>2]|0,c[u>>2]|0)|0;a[k+64>>0]=1;n=f;j=0}i=c[42326]|0;switch(a[i>>0]|0){case 0:{t=1;e=s;i=o;continue b}case 125:{E=51;break b}default:{}}c[42326]=i+1;p=k;l=0;k=0;e=s;i=o}h:do if((E|0)==53){E=0;k=f+j|0;i=m+1|0;switch(a[i>>0]|0){case 0:{k=d;i=m;break h}case 62:case 60:case 124:case 125:case 123:{k=d;break}case 32:{if(!(a[z>>0]|0))k=1;else E=55;break}default:E=55}if((E|0)==55){E=0;a[k>>0]=92;k=d;l=l|9;j=j+1|0}c[42326]=i}while(0);d=f+j|0;if(l&4|0?(a[i>>0]|0)!=32:0){E=59;break b}if(!(l&24))l=(a[i>>0]|0)==32?l:l|9;if(!(l&8))if(!(l&16))e=s;else{m=a[i>>0]|0;d=(k|0)!=0;if(!(d|m<<24>>24!=32))if((o|0)!=(f|0))if((a[o+-1>>0]|0)==32)m=o;else E=73;else m=f;else E=73;if((E|0)==73){E=0;a[o>>0]=m;m=o+1|0;i=c[42326]|0}e=d?m+-1|0:s;o=m}else{m=a[i>>0]|0;e=(k|0)!=0;if(!((!(e|m<<24>>24!=32)?(a[d+-1>>0]|0)==32:0)?(a[z>>0]|0)==0:0)){a[d>>0]=m;j=j+1|0}if(e){e=s;n=f+j+-1|0}else e=s}i=i+1|0;c[42326]=i;while(1){if((a[i>>0]|0)>=0){m=q;d=k;k=r;i=o;continue c}s=i+1|0;c[42326]=s;a[f+j>>0]=a[i>>0]|0;j=j+1|0;i=s}}}if((E|0)==22){Ky(g,r);g=0}else if((E|0)==27){Ky(g,r);g=0}else if((E|0)==34){Ky(g,r);g=0}else if((E|0)==36){Ky(g,r);g=0}else if((E|0)==38){Ky(g,r);g=0}else if((E|0)==51){c[42326]=i+1;c[g+48>>2]=m}else if((E|0)==59){Ky(g,r);g=0}else if((E|0)==78)c[g+48>>2]=q;return g|0}function Gy(b,d,e){b=b|0;d=d|0;e=e|0;var f=0.0,g=0.0,i=0.0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;u=l;l=l+64|0;k=u+48|0;m=u+40|0;n=u+32|0;t=u+16|0;s=u;j=c[e+52>>2]|0;a:do if(!j){n=t+8|0;o=e+48|0;p=e+56|0;q=e+64|0;r=s+8|0;c[t>>2]=0;c[t+4>>2]=0;c[t+8>>2]=0;c[t+12>>2]=0;j=0;while(1){if((j|0)>=(c[o>>2]|0))break a;Gy(s,d,c[(c[p>>2]|0)+(j<<2)>>2]|0);if(!(a[q>>0]|0)){h[n>>3]=+h[n>>3]+ +h[r>>3];k=t;m=+h[t>>3]>+h[s>>3]?t:s}else{h[t>>3]=+h[t>>3]+ +h[s>>3];k=n;m=(+h[n>>3]>+h[r>>3]?t:s)+8|0}h[k>>3]=+h[m>>3];j=j+1|0}}else{g=+h[j+24>>3];f=+h[j+32>>3];if(g>0.0|f>0.0){j=Im(d,90530)|0;do if(j){c[k>>2]=m;c[k+4>>2]=n;j=cM(j,90537,k)|0;if((j|0)<=0){i=8.0;g=g+16.0;break}i=+h[m>>3]*72.0;i=+(~~(i+(i>=0.0?.5:-.5))<<1|0);g=g+i;if((j|0)!=1){i=+h[n>>3]*72.0;i=+(~~(i+(i>=0.0?.5:-.5))<<1|0)}}else{i=8.0;g=g+16.0}while(0);f=i+f}h[t>>3]=g;h[t+8>>3]=f}while(0);c[e>>2]=c[t>>2];c[e+4>>2]=c[t+4>>2];c[e+8>>2]=c[t+8>>2];c[e+12>>2]=c[t+12>>2];c[b>>2]=c[t>>2];c[b+4>>2]=c[t+4>>2];c[b+8>>2]=c[t+8>>2];c[b+12>>2]=c[t+12>>2];l=u;return}function Hy(b,d,e){b=b|0;d=d|0;e=e|0;var f=0.0,g=0,i=0.0,j=0,k=0,m=0,n=0,o=0,p=0,q=0.0,r=0.0,s=0;s=l;l=l+32|0;o=s+16|0;p=s;q=+h[d>>3];i=q-+h[b>>3];r=+h[d+8>>3];f=r-+h[b+8>>3];c[b>>2]=c[d>>2];c[b+4>>2]=c[d+4>>2];c[b+8>>2]=c[d+8>>2];c[b+12>>2]=c[d+12>>2];d=c[b+52>>2]|0;if(!((e|0)!=0|(d|0)==0)){n=d+40|0;h[n>>3]=+h[n>>3]+i;n=d+48|0;h[n>>3]=+h[n>>3]+f}m=b+48|0;d=c[m>>2]|0;a:do if(d|0){n=b+64|0;f=((a[n>>0]|0)==0?f:i)/+(d|0);k=b+56|0;j=0;while(1){if((j|0)>=(d|0))break a;b=c[(c[k>>2]|0)+(j<<2)>>2]|0;g=j+1|0;d=~~(f*+(g|0))-~~(f*+(j|0))|0;if(!(a[n>>0]|0))Iy(p,q,+h[b+8>>3]+ +(d|0));else Iy(p,+h[b>>3]+ +(d|0),r);c[o>>2]=c[p>>2];c[o+4>>2]=c[p+4>>2];c[o+8>>2]=c[p+8>>2];c[o+12>>2]=c[p+12>>2];Hy(b,o,e);j=g;d=c[m>>2]|0}}while(0);l=s;return}function Iy(a,b,c){a=a|0;b=+b;c=+c;h[a>>3]=b;h[a+8>>3]=c;return}function Jy(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0.0,s=0.0;q=l;l=l+48|0;j=q+32|0;n=q+16|0;m=q;a[b+65>>0]=e;k=b+16|0;s=+h[d>>3];p=d+8|0;r=+h[p>>3];Iy(n,s,r-+h[b+8>>3]);c[k>>2]=c[n>>2];c[k+4>>2]=c[n+4>>2];c[k+8>>2]=c[n+8>>2];c[k+12>>2]=c[n+12>>2];k=b+32|0;Iy(m,+h[b>>3]+s,r);c[k>>2]=c[m>>2];c[k+4>>2]=c[m+4>>2];c[k+8>>2]=c[m+8>>2];c[k+12>>2]=c[m+12>>2];k=c[b+48>>2]|0;m=k+-1|0;n=(e|0)==0;o=b+56|0;i=b+64|0;g=0;while(1){if((g|0)>=(k|0))break;do if(!n){b=(g|0)==0;f=(g|0)==(m|0);if(!(a[i>>0]|0))if(b){b=f?15:14;break}else{b=f?11:10;break}else if(b){b=f?15:13;break}else{b=f?7:5;break}}else b=0;while(0);f=c[(c[o>>2]|0)+(g<<2)>>2]|0;c[j>>2]=c[d>>2];c[j+4>>2]=c[d+4>>2];c[j+8>>2]=c[d+8>>2];c[j+12>>2]=c[d+12>>2];Jy(f,j,b&e);if(!(a[i>>0]|0))h[p>>3]=+h[p>>3]-+h[(c[(c[o>>2]|0)+(g<<2)>>2]|0)+8>>3];else h[d>>3]=+h[c[(c[o>>2]|0)+(g<<2)>>2]>>3]+ +h[d>>3];g=g+1|0}l=q;return}function Ky(a,b){a=a|0;b=b|0;Ly(a);_I(b);return}function Ly(a){a=a|0;var b=0,d=0,e=0;d=a+48|0;e=a+56|0;b=0;while(1){if((b|0)>=(c[d>>2]|0))break;Ly(c[(c[e>>2]|0)+(b<<2)>>2]|0);b=b+1|0}_I(c[a+60>>2]|0);ow(c[a+52>>2]|0);_I(c[e>>2]|0);_I(a);return}function My(a){a=a|0;var b=0.0,d=0.0;d=+EA(a,c[42190]|0,0.0,.01);b=+EA(a,c[42189]|0,0.0,.02);b=(d>b?d:b)*72.0;return +(+(~~(b+(b>=0.0?.5:-.5))|0))}function Ny(a,b){a=+a;b=+b;var c=0;c=~~(a/b);return +(+((+(c|0)*b+1.0e-05>2]|0)+8>>2]|0;if(!a)a=0;else a=(c[c[a+4>>2]>>2]|0)==75&1;return a|0}function Py(b){b=b|0;var d=0,e=0,f=0,g=0,h=0;f=c[42327]|0;a:do if(!f)d=0;else{g=c[42328]|0;e=0;while(1){if((e|0)>=(g|0)){d=0;break a}d=c[f+(e<<2)>>2]|0;h=c[d>>2]|0;if((a[h>>0]|0)==(a[b>>0]|0)?(xJ(h,b)|0)==0:0)break a;e=e+1|0}}while(0);return d|0}function Qy(b,d){b=b|0;d=d|0;var e=0,f=0,g=0;if(RA(Im(d,90560)|0)|0)if((a[b>>0]|0)==101?(xJ(b,90725)|0)==0:0){d=101;g=6}else{b=90553;g=4}else g=4;if((g|0)==4){d=a[b>>0]|0;if(d<<24>>24==99)if(!(xJ(b,90553)|0))g=11;else{d=99;g=6}else g=6}a:do if((g|0)==6){e=19868;while(1){f=c[e>>2]|0;if(!f){g=11;break a}if((a[f>>0]|0)==d<<24>>24?(xJ(f,b)|0)==0:0){b=e;break a}e=e+16|0}}while(0);if((g|0)==11)b=Ry(b)|0;return b|0}function Ry(b){b=b|0;var d=0,e=0,f=0,g=0,h=0;h=l;l=l+16|0;g=h;d=Py(b)|0;if(!d){f=c[42328]|0;d=f+1|0;c[42328]=d;e=c[42327]|0;if(!e)d=ww(d<<2)|0;else d=yw(e,d<<2)|0;c[42327]=d;d=vw(16)|0;c[(c[42327]|0)+(f<<2)>>2]=d;c[d>>2]=c[4967];c[d+4>>2]=c[4968];c[d+8>>2]=c[4969];c[d+12>>2]=c[4970];e=GL(b)|0;c[d>>2]=e;do if(!0){if((a[b>>0]|0)==99?(xJ(b,90553)|0)==0:0){e=1;break}c[g>>2]=c[4967];c[g+4>>2]=e;_l(0,90730,g)|0;e=0}else e=1;while(0);a[d+12>>0]=e}l=h;return d|0}function Sy(a,b){a=a|0;b=b|0;var c=0.0,d=0.0;d=+h[b>>3]*.5257311121191336;c=+h[b+8>>3]*.8944271909999159;c=d>c?d:c;h[a>>3]=c*4.97979656976556;h[a+8>>3]=c*4.73606797749979;return}function Ty(a,b){a=a|0;b=b|0;var c=0.0,d=0.0,e=0.0,f=0,g=0.0,i=0.0,j=0.0,k=0,l=0,m=0.0;d=+h[b>>3];k=b+8|0;e=+h[k>>3];c=e/d;if(!(c>.9510565162951536))if(c<.9510565162951536){j=d;e=d*.9510565162951536}else j=d;else j=e*1.0514622242382672;d=j*.5257311121191336;g=j*.20081141588622725;i=j*.05020285397155681;c=.3141592653589793;f=0;while(1){if((f|0)>=10)break;h[a+(f<<4)>>3]=+E(+c)*d;h[a+(f<<4)+8>>3]=+F(+c)*d-i;m=c+.6283185307179586;l=f|1;h[a+(l<<4)>>3]=+E(+m)*g;h[a+(l<<4)+8>>3]=+F(+m)*g-i;c=c+1.2566370614359172;f=f+2|0}h[b>>3]=j;h[k>>3]=e;return}function Uy(a){a=a|0;a=c[(c[a+16>>2]|0)+12>>2]|0;if(a|0){_I(c[a+44>>2]|0);_I(a)}return}function Vy(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0;o=l;l=l+80|0;k=o+40|0;g=o;n=o+64|0;h=o+56|0;if(!(a[e>>0]|0)){g=4144;h=b+40|0;do{c[b>>2]=c[g>>2];b=b+4|0;g=g+4|0}while((b|0)<(h|0))}else{i=(f|0)==0?91400:f;c[n>>2]=15;j=d+16|0;f=c[j>>2]|0;do if(a[(c[f+104>>2]|0)+82>>0]|0){f=HF(d,e,n)|0;if(!f){f=c[j>>2]|0;m=8;break}if(hz(d,f,g,i,c[n>>2]|0,0)|0){c[k>>2]=Dn(d)|0;c[k+4>>2]=e;c[k+8>>2]=i;_l(0,91402,k)|0}}else m=8;while(0);if((m|0)==8){if((c[(c[f+8>>2]|0)+8>>2]|0)==1600)h=0;else{c[h>>2]=d;c[h+4>>2]=0}if(hz(d,0,g,e,c[n>>2]|0,h)|0)iz(d,e)}c[g+36>>2]=0;h=b+40|0;do{c[b>>2]=c[g>>2];b=b+4|0;g=g+4|0}while((b|0)<(h|0))}l=o;return}function Wy(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0,g=0,i=0,j=0.0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0.0,t=0;r=l;l=l+112|0;n=r+96|0;m=r+80|0;p=r+64|0;k=r+48|0;q=r+32|0;o=r;f=r+16|0;if(!a){c[42331]=0;a=0}else{g=c[a+4>>2]|0;a=c[a>>2]|0;i=(c[(c[(ro(a)|0)+16>>2]|0)+116>>2]&3)*90|0;c[n>>2]=c[b>>2];c[n+4>>2]=c[b+4>>2];c[n+8>>2]=c[b+8>>2];c[n+12>>2]=c[b+12>>2];aw(f,n,i);c[q>>2]=c[f>>2];c[q+4>>2]=c[f+4>>2];c[q+8>>2]=c[f+8>>2];c[q+12>>2]=c[f+12>>2];a:do if(g){d=+h[g+8>>3];e=+h[g+24>>3];s=+h[q>>3];if((+h[g>>3]<=s?s<=+h[g+16>>3]:0)?(j=+h[q+8>>3],d<=j):0)a=j<=e&1;else a=0}else{if((a|0)==(c[42331]|0)){f=c[42332]|0;g=c[42334]|0;i=c[42333]|0}else{g=c[(c[a+16>>2]|0)+12>>2]|0;c[42335]=g;i=c[g+44>>2]|0;c[42333]=i;f=c[g+8>>2]|0;c[42332]=f;g=O((c[g+4>>2]|0)+-1|0,f)|0;g=(g|0)>0?g:0;c[42334]=g;c[42331]=a}a=0;b=0;while(1){if((a|0)>=(f|0)){a=1;break a}t=i+(g+a<<4)|0;c[o>>2]=c[t>>2];c[o+4>>2]=c[t+4>>2];c[o+8>>2]=c[t+8>>2];c[o+12>>2]=c[t+12>>2];t=i+(g+((a+4|0)%(f|0)|0)<<4)|0;c[k>>2]=c[q>>2];c[k+4>>2]=c[q+4>>2];c[k+8>>2]=c[q+8>>2];c[k+12>>2]=c[q+12>>2];c[p>>2]=c[41802];c[p+4>>2]=c[41803];c[p+8>>2]=c[41804];c[p+12>>2]=c[41805];c[m>>2]=c[o>>2];c[m+4>>2]=c[o+4>>2];c[m+8>>2]=c[o+8>>2];c[m+12>>2]=c[o+12>>2];c[n>>2]=c[t>>2];c[n+4>>2]=c[t+4>>2];c[n+8>>2]=c[t+8>>2];c[n+12>>2]=c[t+12>>2];b=b+((gz(k,p,m,n)|0)==0&1)|0;if((b|0)==2){a=0;break}else a=a+2|0}}while(0)}l=r;return a|0}function Xy(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;e=c[b+16>>2]|0;if((a[(c[e+104>>2]|0)+82>>0]|0)!=0?(a[e+145>>0]|0)!=0:0)b=KF(b,d,0,f,g)|0;else b=0;return b|0}function Yy(e,f){e=e|0;f=f|0;var i=0,j=0,k=0.0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0.0,C=0.0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,P=0,Q=0,R=0;P=l;l=l+48|0;H=P+24|0;G=P+16|0;A=P+8|0;z=P;L=P+32|0;n=P+28|0;M=c[e+16>>2]|0;N=M+208|0;i=c[N>>2]|0;if((i|0)==0?(b[M+260>>1]&1)==0:0)J=0;else E=4;if((E|0)==4)if(!(c[e+152>>2]&4)){wD(e,i,c[M+228>>2]|0,c[M+244>>2]|0,c[M+212>>2]|0);J=1}else J=1;I=f+16|0;i=c[I>>2]|0;r=c[i+12>>2]|0;F=c[r+44>>2]|0;K=c[r+8>>2]|0;r=c[r+4>>2]|0;if((c[42329]|0)<(K|0)){i=K+5|0;c[42329]=i;j=c[42330]|0;if(!j)i=ww(i<<4)|0;else i=yw(j,i<<4)|0;c[42330]=i;i=c[I>>2]|0}D=(c[i+104>>2]|0)+56|0;i=i+16|0;c[D>>2]=c[i>>2];c[D+4>>2]=c[i+4>>2];c[D+8>>2]=c[i+8>>2];c[D+12>>2]=c[i+12>>2];D=c[I>>2]|0;B=+h[D+32>>3]*72.0;B=(+h[D+96>>3]+ +h[D+88>>3])/+(~~(B+(B>=0.0?.5:-.5))|0);C=+h[D+40>>3]*72.0;C=+h[D+80>>3]/+(~~(C+(C>=0.0?.5:-.5))|0);D=Zy(e,f)|0;c[L>>2]=0;i=d[(c[I>>2]|0)+117>>0]|0;do if(!(i&1)){if(i&2|0){s=GA(f,0,91300)|0;BD(e,s);DD(e,GA(f,0,91308)|0);j=0;i=1;break}if(i&8|0){s=GA(f,0,91316)|0;BD(e,s);DD(e,GA(f,0,91324)|0);j=0;i=1;break}if(i&4|0){s=GA(f,0,91332)|0;BD(e,s);DD(e,GA(f,0,91340)|0);j=0;i=1;break}if(!(D&1))if(!(D&576)){j=0;i=0}else{j=_y(f)|0;i=1}else{j=_y(f)|0;if(!((xv(j,L,n)|0)<<24>>24)){DD(e,j);i=1}else{DD(e,c[L>>2]|0);i=c[L+4>>2]|0;m=DA(f,c[42217]|0,0,0)|0;k=+g[n>>2];if(!i)ED(e,122106,m,k);else ED(e,i,m,k);i=(D&2)>>>1|2}}s=$y(e,f)|0}else{s=GA(f,0,91284)|0;BD(e,s);DD(e,GA(f,0,91292)|0);j=0;i=1}while(0);m=c[(c[I>>2]|0)+8>>2]|0;if(a[m+12>>0]|0){m=c[m>>2]|0;if((a[m>>0]|0)==99){m=(xJ(m,90553)|0)==0;E=33}else u=1}else{m=1;E=33}if((E|0)==33){m=m^1;if((r|0)!=0|i<<24>>24==0|m)u=m;else{BD(e,122171);r=1;u=0}}v=(K|0)<3;w=(D&512|0)!=0;y=(D&8|0)==0;x=(D&64|0)==0;p=(D&1024|0)==0;q=(D&2130706444|0)==0;t=0;while(1){if((t|0)>=(r|0))break;n=O(t,K)|0;o=c[42330]|0;m=0;while(1){if((m|0)>=(K|0))break;R=m+n|0;k=+h[F+(R<<4)+8>>3];Q=c[I>>2]|0;h[o+(m<<4)>>3]=+h[Q+16>>3]+ +h[F+(R<<4)>>3]*B;h[o+(m<<4)+8>>3]=+h[Q+24>>3]+k*C;m=m+1|0}do if(v){if(w&(t|0)==0?(WJ(j,58)|0)!=0:0)if((_t(e,o,j)|0)>1){c[z>>2]=Dn(f)|0;_l(3,91348,z)|0;i=0}else i=0;GD(e,c[42330]|0,K,i&255);if(!y)az(e,f)}else{if(!x){if((t|0)==0?(cu(e,o,j,1)|0)>1:0){c[A>>2]=Dn(f)|0;_l(3,91348,A)|0}HD(e,c[42330]|0,K,0);break}if(!p){BD(e,122171);HD(e,c[42330]|0,K,i&255);BD(e,s);KD(e,(c[42330]|0)+32|0,2);break}i=i&255;if(q){HD(e,o,K,i);break}else{yy(e,o,K,D,i);break}}while(0);t=t+1|0;i=0}m=c[(c[I>>2]|0)+8>>2]|0;if(!(a[m+12>>0]|0)){m=Im(f,93847)|0;if(m|0?a[m>>0]|0:0){o=m;E=65}}else{m=c[m>>2]|0;if((a[m>>0]|0)==99?(xJ(m,90553)|0)==0:0){m=Im(f,90560)|0;if(m|0?a[m>>0]|0:0){o=m;E=65}}else{o=m;E=65}}if((E|0)==65){n=c[42330]|0;m=0;while(1){if((m|0)>=(K|0))break;k=+h[F+(m<<4)+8>>3];R=c[I>>2]|0;h[n+(m<<4)>>3]=+h[R+16>>3]+ +h[F+(m<<4)>>3]*B;h[n+(m<<4)+8>>3]=+h[R+24>>3]+k*C;m=m+1|0}m=i&255;do if(!(u|i<<24>>24==0)){if(v){if(w&(t|0)==0?(WJ(j,58)|0)!=0:0)if((_t(e,n,j)|0)>1){c[G>>2]=Dn(f)|0;_l(3,91348,G)|0;i=0}else i=0;GD(e,c[42330]|0,K,i&255);if(y)break;az(e,f);break}if(x)if(!(D&12)){HD(e,n,K,m);break}else{yy(e,n,K,D,m);break}else{if((cu(e,n,j,1)|0)>1){c[H>>2]=Dn(f)|0;_l(3,91348,H)|0}HD(e,c[42330]|0,K,0);break}}while(0);R=c[42330]|0;MD(e,o,R,K,i,FA(f,c[42210]|0,122100)|0)}_I(c[L>>2]|0);pw(e,10,c[(c[I>>2]|0)+104>>2]|0);if(J){if(c[e+152>>2]&4|0)wD(e,c[N>>2]|0,c[M+228>>2]|0,c[M+244>>2]|0,c[M+212>>2]|0);xD(e)}l=P;return}function Zy(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0;h=l;l=l+16|0;f=h;e=dz(d,f)|0;if(e|0)FD(b,e);e=c[42216]|0;if((e|0?(g=Jm(d,e)|0,g|0):0)?a[g>>0]|0:0)OD(b,+EA(d,c[42216]|0,1.0,0.0));l=h;return c[f>>2]|0}function _y(a){a=a|0;return cz(a,119592)|0}function $y(b,d){b=b|0;d=d|0;d=GA(d,c[42192]|0,174181)|0;d=a[d>>0]|0?d:122106;BD(b,d);return d|0}function az(a,b){a=a|0;b=b|0;var d=0,e=0,f=0.0,g=0,i=0.0,j=0,k=0,m=0;d=l;l=l+96|0;j=d+80|0;k=d+64|0;e=d+32|0;m=d+16|0;g=d;b=c[b+16>>2]|0;f=+h[b+80>>3];h[m+8>>3]=f*.375;i=+h[b+96>>3];h[m>>3]=i*.6614;b=b+16|0;c[k>>2]=c[m>>2];c[k+4>>2]=c[m+4>>2];c[k+8>>2]=c[m+8>>2];c[k+12>>2]=c[m+12>>2];c[j>>2]=c[b>>2];c[j+4>>2]=c[b+4>>2];c[j+8>>2]=c[b+8>>2];c[j+12>>2]=c[b+12>>2];bz(g,k,j);c[e>>2]=c[g>>2];c[e+4>>2]=c[g+4>>2];c[e+8>>2]=c[g+8>>2];c[e+12>>2]=c[g+12>>2];g=e+8|0;b=e+24|0;h[b>>3]=+h[g>>3];h[e+16>>3]=+h[e>>3]-i*1.3228;KD(a,e,2);f=+h[g>>3]-f*.75;h[g>>3]=f;h[b>>3]=f;KD(a,e,2);l=d;return}function bz(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0;d=+h[c+8>>3]+ +h[b+8>>3];h[a>>3]=+h[c>>3]+ +h[b>>3];h[a+8>>3]=d;return}function cz(b,d){b=b|0;d=d|0;var e=0;e=GA(b,c[42193]|0,174181)|0;if(!(a[e>>0]|0)){e=GA(b,c[42192]|0,174181)|0;return ((a[e>>0]|0)==0?d:e)|0}else return e|0;return 0}function dz(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;e=GA(b,c[42201]|0,174181)|0;a:do if(!(a[e>>0]|0)){g=0;e=0}else{g=Du(e)|0;h=g;e=0;b:while(1){f=c[h>>2]|0;if(!f)break a;switch(a[f>>0]|0){case 102:{if(!(xJ(f,95923)|0)){h=h+4|0;e=e|1;continue b}break}case 114:{if(!(xJ(f,91360)|0)){f=h;do{j=f;f=f+4|0;i=c[f>>2]|0;c[j>>2]=i}while((i|0)!=0);j=h;e=e|4;h=j;continue b}if(!(xJ(f,91378)|0)){f=h;do{i=f;f=f+4|0;j=c[f>>2]|0;c[i>>2]=j}while((j|0)!=0);j=h;e=e|3;h=j;continue b}break}case 100:{if(!(xJ(f,91368)|0)){f=h;do{i=f;f=f+4|0;j=c[f>>2]|0;c[i>>2]=j}while((j|0)!=0);j=h;e=e|8;h=j;continue b}break}case 105:{if(!(xJ(f,119127)|0)){h=h+4|0;e=e|32;continue b}break}case 115:{if((xJ(f,91385)|0)==0?ez(b)|0:0){f=h;do{i=f;f=f+4|0;j=c[f>>2]|0;c[i>>2]=j}while((j|0)!=0);j=h;e=e|64;h=j;continue b}break}case 119:{if((xJ(f,91393)|0)==0?fz(b)|0:0){f=h;do{i=f;f=f+4|0;j=c[f>>2]|0;c[i>>2]=j}while((j|0)!=0);j=h;e=e|512;h=j;continue b}break}default:{}}h=h+4|0}}while(0);f=c[(c[(c[b+16>>2]|0)+8>>2]|0)+8>>2]|0;if(f)e=c[f+40>>2]|e;c[d>>2]=e;return g|0}function ez(a){a=a|0;var b=0.0;a=c[(c[(c[a+16>>2]|0)+8>>2]|0)+8>>2]|0;if((((a|0)!=0?(c[a+8>>2]|0)==4:0)?(b=+h[a+16>>3],((~~(b+(b>=0.0?.5:-.5))|0)%90|0|0)==0):0)?+h[a+24>>3]==0.0:0)a=+h[a+32>>3]==0.0&1;else a=0;return a|0}function fz(a){a=a|0;a=c[(c[(c[a+16>>2]|0)+8>>2]|0)+8>>2]|0;if(!a)a=0;else a=(c[a+8>>2]|0)<3&1;return a|0}function gz(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0.0,f=0.0,g=0.0,i=0.0;i=+h[c+8>>3];g=-(+h[d+8>>3]-i);f=+h[c>>3];e=+h[d>>3]-f;f=e*i+f*g;return (+h[a+8>>3]*e+ +h[a>>3]*g-f>=0.0^+h[b>>3]*g-f+ +h[b+8>>3]*e>=0.0^1)&1|0}function hz(b,d,e,f,g,i){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;i=i|0;var j=0.0,k=0.0,m=0,n=0,o=0,p=0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;G=l;l=l+192|0;B=G+176|0;E=G+160|0;m=G+144|0;z=G+128|0;A=G+112|0;n=G+96|0;o=G+80|0;p=G+64|0;v=G+48|0;w=G+32|0;x=G+16|0;D=G;if(!d){c[E>>2]=0;c[E+4>>2]=0;c[E+8>>2]=0;c[E+12>>2]=0;m=(c[(c[(ro(b)|0)+16>>2]|0)+116>>2]&1|0)==0;C=c[b+16>>2]|0;q=+h[C+80>>3]*.5;j=+h[C+88>>3];t=m?q:j;q=m?j:q;m=0;C=E;j=0.0;k=-q;r=t;F=E+8|0;s=0.0;t=-t}else{k=+h[d>>3];t=+h[d+8>>3];q=+h[d+16>>3];r=+h[d+24>>3];Iy(m,(q+k)*.5,(r+t)*.5);c[E>>2]=c[m>>2];c[E+4>>2]=c[m+4>>2];c[E+8>>2]=c[m+8>>2];c[E+12>>2]=c[m+12>>2];H=E+8|0;m=1;C=E;j=+h[E>>3];F=H;s=+h[H>>3]}u=(q>r?q:r)*4.0;a:do if((f|0)!=0?(y=a[f>>0]|0,y<<24>>24!=0):0){f=f+1|0;switch(y<<24>>24|0){case 99:{p=1;g=0;f=0;n=0;j=0.0;o=0;break a}case 101:{if(a[f>>0]|0){p=1;g=0;f=0;n=0;j=0.0;o=1;break a}if(!i)h[C>>3]=q;else{jz(z,i,s,u);c[E>>2]=c[z>>2];c[E+4>>2]=c[z+4>>2];c[E+8>>2]=c[z+8>>2];c[E+12>>2]=c[z+12>>2]}p=0;g=g&2;f=0;n=1;j=0.0;o=0;m=1;break a}case 115:{h[F>>3]=t;switch(a[f>>0]|0){case 0:{if(!i)h[C>>3]=j;else{jz(A,i,-u,j);c[E>>2]=c[A>>2];c[E+4>>2]=c[A+4>>2];c[E+8>>2]=c[A+8>>2];c[E+12>>2]=c[A+12>>2]}p=0;g=g&1;f=0;n=1;j=-1.5707963267948966;o=0;m=1;break a}case 101:{if(!i)h[C>>3]=q;else{jz(n,i,-u,u);c[E>>2]=c[n>>2];c[E+4>>2]=c[n+4>>2];c[E+8>>2]=c[n+8>>2];c[E+12>>2]=c[n+12>>2]}p=0;g=g&3;f=0;n=1;j=-.7853981633974483;o=0;m=1;break a}case 119:{if(!i)h[C>>3]=k;else{u=-u;jz(o,i,u,u);c[E>>2]=c[o>>2];c[E+4>>2]=c[o+4>>2];c[E+8>>2]=c[o+8>>2];c[E+12>>2]=c[o+12>>2]}p=0;g=g&9;f=0;n=1;j=-2.356194490192345;o=0;m=1;break a}default:{h[F>>3]=s;p=1;g=0;f=0;n=0;j=0.0;o=1;break a}}}case 119:{if(a[f>>0]|0){p=1;g=0;f=0;n=0;j=0.0;o=1;break a}if(!i)h[C>>3]=k;else{jz(p,i,s,-u);c[E>>2]=c[p>>2];c[E+4>>2]=c[p+4>>2];c[E+8>>2]=c[p+8>>2];c[E+12>>2]=c[p+12>>2]}p=0;g=g&8;f=0;n=1;j=3.141592653589793;o=0;m=1;break a}case 110:{h[F>>3]=r;switch(a[f>>0]|0){case 0:{if(!i)h[C>>3]=j;else{jz(v,i,u,j);c[E>>2]=c[v>>2];c[E+4>>2]=c[v+4>>2];c[E+8>>2]=c[v+8>>2];c[E+12>>2]=c[v+12>>2]}p=0;g=g&4;f=0;n=1;j=1.5707963267948966;o=0;m=1;break a}case 101:{if(!i)h[C>>3]=q;else{jz(w,i,u,u);c[E>>2]=c[w>>2];c[E+4>>2]=c[w+4>>2];c[E+8>>2]=c[w+8>>2];c[E+12>>2]=c[w+12>>2]}p=0;g=g&6;f=0;n=1;j=.7853981633974483;o=0;m=1;break a}case 119:{if(!i)h[C>>3]=k;else{jz(x,i,u,-u);c[E>>2]=c[x>>2];c[E+4>>2]=c[x+4>>2];c[E+8>>2]=c[x+8>>2];c[E+12>>2]=c[x+12>>2]}p=0;g=g&12;f=0;n=1;j=2.356194490192345;o=0;m=1;break a}default:{h[F>>3]=s;p=1;g=0;f=0;n=0;j=0.0;o=1;break a}}}case 95:{p=1;f=1;n=0;j=0.0;o=0;break a}default:{p=1;g=0;f=0;n=0;j=0.0;o=1;break a}}}else{p=1;g=0;f=0;n=0;j=0.0;o=0}while(0);H=(c[(c[(ro(b)|0)+16>>2]|0)+116>>2]&3)*90|0;c[B>>2]=c[E>>2];c[B+4>>2]=c[E+4>>2];c[B+8>>2]=c[E+8>>2];c[B+12>>2]=c[E+12>>2];$v(D,B,H);c[E>>2]=c[D>>2];c[E+4>>2]=c[D+4>>2];c[E+8>>2]=c[D+8>>2];c[E+12>>2]=c[D+12>>2];if(!(f<<24>>24))g=kz(g,c[(c[(ro(b)|0)+16>>2]|0)+116>>2]&3)|0;a[e+33>>0]=g;c[e+24>>2]=d;k=+h[C>>3];h[e>>3]=+(~~(k+(k>=0.0?.5:-.5))|0);k=+h[F>>3];h[e+8>>3]=+(~~(k+(k>=0.0?.5:-.5))|0);h[e+16>>3]=+lz(j,c[(c[(ro(b)|0)+16>>2]|0)+116>>2]&3);k=+h[C>>3];j=+h[F>>3];if(k==0.0&j==0.0)g=-128;else{u=+K(+j,+k);t=u+4.71238898038469;g=~~((!(t>=6.283185307179586)?t:u+-1.5707963267948966)*40.74366543152521)&255}a[e+32>>0]=g;a[e+29>>0]=n;a[e+28>>0]=m;a[e+30>>0]=p;a[e+31>>0]=f;l=G;return o|0}function iz(a,b){a=a|0;b=b|0;var d=0,e=0;d=l;l=l+16|0;e=d;c[e>>2]=Dn(a)|0;c[e+4>>2]=b;_l(0,91463,e)|0;l=d;return}function jz(a,b,d,e){a=a|0;b=b|0;d=+d;e=+e;var f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0;p=l;l=l+128|0;g=p+112|0;j=p+48|0;k=p+16|0;m=p+32|0;n=p;o=c[b>>2]|0;i=c[(c[(ro(o)|0)+16>>2]|0)+116>>2]&3;h[k>>3]=e;h[k+8>>3]=d;f=(i|0)!=0;if(f){c[g>>2]=c[k>>2];c[g+4>>2]=c[k+4>>2];c[g+8>>2]=c[k+8>>2];c[g+12>>2]=c[k+12>>2];$v(m,g,i*90|0);c[k>>2]=c[m>>2];c[k+4>>2]=c[m+4>>2];c[k+8>>2]=c[m+8>>2];c[k+12>>2]=c[m+12>>2]}m=j+48|0;q=j+32|0;c[j>>2]=0;c[j+4>>2]=0;c[j+8>>2]=0;c[j+12>>2]=0;c[j+16>>2]=0;c[j+20>>2]=0;c[j+24>>2]=0;c[j+28>>2]=0;c[q>>2]=c[k>>2];c[q+4>>2]=c[k+4>>2];c[q+8>>2]=c[k+8>>2];c[q+12>>2]=c[k+12>>2];c[m>>2]=c[k>>2];c[m+4>>2]=c[k+4>>2];c[m+8>>2]=c[k+8>>2];c[m+12>>2]=c[k+12>>2];Fz(b,c[(c[(c[(c[o+16>>2]|0)+8>>2]|0)+4>>2]|0)+12>>2]|0,j,1);if(f){c[g>>2]=c[j>>2];c[g+4>>2]=c[j+4>>2];c[g+8>>2]=c[j+8>>2];c[g+12>>2]=c[j+12>>2];aw(n,g,i*90|0);c[j>>2]=c[n>>2];c[j+4>>2]=c[n+4>>2];c[j+8>>2]=c[n+8>>2];c[j+12>>2]=c[n+12>>2]};c[a>>2]=c[j>>2];c[a+4>>2]=c[j+4>>2];c[a+8>>2]=c[j+8>>2];c[a+12>>2]=c[j+12>>2];l=p;return}function kz(a,b){a=a|0;b=b|0;a:do switch(b|0){case 3:switch(a|0){case 4:{a=2;break a}case 1:{a=8;break a}case 8:{a=1;break a}case 2:{a=4;break a}default:break a}case 2:switch(a|0){case 4:{a=1;break a}case 1:{a=4;break a}default:break a}case 1:switch(a|0){case 4:{a=2;break a}case 1:{a=8;break a}case 8:{a=4;break a}case 2:{a=1;break a}default:break a}default:{}}while(0);return a|0}function lz(a,b){a=+a;b=b|0;switch(b|0){case 3:{if(!(a==3.141592653589793))if(!(a==2.356194490192345))if(!(a==1.5707963267948966))if(!(a==0.0))if(!(a==-.7853981633974483)){if(a==-1.5707963267948966)a=3.141592653589793}else a=2.356194490192345;else a=1.5707963267948966;else a=0.0;else a=-.7853981633974483;else a=-1.5707963267948966;break}case 2:{a=-a;break}case 1:{a=a+-1.5707963267948966;break}default:{}}return +a}function mz(a,b){a=a|0;b=b|0;var d=0.0,e=0,f=0.0,g=0.0,i=0,j=0,k=0;e=l;l=l+32|0;k=e+16|0;i=e;a=c[a>>2]|0;j=(c[(c[(ro(a)|0)+16>>2]|0)+116>>2]&3)*90|0;c[k>>2]=c[b>>2];c[k+4>>2]=c[b+4>>2];c[k+8>>2]=c[b+8>>2];c[k+12>>2]=c[b+12>>2];aw(i,k,j);d=+h[i>>3];g=+h[i+8>>3];a=c[a+16>>2]|0;f=+h[a+80>>3]*.5;if(!(!(g>=-f)|!(g<=f))?d>=-+h[a+88>>3]:0)a=d<=+h[a+96>>3]&1;else a=0;l=e;return a|0}function nz(a,d){a=a|0;d=d|0;var e=0,f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0.0;n=l;l=l+32|0;m=n;i=c[a+16>>2]|0;j=i+208|0;g=c[j>>2]|0;if(!g)k=(b[i+260>>1]&1)!=0;else k=1;e=d+16|0;d=c[e>>2]|0;f=c[d+12>>2]|0;if(f|0){if(k?(c[a+152>>2]&4|0)==0:0){wD(a,g,c[i+228>>2]|0,c[i+244>>2]|0,c[i+212>>2]|0);d=c[e>>2]|0}g=c[a+36>>2]|0;p=+h[d+24>>3]+ +(c[f+8>>2]|0);o=c[f>>2]|0;h[m>>3]=+h[d+16>>3]+ +(c[f+4>>2]|0);h[m+8>>3]=p;c[m+16>>2]=o;zL(g,91494,m)|0;g=c[e>>2]|0;m=(c[g+104>>2]|0)+56|0;g=g+16|0;c[m>>2]=c[g>>2];c[m+4>>2]=c[g+4>>2];c[m+8>>2]=c[g+8>>2];c[m+12>>2]=c[g+12>>2];pw(a,10,c[(c[e>>2]|0)+104>>2]|0);if(k){if(c[a+152>>2]&4|0)wD(a,c[j>>2]|0,c[i+228>>2]|0,c[i+244>>2]|0,c[i+212>>2]|0);xD(a)}}l=n;return}function oz(a){a=a|0;Ly(c[(c[a+16>>2]|0)+12>>2]|0);return}function pz(b,e,f,g){b=b|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,m=0;m=l;l=l+64|0;k=m+40|0;h=m;if(!(a[f>>0]|0)){h=4144;g=b+40|0;do{c[b>>2]=c[h>>2];b=b+4|0;h=h+4|0}while((b|0)<(g|0))}else{g=(g|0)==0?91400:g;i=c[(c[e+16>>2]|0)+12>>2]|0;j=vz(i,f)|0;if(!j){if(hz(e,i+16|0,h,f,15,0)|0)iz(e,f)}else if(hz(e,j+16|0,h,g,d[j+65>>0]|0,0)|0){c[k>>2]=Dn(e)|0;c[k+4>>2]=f;c[k+8>>2]=g;_l(0,91402,k)|0}g=b+40|0;do{c[b>>2]=c[h>>2];b=b+4|0;h=h+4|0}while((b|0)<(g|0))}l=m;return}function qz(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0,g=0,i=0,j=0.0,k=0,m=0,n=0.0;k=l;l=l+32|0;m=k+16|0;i=k;f=c[a+4>>2]|0;a=c[a>>2]|0;g=(c[(c[(ro(a)|0)+16>>2]|0)+116>>2]&3)*90|0;c[m>>2]=c[b>>2];c[m+4>>2]=c[b+4>>2];c[m+8>>2]=c[b+8>>2];c[m+12>>2]=c[b+12>>2];aw(i,m,g);c[b>>2]=c[i>>2];c[b+4>>2]=c[i+4>>2];c[b+8>>2]=c[i+8>>2];c[b+12>>2]=c[i+12>>2];if(!f){f=c[(c[a+16>>2]|0)+12>>2]|0;g=f+16|0;a=f+24|0;i=f+32|0;f=f+40|0}else{g=f;a=f+8|0;i=f+16|0;f=f+24|0}e=+h[a>>3];d=+h[f>>3];n=+h[b>>3];if((+h[g>>3]<=n?n<=+h[i>>3]:0)?(j=+h[b+8>>3],e<=j):0)a=j<=d&1;else a=0;l=k;return a|0}function rz(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var i=0.0,j=0.0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0.0,t=0,u=0,v=0.0;u=l;l=l+80|0;r=u+64|0;q=u+32|0;t=u;a:do if(!(a[d+28>>0]|0))e=0;else{i=+h[d>>3];p=b+16|0;m=c[(c[p>>2]|0)+12>>2]|0;k=m+48|0;m=m+56|0;d=0;while(1){if((d|0)>=(c[k>>2]|0))break a;n=(c[(c[(ro(b)|0)+16>>2]|0)+116>>2]&1|0)==0;o=c[(c[m>>2]|0)+(d<<2)>>2]|0;j=+(~~+h[(n?o+16|0:o+24|0)>>3]|0);if(i>=j?(s=+(~~+h[(n?o+32|0:o+40|0)>>3]|0),i<=s):0)break;d=d+1|0}if(!(c[(c[(ro(b)|0)+16>>2]|0)+116>>2]&1)){t=c[p>>2]|0;v=+h[t+16>>3];h[f>>3]=v+j;j=+h[t+24>>3];i=+h[t+80>>3];h[f+8>>3]=j-i*.5;h[f+16>>3]=v+s}else{o=(c[(c[m>>2]|0)+(d<<2)>>2]|0)+16|0;b=(c[p>>2]|0)+16|0;c[q>>2]=c[o>>2];c[q+4>>2]=c[o+4>>2];c[q+8>>2]=c[o+8>>2];c[q+12>>2]=c[o+12>>2];c[q+16>>2]=c[o+16>>2];c[q+20>>2]=c[o+20>>2];c[q+24>>2]=c[o+24>>2];c[q+28>>2]=c[o+28>>2];c[r>>2]=c[b>>2];c[r+4>>2]=c[b+4>>2];c[r+8>>2]=c[b+8>>2];c[r+12>>2]=c[b+12>>2];bw(t,q,r);c[f>>2]=c[t>>2];c[f+4>>2]=c[t+4>>2];c[f+8>>2]=c[t+8>>2];c[f+12>>2]=c[t+12>>2];c[f+16>>2]=c[t+16>>2];c[f+20>>2]=c[t+20>>2];c[f+24>>2]=c[t+24>>2];c[f+28>>2]=c[t+28>>2];t=c[p>>2]|0;i=+h[t+80>>3];j=+h[t+24>>3]}h[f+24>>3]=i*.5+j;c[g>>2]=1}while(0);l=u;return e|0}function sz(d,e){d=d|0;e=e|0;var f=0,i=0,j=0,k=0.0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0.0;w=l;l=l+144|0;n=w+96|0;p=w+64|0;r=w;s=w+128|0;t=c[d+16>>2]|0;u=t+208|0;f=c[u>>2]|0;if(!f)v=(b[t+260>>1]&1)!=0;else v=1;m=e+16|0;q=c[m>>2]|0;o=c[q+12>>2]|0;j=o+16|0;c[p>>2]=c[j>>2];c[p+4>>2]=c[j+4>>2];c[p+8>>2]=c[j+8>>2];c[p+12>>2]=c[j+12>>2];c[p+16>>2]=c[j+16>>2];c[p+20>>2]=c[j+20>>2];c[p+24>>2]=c[j+24>>2];c[p+28>>2]=c[j+28>>2];x=+h[q+16>>3];h[p>>3]=+h[p>>3]+x;k=+h[q+24>>3];q=p+8|0;h[q>>3]=+h[q>>3]+k;q=p+16|0;h[q>>3]=+h[q>>3]+x;j=p+24|0;h[j>>3]=+h[j>>3]+k;if(v?(c[d+152>>2]&4|0)==0:0)wD(d,f,c[t+228>>2]|0,c[t+244>>2]|0,c[t+212>>2]|0);f=Zy(d,e)|0;$y(d,e)|0;c[s>>2]=0;if(!(f&1))i=0;else{i=_y(e)|0;if(!((xv(i,s,n)|0)<<24>>24)){DD(d,i);i=1}else{DD(d,c[s>>2]|0);i=c[s+4>>2]|0;j=DA(e,c[42217]|0,0,0)|0;k=+g[n>>2];if(!i)ED(d,122106,j,k);else ED(d,i,j,k);i=f>>>1&1|2}}j=c[c[(c[m>>2]|0)+8>>2]>>2]|0;if((a[j>>0]|0)==77){m=(xJ(j,91271)|0)==0;f=m?f|4:f}if(!(f&2130706444)){c[n>>2]=c[p>>2];c[n+4>>2]=c[p+4>>2];c[n+8>>2]=c[p+8>>2];c[n+12>>2]=c[p+12>>2];c[n+16>>2]=c[p+16>>2];c[n+20>>2]=c[p+20>>2];c[n+24>>2]=c[p+24>>2];c[n+28>>2]=c[p+28>>2];ID(d,n,i)}else{c[r>>2]=c[p>>2];c[r+4>>2]=c[p+4>>2];c[r+8>>2]=c[p+8>>2];c[r+12>>2]=c[p+12>>2];p=r+32|0;c[p>>2]=c[q>>2];c[p+4>>2]=c[q+4>>2];c[p+8>>2]=c[q+8>>2];c[p+12>>2]=c[q+12>>2];h[r+16>>3]=+h[p>>3];h[r+24>>3]=+h[r+8>>3];h[r+48>>3]=+h[r>>3];h[r+56>>3]=+h[r+40>>3];yy(d,r,4,f,i)}tz(d,e,o);_I(c[s>>2]|0);if(v){if(c[d+152>>2]&4|0)wD(d,c[u>>2]|0,c[t+228>>2]|0,c[t+244>>2]|0,c[t+212>>2]|0);xD(d)}l=w;return}function tz(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;u=l;l=l+144|0;p=u+128|0;o=u+112|0;q=u+16|0;r=u;g=u+96|0;i=u+80|0;s=u+64|0;t=u+48|0;j=e+52|0;f=c[j>>2]|0;if(!f)f=d+16|0;else{n=f+56|0;m=e+16|0;f=e+32|0;c[o>>2]=c[m>>2];c[o+4>>2]=c[m+4>>2];c[o+8>>2]=c[m+8>>2];c[o+12>>2]=c[m+12>>2];c[p>>2]=c[f>>2];c[p+4>>2]=c[f+4>>2];c[p+8>>2]=c[f+8>>2];c[p+12>>2]=c[f+12>>2];uz(g,o,p);f=d+16|0;m=(c[f>>2]|0)+16|0;c[o>>2]=c[g>>2];c[o+4>>2]=c[g+4>>2];c[o+8>>2]=c[g+8>>2];c[o+12>>2]=c[g+12>>2];c[p>>2]=c[m>>2];c[p+4>>2]=c[m+4>>2];c[p+8>>2]=c[m+8>>2];c[p+12>>2]=c[m+12>>2];bz(i,o,p);c[n>>2]=c[i>>2];c[n+4>>2]=c[i+4>>2];c[n+8>>2]=c[i+8>>2];c[n+12>>2]=c[i+12>>2];pw(b,10,c[j>>2]|0);$y(b,d)|0}k=(c[f>>2]|0)+16|0;c[r>>2]=c[k>>2];c[r+4>>2]=c[k+4>>2];c[r+8>>2]=c[k+8>>2];c[r+12>>2]=c[k+12>>2];k=e+48|0;m=e+64|0;n=q+16|0;j=e+56|0;e=q+16|0;i=0;while(1){if((i|0)>=(c[k>>2]|0))break;if((i|0)>0){f=(c[j>>2]|0)+(i<<2)|0;g=c[f>>2]|0;if(!(a[m>>0]|0)){g=g+32|0;c[n>>2]=c[g>>2];c[n+4>>2]=c[g+4>>2];c[n+8>>2]=c[g+8>>2];c[n+12>>2]=c[g+12>>2];h[q>>3]=+h[(c[f>>2]|0)+16>>3];f=n;g=0}else{g=g+16|0;c[q>>2]=c[g>>2];c[q+4>>2]=c[g+4>>2];c[q+8>>2]=c[g+8>>2];c[q+12>>2]=c[g+12>>2];h[e>>3]=+h[q>>3];f=(c[f>>2]|0)+32|0;g=1}h[q+(g<<4)+8>>3]=+h[f+8>>3];c[o>>2]=c[q>>2];c[o+4>>2]=c[q+4>>2];c[o+8>>2]=c[q+8>>2];c[o+12>>2]=c[q+12>>2];c[p>>2]=c[r>>2];c[p+4>>2]=c[r+4>>2];c[p+8>>2]=c[r+8>>2];c[p+12>>2]=c[r+12>>2];bz(s,o,p);c[q>>2]=c[s>>2];c[q+4>>2]=c[s+4>>2];c[q+8>>2]=c[s+8>>2];c[q+12>>2]=c[s+12>>2];c[o>>2]=c[n>>2];c[o+4>>2]=c[n+4>>2];c[o+8>>2]=c[n+8>>2];c[o+12>>2]=c[n+12>>2];c[p>>2]=c[r>>2];c[p+4>>2]=c[r+4>>2];c[p+8>>2]=c[r+8>>2];c[p+12>>2]=c[r+12>>2];bz(t,o,p);c[n>>2]=c[t>>2];c[n+4>>2]=c[t+4>>2];c[n+8>>2]=c[t+8>>2];c[n+12>>2]=c[t+12>>2];KD(b,q,2)}tz(b,d,c[(c[j>>2]|0)+(i<<2)>>2]|0);i=i+1|0}l=u;return}function uz(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0;d=(+h[c+8>>3]+ +h[b+8>>3])*.5;h[a>>3]=(+h[c>>3]+ +h[b>>3])*.5;h[a+8>>3]=d;return}function vz(b,d){b=b|0;d=d|0;var e=0,f=0,g=0;e=c[b+60>>2]|0;if(!(((e|0)!=0?(a[e>>0]|0)==(a[d>>0]|0):0)?(xJ(e,d)|0)==0:0))f=4;a:do if((f|0)==4){g=b+56|0;f=c[b+48>>2]|0;e=0;while(1){if((e|0)>=(f|0)){b=0;break a}b=vz(c[(c[g>>2]|0)+(e<<2)>>2]|0,d)|0;if(!b)e=e+1|0;else break}}while(0);return b|0}function wz(a,b){a=a|0;b=b|0;var d=0;d=b+8|0;h[d>>3]=+h[d>>3]*1.375;c[a>>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];c[a+12>>2]=c[b+12>>2];return}function xz(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,g=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0;k=+h[b>>3];f=k*.5;m=+h[b+8>>3];i=m*.5;h[a>>3]=f;e=m*.40909090909090906;h[a+8>>3]=e;h[a+16>>3]=f;g=m*.4592530909090909;h[a+24>>3]=g;j=k*.275892;h[a+32>>3]=j;h[a+40>>3]=i;h[a+48>>3]=0.0;h[a+56>>3]=i;k=k*-.275892;h[a+64>>3]=k;h[a+72>>3]=i;l=-f;h[a+80>>3]=l;h[a+88>>3]=g;d=a+96|0;h[d>>3]=l;h[a+104>>3]=e;b=a+112|0;c[b>>2]=c[d>>2];c[b+4>>2]=c[d+4>>2];c[b+8>>2]=c[d+8>>2];c[b+12>>2]=c[d+12>>2];b=a+128|0;h[b>>3]=l;h[a+136>>3]=m*-.40909090909090906;d=a+144|0;c[d>>2]=c[b>>2];c[d+4>>2]=c[b+4>>2];c[d+8>>2]=c[b+8>>2];c[d+12>>2]=c[b+12>>2];h[a+160>>3]=l;g=-g;h[a+168>>3]=g;h[a+176>>3]=k;i=-i;h[a+184>>3]=i;h[a+192>>3]=0.0;h[a+200>>3]=i;h[a+208>>3]=j;h[a+216>>3]=i;h[a+224>>3]=f;h[a+232>>3]=g;d=a+240|0;h[d>>3]=f;h[a+248>>3]=-e;b=a+256|0;c[b>>2]=c[d>>2];c[b+4>>2]=c[d+4>>2];c[b+8>>2]=c[d+8>>2];c[b+12>>2]=c[d+12>>2];b=a+288|0;d=a+272|0;c[d>>2]=c[a>>2];c[d+4>>2]=c[a+4>>2];c[d+8>>2]=c[a+8>>2];c[d+12>>2]=c[a+12>>2];c[b>>2]=c[a>>2];c[b+4>>2]=c[a+4>>2];c[b+8>>2]=c[a+8>>2];c[b+12>>2]=c[a+12>>2];return}function yz(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,g=0,i=0.0,j=0,k=0,m=0,n=0,o=0,p=0.0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0;x=l;l=l+144|0;u=x+112|0;t=x+96|0;v=x+80|0;s=x+64|0;w=x+32|0;q=x+16|0;r=x;g=x+48|0;do if(a){j=c[a+4>>2]|0;k=c[a>>2]|0;o=(c[(c[(ro(k)|0)+16>>2]|0)+116>>2]&3)*90|0;c[u>>2]=c[b>>2];c[u+4>>2]=c[b+4>>2];c[u+8>>2]=c[b+8>>2];c[u+12>>2]=c[b+12>>2];aw(g,u,o);c[w>>2]=c[g>>2];c[w+4>>2]=c[g+4>>2];c[w+8>>2]=c[g+8>>2];c[w+12>>2]=c[g+12>>2];if(j|0){d=+h[w>>3];if(!(+h[j>>3]<=d)){a=0;break}if(!(d<=+h[j+16>>3])){a=0;break}d=+h[w+8>>3];if(!(+h[j+8>>3]<=d)){a=0;break}a=d<=+h[j+24>>3];break}if((k|0)==(c[42336]|0)){d=+h[20903];e=+h[20904];i=+h[20905]}else{a=k+16|0;b=c[(c[a>>2]|0)+12>>2]|0;c[42337]=b;c[42338]=c[b+44>>2];c[42339]=c[b+8>>2];if(!(c[b+40>>2]&2048)){n=(c[(c[(ro(k)|0)+16>>2]|0)+116>>2]&1|0)==0;o=c[a>>2]|0;h[(n?167248:167256)>>3]=+h[o+96>>3]+ +h[o+88>>3];h[(n?167256:167248)>>3]=+h[o+80>>3];i=+h[o+32>>3]*72.0;f=+h[o+40>>3]*72.0;f=+(~~(f+(f>=0.0?.5:-.5))|0);i=+(~~(i+(i>=0.0?.5:-.5))|0)}else{aB(u,b);i=+h[u+16>>3]-+h[u>>3];f=+h[u+24>>3]-+h[u+8>>3];o=(c[(c[(ro(k)|0)+16>>2]|0)+116>>2]&1|0)==0;h[(o?167248:167256)>>3]=i;h[(o?167256:167248)>>3]=f}d=+h[20906];if(d==0.0){h[20906]=1.0;d=1.0}e=+h[20907];if(e==0.0){h[20907]=1.0;e=1.0}d=i/d;h[20903]=d;e=f/e;h[20904]=e;i=i*.5;h[20905]=i;h[20908]=f*.5;o=O((c[(c[42337]|0)+4>>2]|0)+-1|0,c[42339]|0)|0;c[42340]=(o|0)>0?o:0;c[42336]=k}f=+h[w>>3]*d;h[w>>3]=f;o=w+8|0;d=+h[o>>3]*e;h[o>>3]=d;if(!(+B(+f)>i)?(e=+B(+d),p=+h[20908],!(e>p)):0){o=c[42339]|0;if((o|0)<3){a=+QJ(f/i,d/p)<1.0;break}b=(c[42341]|0)%(o|0)|0;a=(b+1|0)%(o|0)|0;k=c[42338]|0;m=c[42340]|0;n=k+(m+b<<4)|0;c[q>>2]=c[n>>2];c[q+4>>2]=c[n+4>>2];c[q+8>>2]=c[n+8>>2];c[q+12>>2]=c[n+12>>2];n=k+(m+a<<4)|0;c[r>>2]=c[n>>2];c[r+4>>2]=c[n+4>>2];c[r+8>>2]=c[n+8>>2];c[r+12>>2]=c[n+12>>2];c[s>>2]=c[w>>2];c[s+4>>2]=c[w+4>>2];c[s+8>>2]=c[w+8>>2];c[s+12>>2]=c[w+12>>2];c[v>>2]=c[41818];c[v+4>>2]=c[41819];c[v+8>>2]=c[41820];c[v+12>>2]=c[41821];c[t>>2]=c[q>>2];c[t+4>>2]=c[q+4>>2];c[t+8>>2]=c[q+8>>2];c[t+12>>2]=c[q+12>>2];c[u>>2]=c[n>>2];c[u+4>>2]=c[n+4>>2];c[u+8>>2]=c[n+8>>2];c[u+12>>2]=c[n+12>>2];if(gz(s,v,t,u)|0){c[s>>2]=c[w>>2];c[s+4>>2]=c[w+4>>2];c[s+8>>2]=c[w+8>>2];c[s+12>>2]=c[w+12>>2];c[v>>2]=c[q>>2];c[v+4>>2]=c[q+4>>2];c[v+8>>2]=c[q+8>>2];c[v+12>>2]=c[q+12>>2];c[t>>2]=c[r>>2];c[t+4>>2]=c[r+4>>2];c[t+8>>2]=c[r+8>>2];c[t+12>>2]=c[r+12>>2];c[u>>2]=c[41818];c[u+4>>2]=c[41819];c[u+8>>2]=c[41820];c[u+12>>2]=c[41821];n=(gz(s,v,t,u)|0)!=0;if(n?(c[s>>2]=c[w>>2],c[s+4>>2]=c[w+4>>2],c[s+8>>2]=c[w+8>>2],c[s+12>>2]=c[w+12>>2],c[v>>2]=c[r>>2],c[v+4>>2]=c[r+4>>2],c[v+8>>2]=c[r+8>>2],c[v+12>>2]=c[r+12>>2],c[t>>2]=c[41818],c[t+4>>2]=c[41819],c[t+8>>2]=c[41820],c[t+12>>2]=c[41821],c[u>>2]=c[q>>2],c[u+4>>2]=c[q+4>>2],c[u+8>>2]=c[q+8>>2],c[u+12>>2]=c[q+12>>2],(gz(s,v,t,u)|0)!=0):0){a=1;break}else{j=b;b=1}while(1){if((b|0)>=(o|0)){b=31;break}if(n){g=a;a=(a+1|0)%(o|0)|0}else{g=(j+-1+o|0)%(o|0)|0;a=j}q=k+(m+g<<4)|0;r=k+(m+a<<4)|0;c[s>>2]=c[w>>2];c[s+4>>2]=c[w+4>>2];c[s+8>>2]=c[w+8>>2];c[s+12>>2]=c[w+12>>2];c[v>>2]=c[41818];c[v+4>>2]=c[41819];c[v+8>>2]=c[41820];c[v+12>>2]=c[41821];c[t>>2]=c[q>>2];c[t+4>>2]=c[q+4>>2];c[t+8>>2]=c[q+8>>2];c[t+12>>2]=c[q+12>>2];c[u>>2]=c[r>>2];c[u+4>>2]=c[r+4>>2];c[u+8>>2]=c[r+8>>2];c[u+12>>2]=c[r+12>>2];if(!(gz(s,v,t,u)|0)){b=30;break}else{j=g;b=b+1|0}}if((b|0)==30){c[42341]=g;a=0;break}else if((b|0)==31){c[42341]=j;a=1;break}}else a=0}else a=0}else{c[42336]=0;a=0}while(0);l=x;return a&1|0}function zz(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0,g=0.0,i=0,j=0,k=0;j=l;l=l+32|0;f=j+16|0;i=j;if(a){a=c[a>>2]|0;k=(c[(c[(ro(a)|0)+16>>2]|0)+116>>2]&3)*90|0;c[f>>2]=c[b>>2];c[f+4>>2]=c[b+4>>2];c[f+8>>2]=c[b+8>>2];c[f+12>>2]=c[b+12>>2];aw(i,f,k);g=+h[i>>3];e=+h[i+8>>3];if((a|0)==(c[42344]|0))d=+h[20911];else{i=c[(c[a+16>>2]|0)+12>>2]|0;k=(c[i+4>>2]<<1)+-2|0;d=+h[(c[i+44>>2]|0)+((((k|0)>0?k:0)|1)<<4)>>3];h[20911]=d;c[42344]=a}if(+B(+g)>d|+B(+e)>d)a=0;else a=+QJ(g,e)<=d&1}else{c[42344]=0;a=0}l=j;return a|0}function Az(e,f){e=e|0;f=f|0;var g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0.0,v=0,w=0;t=l;l=l+16|0;j=t;r=c[e+16>>2]|0;s=r+208|0;g=c[s>>2]|0;if((g|0)==0?(b[r+260>>1]&1)==0:0)q=0;else if(!(c[e+152>>2]&4)){wD(e,g,c[r+228>>2]|0,c[r+244>>2]|0,c[r+212>>2]|0);q=1}else q=1;n=f+16|0;k=c[(c[n>>2]|0)+12>>2]|0;o=c[k+44>>2]|0;p=c[k+8>>2]|0;k=c[k+4>>2]|0;if((c[42342]|0)<(p|0)){g=p+2|0;c[42342]=g;i=c[42343]|0;if(!i)g=ww(g<<4)|0;else g=yw(i,g<<4)|0;c[42343]=g}dz(f,j)|0;if(!(c[j>>2]&32))FD(e,21040);else FD(e,21036);g=c[42216]|0;if(g|0)OD(e,+EA(f,g,1.0,0.0));g=d[(c[n>>2]|0)+117>>0]|0;do if(!(g&1)){if(g&2|0){BD(e,GA(f,0,91300)|0);g=GA(f,0,91308)|0;DD(e,g);break}if(g&8|0){BD(e,GA(f,0,91316)|0);g=GA(f,0,91324)|0;DD(e,g);break}if(!(g&4)){g=cz(f,122106)|0;DD(e,g);$y(e,f)|0;break}else{BD(e,GA(f,0,91332)|0);g=GA(f,0,91340)|0;DD(e,g);break}}else{BD(e,GA(f,0,91284)|0);g=GA(f,0,91292)|0;DD(e,g)}while(0);if(!k)if(!(a[g>>0]|0))i=1;else{BD(e,g);i=1}else i=k;j=1;f=0;while(1){if((f|0)>=(i|0))break;k=O(f,p)|0;m=c[42343]|0;g=0;while(1){if((g|0)>=(p|0))break;w=g+k|0;u=+h[o+(w<<4)+8>>3];v=c[n>>2]|0;h[m+(g<<4)>>3]=+h[v+16>>3]+ +h[o+(w<<4)>>3];h[m+(g<<4)+8>>3]=+h[v+24>>3]+u;g=g+1|0}GD(e,m,p,j);j=0;f=f+1|0}if(q){if(c[e+152>>2]&4|0)wD(e,c[s>>2]|0,c[r+228>>2]|0,c[r+244>>2]|0,c[r+212>>2]|0);xD(e)}l=t;return}function Bz(a,b,e,f){a=a|0;b=b|0;e=e|0;f=f|0;var g=0,h=0;g=l;l=l+48|0;h=g;e=Cz(b,e,f)|0;c[h+36>>2]=c[f+36>>2];hz(b,c[f+24>>2]|0,h,e,d[f+33>>0]|0,0)|0;b=h;e=a+40|0;do{c[a>>2]=c[b>>2];a=a+4|0;b=b+4|0}while((a|0)<(e|0));l=g;return}function Cz(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0.0,j=0.0,k=0,m=0.0,n=0.0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0.0,B=0.0,C=0;z=l;l=l+32|0;y=z;g=z+24|0;k=z+16|0;x=c[(c[(c[(ro(b)|0)+60>>2]|0)+16>>2]|0)+116>>2]&3;f=b+16|0;w=(c[f>>2]|0)+16|0;c[y>>2]=c[w>>2];c[y+4>>2]=c[w+4>>2];c[y+8>>2]=c[w+8>>2];c[y+12>>2]=c[w+12>>2];Dz(g,y,x);w=(c[d+16>>2]|0)+16|0;c[y>>2]=c[w>>2];c[y+4>>2]=c[w+4>>2];c[y+8>>2]=c[w+8>>2];c[y+12>>2]=c[w+12>>2];Dz(k,y,x);x=a[e+33>>0]|0;y=x&255;a:do switch(x<<24>>24){case 0:case 15:{d=0;break}default:{d=c[e+24>>2]|0;if(!d){x=(c[(c[(ro(b)|0)+16>>2]|0)+116>>2]&1|0)==0;w=c[f>>2]|0;B=+h[w+80>>3]*.5;A=-B;m=+h[w+88>>3];j=-m;n=x?j:A;i=x?m:B;m=x?B:m;j=x?A:j}else{n=+h[d>>3];i=+h[d+16>>3];m=+h[d+24>>3];j=+h[d+8>>3]}x=c[g>>2]|0;v=c[g+4>>2]|0;w=c[k>>2]|0;s=c[k+4>>2]|0;t=~~j;u=~~((i+n)*.5);r=~~i;q=~~((m+j)*.5);p=~~m;o=~~n;g=0;k=0;d=0;e=0;b=0;while(1){if((k|0)==4)break a;if(1<>2]|0;else f=g}else f=g;g=f;k=k+1|0}}}while(0);l=z;return d|0}function Dz(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0;switch(d|0){case 0:{f=+h[b>>3];e=+h[b+8>>3];break}case 2:{f=+h[b>>3];e=-+h[b+8>>3];break}case 1:{f=-+h[b+8>>3];e=+h[b>>3];break}case 3:{f=+h[b+8>>3];e=+h[b>>3];break}default:{f=0.0;e=0.0}}c[a>>2]=~~(f+(f>=0.0?.5:-.5));c[a+4>>2]=~~(e+(e>=0.0?.5:-.5));return}function Ez(){var a=0,b=0,d=0;a=l;l=l+32|0;b=a+16|0;d=a;c[d>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;c[b>>2]=c[d>>2];c[b+4>>2]=c[d+4>>2];c[b+8>>2]=c[d+8>>2];c[b+12>>2]=c[d+12>>2];yz(0,b)|0;c[b>>2]=c[d>>2];c[b+4>>2]=c[d+4>>2];c[b+8>>2]=c[d+8>>2];c[b+12>>2]=c[d+12>>2];zz(0,b)|0;c[b>>2]=c[d>>2];c[b+4>>2]=c[d+4>>2];c[b+8>>2]=c[d+8>>2];c[b+12>>2]=c[d+12>>2];Wy(0,b)|0;l=a;return}function Fz(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,g=0.0,i=0.0,j=0,k=0,m=0,n=0,o=0,p=0.0,q=0,r=0.0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0;z=l;l=l+192|0;s=z+176|0;x=z+112|0;y=z+48|0;t=z+32|0;u=z+24|0;v=z+16|0;w=z;if(!(e<<24>>24)){k=d+48|0;c[t>>2]=c[k>>2];c[t+4>>2]=c[k+4>>2];c[t+8>>2]=c[k+8>>2];c[t+12>>2]=c[k+12>>2];k=u;m=v;n=x;o=0}else{c[t>>2]=c[d>>2];c[t+4>>2]=c[d+4>>2];c[t+8>>2]=c[d+8>>2];c[t+12>>2]=c[d+12>>2];k=v;m=u;n=0;o=x}h[u>>3]=0.0;h[v>>3]=1.0;q=t+8|0;f=0.0;g=1.0;j=0;p=+h[t>>3];while(1){r=+h[q>>3];f=(f+g)*.5;PA(w,d,3,f,n,o);c[t>>2]=c[w>>2];c[t+4>>2]=c[w+4>>2];c[t+8>>2]=c[w+8>>2];c[t+12>>2]=c[w+12>>2];c[s>>2]=c[w>>2];c[s+4>>2]=c[w+4>>2];c[s+8>>2]=c[w+8>>2];c[s+12>>2]=c[w+12>>2];a:do if(!((ab[b&63](a,s)|0)<<24>>24)){e=0;while(1){if((e|0)==4){e=k;j=1;break a}j=y+(e<<4)|0;A=x+(e<<4)|0;c[j>>2]=c[A>>2];c[j+4>>2]=c[A+4>>2];c[j+8>>2]=c[A+8>>2];c[j+12>>2]=c[A+12>>2];e=e+1|0}}else e=m;while(0);h[e>>3]=f;i=+h[t>>3];p=p-i;if(!((p>=0.0?p:-p)>.5)?(r=r-+h[q>>3],!((r>=0.0?r:-r)>.5)):0)break;f=+h[u>>3];g=+h[v>>3];p=i}b:do if(!(j<<24>>24)){e=0;while(1){if((e|0)==4)break b;A=d+(e<<4)|0;y=x+(e<<4)|0;c[A>>2]=c[y>>2];c[A+4>>2]=c[y+4>>2];c[A+8>>2]=c[y+8>>2];c[A+12>>2]=c[y+12>>2];e=e+1|0}}else{e=0;while(1){if((e|0)==4)break b;A=d+(e<<4)|0;x=y+(e<<4)|0;c[A>>2]=c[x>>2];c[A+4>>2]=c[x+4>>2];c[A+8>>2]=c[x+8>>2];c[A+12>>2]=c[x+12>>2];e=e+1|0}}while(0);l=z;return}function Gz(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0,k=0,m=0,n=0.0;m=l;l=l+48|0;d=m+16|0;e=m;f=m+32|0;g=a+16|0;i=c[g>>2]|0;j=c[i+8>>2]|0;if(j|0?(k=j+4|0,c[(c[k>>2]|0)+12>>2]|0):0){c[f>>2]=a;c[f+4>>2]=0;n=+h[i+96>>3];h[e>>3]=+h[b>>3]-+h[i+16>>3];h[e+8>>3]=+h[b+8>>3]-+h[i+24>>3];k=c[(c[k>>2]|0)+12>>2]|0;c[d>>2]=c[e>>2];c[d+4>>2]=c[e+4>>2];c[d+8>>2]=c[e+8>>2];c[d+12>>2]=c[e+12>>2];k=ab[k&63](f,d)|0;h[(c[g>>2]|0)+96>>3]=n;Hz(f,a,b,k)}l=m;return}function Hz(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0.0,m=0,n=0;n=l;l=l+64|0;m=n;j=b+16|0;g=c[j>>2]|0;k=+h[g+96>>3];i=g+16|0;f=g+24|0;b=0;while(1){if((b|0)==4)break;h[m+(b<<4)>>3]=+h[d+(b<<4)>>3]-+h[i>>3];h[m+(b<<4)+8>>3]=+h[d+(b<<4)+8>>3]-+h[f>>3];b=b+1|0}Fz(a,c[(c[(c[g+8>>2]|0)+4>>2]|0)+12>>2]|0,m,e);b=0;while(1){if((b|0)==4)break;e=c[j>>2]|0;h[d+(b<<4)>>3]=+h[e+16>>3]+ +h[m+(b<<4)>>3];h[d+(b<<4)+8>>3]=+h[e+24>>3]+ +h[m+(b<<4)+8>>3];b=b+1|0}h[(c[j>>2]|0)+96>>3]=k;l=n;return}function Iz(b,d){b=b|0;d=d|0;var e=0,f=0;while(1){f=b+16|0;b=c[f>>2]|0;if(!(a[b+112>>0]|0))break;b=c[b+116>>2]|0}b=c[b+8>>2]|0;if(!b){b=vw(40)|0;c[(c[f>>2]|0)+8>>2]=b}e=c[b>>2]|0;if(!e)b=ww(((c[b+4>>2]|0)*48|0)+48|0)|0;else b=yw(e,((c[b+4>>2]|0)*48|0)+48|0)|0;f=c[(c[f>>2]|0)+8>>2]|0;c[f>>2]=b;f=f+4|0;e=c[f>>2]|0;c[f>>2]=e+1;f=b+(e*48|0)|0;c[f>>2]=vw(d<<4)|0;c[b+(e*48|0)+4>>2]=d;b=b+(e*48|0)+8|0;e=b+40|0;do{c[b>>2]=0;b=b+4|0}while((b|0)<(e|0));return f|0}function Jz(b,e,f,g,i){b=b|0;e=e|0;f=f|0;g=g|0;i=i|0;var j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0;D=l;l=l+96|0;A=D+16|0;u=D;x=D+92|0;y=D+88|0;v=D+80|0;m=c[((c[b>>2]&3|0)==3?b:b+48|0)+40>>2]|0;z=ro(m)|0;B=Iz(b,g)|0;n=b;while(1){o=c[n+16>>2]|0;if(!(a[o+112>>0]|0))break;n=c[o+116>>2]|0}if((a[i+8>>0]|0)==0?(j=c[m+16>>2]|0,k=c[e+16>>2]|0,(c[j+232>>2]|0)==(c[k+232>>2]|0)):0){p=(c[j+236>>2]|0)>(c[k+236>>2]|0);w=p?m:e;m=p?e:m}else w=e;if((m|0)==(c[((c[n>>2]&3|0)==3?n:n+48|0)+40>>2]|0)){j=o+80|0;k=o+40|0;p=d[o+86>>0]|0;e=d[o+46>>0]|0}else{j=o+40|0;k=o+80|0;p=d[o+46>>0]|0;e=d[o+86>>0]|0}o=c[j>>2]|0;j=c[k>>2]|0;if(((e|0)!=0?(r=m+16|0,q=c[(c[r>>2]|0)+8>>2]|0,(q|0)!=0):0)?(c[(c[q+4>>2]|0)+12>>2]|0)!=0:0){c[v>>2]=m;c[v+4>>2]=j;j=g+-4|0;e=u+8|0;k=0;while(1){if((k|0)>=(j|0))break;n=k+3|0;q=c[r>>2]|0;h[u>>3]=+h[f+(n<<4)>>3]-+h[q+16>>3];h[e>>3]=+h[f+(n<<4)+8>>3]-+h[q+24>>3];q=c[(c[(c[q+8>>2]|0)+4>>2]|0)+12>>2]|0;c[A>>2]=c[u>>2];c[A+4>>2]=c[u+4>>2];c[A+8>>2]=c[u+8>>2];c[A+12>>2]=c[u+12>>2];if(!((ab[q&63](v,A)|0)<<24>>24))break;else k=n}c[x>>2]=k;Hz(v,m,f+(k<<4)|0,1)}else{c[x>>2]=0;k=0}if(((p|0)!=0?(t=w+16|0,s=c[(c[t>>2]|0)+8>>2]|0,(s|0)!=0):0)?(c[(c[s+4>>2]|0)+12>>2]|0)!=0:0){c[v>>2]=w;c[v+4>>2]=o;m=g+-4|0;e=u+8|0;j=m;while(1){if((j|0)<=0)break;g=c[t>>2]|0;h[u>>3]=+h[f+(j<<4)>>3]-+h[g+16>>3];h[e>>3]=+h[f+(j<<4)+8>>3]-+h[g+24>>3];g=c[(c[(c[g+8>>2]|0)+4>>2]|0)+12>>2]|0;c[A>>2]=c[u>>2];c[A+4>>2]=c[u+4>>2];c[A+8>>2]=c[u+8>>2];c[A+12>>2]=c[u+12>>2];if(!((ab[g&63](v,A)|0)<<24>>24))break;j=j+-3|0}c[y>>2]=j;Hz(v,w,f+(j<<4)|0,0)}else{m=g+-4|0;c[y>>2]=m;j=m}while(1){if((k|0)>=(m|0))break;e=k+3|0;E=+h[f+(k<<4)>>3]-+h[f+(e<<4)>>3];F=+h[f+(k<<4)+8>>3]-+h[f+(e<<4)+8>>3];if(F*F+E*E<1.0e-06)k=e;else break}c[x>>2]=k;while(1){if((j|0)<=0)break;v=j+3|0;F=+h[f+(j<<4)>>3]-+h[f+(v<<4)>>3];E=+h[f+(j<<4)+8>>3]-+h[f+(v<<4)+8>>3];if(!(E*E+F*F<1.0e-06))break;j=j+-3|0}c[y>>2]=j;Kz(b,w,f,x,y,B,i);r=c[x>>2]|0;n=c[y>>2]|0;m=n+4|0;n=n+3|0;o=A+16|0;p=A+32|0;q=A+48|0;k=z+16|0;j=r;while(1){if((j|0)>=(m|0))break;z=(c[B>>2]|0)+(j-r<<4)|0;e=f+(j<<4)|0;c[z>>2]=c[e>>2];c[z+4>>2]=c[e+4>>2];c[z+8>>2]=c[e+8>>2];c[z+12>>2]=c[e+12>>2];c[A>>2]=c[e>>2];c[A+4>>2]=c[e+4>>2];c[A+8>>2]=c[e+8>>2];c[A+12>>2]=c[e+12>>2];e=j+1|0;if((j|0)>=(n|0)){C=38;break}y=(c[B>>2]|0)+(e-r<<4)|0;z=f+(e<<4)|0;c[y>>2]=c[z>>2];c[y+4>>2]=c[z+4>>2];c[y+8>>2]=c[z+8>>2];c[y+12>>2]=c[z+12>>2];c[o>>2]=c[z>>2];c[o+4>>2]=c[z+4>>2];c[o+8>>2]=c[z+8>>2];c[o+12>>2]=c[z+12>>2];z=j+2|0;y=(c[B>>2]|0)+(z-r<<4)|0;z=f+(z<<4)|0;c[y>>2]=c[z>>2];c[y+4>>2]=c[z+4>>2];c[y+8>>2]=c[z+8>>2];c[y+12>>2]=c[z+12>>2];c[p>>2]=c[z>>2];c[p+4>>2]=c[z+4>>2];c[p+8>>2]=c[z+8>>2];c[p+12>>2]=c[z+12>>2];z=j+3|0;y=f+(z<<4)|0;c[q>>2]=c[y>>2];c[q+4>>2]=c[y+4>>2];c[q+8>>2]=c[y+8>>2];c[q+12>>2]=c[y+12>>2];eu((c[k>>2]|0)+16|0,A);j=z}c[B+4>>2]=m-r;l=D;return}function Kz(b,d,e,f,g,h,i){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,m=0,n=0,o=0,p=0;p=l;l=l+16|0;m=p+4|0;n=p;o=b;while(1){j=c[(c[o+16>>2]|0)+116>>2]|0;if(!j)break;else o=j}if(!(a[i+8>>0]|0))j=($a[c[i>>2]&31](o)|0)&255;else j=0;At(o,m,n);k=i+4|0;if(($a[c[k>>2]&31](d)|0)<<24>>24)c[n>>2]=0;if(($a[c[k>>2]&31](c[((c[b>>2]&3|0)==3?b:b+48|0)+40>>2]|0)|0)<<24>>24)c[m>>2]=0;if(j|0){d=c[m>>2]|0;c[m>>2]=c[n>>2];c[n>>2]=d}if(!(a[i+9>>0]|0)){j=c[m>>2]|0;if(j|0)c[f>>2]=Pt(o,e,c[f>>2]|0,c[g>>2]|0,h,j)|0;j=c[n>>2]|0;if(j|0)c[g>>2]=Nt(o,e,c[f>>2]|0,c[g>>2]|0,h,j)|0}else{k=c[n>>2]|0;j=c[m>>2]|0;if(j|k|0)Qt(o,e,c[f>>2]|0,c[g>>2]|0,h,j,k)}l=p;return}function Lz(a,b){a=a|0;b=b|0;var d=0,e=0;if(+h[b>>3]<+h[b+16>>3]?+h[b+8>>3]<+h[b+24>>3]:0){d=c[a+84>>2]|0;e=a+80|0;a=c[e>>2]|0;c[e>>2]=a+1;a=d+(a<<5)|0;c[a>>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];c[a+12>>2]=c[b+12>>2];c[a+16>>2]=c[b+16>>2];c[a+20>>2]=c[b+20>>2];c[a+24>>2]=c[b+24>>2];c[a+28>>2]=c[b+28>>2]}return}function Mz(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var i=0,j=0,k=0.0,m=0.0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0.0,z=0.0;x=l;l=l+112|0;u=x+72|0;o=x+56|0;n=x+16|0;q=x;j=c[d>>2]&3;p=d+48|0;w=c[((j|0)==3?d:p)+40>>2]|0;t=d+16|0;r=c[t>>2]|0;i=r+16|0;if(a[r+47>>0]|0){Bz(n,w,c[((j|0)==2?d:d+-48|0)+40>>2]|0,i);j=n;n=i+40|0;do{c[i>>2]=c[j>>2];i=i+4|0;j=j+4|0}while((i|0)<(n|0))}r=w+16|0;j=c[r>>2]|0;i=c[j+8>>2]|0;if(!i)n=0;else n=c[(c[i+4>>2]|0)+16>>2]|0;i=j+16|0;j=(c[t>>2]|0)+16|0;c[o>>2]=c[i>>2];c[o+4>>2]=c[i+4>>2];c[o+8>>2]=c[i+8>>2];c[o+12>>2]=c[i+12>>2];c[u>>2]=c[j>>2];c[u+4>>2]=c[j+4>>2];c[u+8>>2]=c[j+8>>2];c[u+12>>2]=c[j+12>>2];Nz(q,o,u);c[b>>2]=c[q>>2];c[b+4>>2]=c[q+4>>2];c[b+8>>2]=c[q+8>>2];c[b+12>>2]=c[q+12>>2];if(!(g<<24>>24)){i=c[t>>2]|0;if(!(a[i+45>>0]|0))i=0;else{k=+h[i+32>>3];v=9}}else{k=+Oz(c[((c[d>>2]&3|0)==3?d:p)+40>>2]|0);v=9}if((v|0)==9){h[b+16>>3]=k;i=1}a[b+29>>0]=i;c[b+80>>2]=0;c[b+88>>2]=d;q=f+32|0;c[q>>2]=c[b>>2];c[q+4>>2]=c[b+4>>2];c[q+8>>2]=c[b+8>>2];c[q+12>>2]=c[b+12>>2];switch(e|0){case 1:{j=c[r>>2]|0;if((a[j+156>>0]|0)==0?(q=a[(c[t>>2]|0)+49>>0]|0,s=q&255,q<<24>>24!=0):0){c[u>>2]=c[f>>2];c[u+4>>2]=c[f+4>>2];c[u+8>>2]=c[f+8>>2];c[u+12>>2]=c[f+12>>2];c[u+16>>2]=c[f+16>>2];c[u+20>>2]=c[f+20>>2];c[u+24>>2]=c[f+24>>2];c[u+28>>2]=c[f+28>>2];do if(!(s&4)){if(s&1|0){c[f+48>>2]=1;i=u+24|0;h[i>>3]=+h[(+h[i>>3]>+h[b+8>>3]?u+16|0:b)+8>>3];i=f+56|0;c[i>>2]=c[u>>2];c[i+4>>2]=c[u+4>>2];c[i+8>>2]=c[u+8>>2];c[i+12>>2]=c[u+12>>2];c[i+16>>2]=c[u+16>>2];c[i+20>>2]=c[u+20>>2];c[i+24>>2]=c[u+24>>2];c[i+28>>2]=c[u+28>>2];i=1;break}i=f+48|0;if(!(s&8)){c[i>>2]=2;h[u>>3]=+h[b>>3];h[u+8>>3]=+h[j+24>>3]-+h[j+80>>3]*.5;h[u+24>>3]=+h[b+8>>3];i=f+56|0;c[i>>2]=c[u>>2];c[i+4>>2]=c[u+4>>2];c[i+8>>2]=c[u+8>>2];c[i+12>>2]=c[u+12>>2];c[i+16>>2]=c[u+16>>2];c[i+20>>2]=c[u+20>>2];c[i+24>>2]=c[u+24>>2];c[i+28>>2]=c[u+28>>2];i=1;break}else{c[i>>2]=8;h[u+16>>3]=+h[b>>3];h[u+8>>3]=+h[j+24>>3]-+h[j+80>>3]*.5;h[u+24>>3]=+h[b+8>>3];i=f+56|0;c[i>>2]=c[u>>2];c[i+4>>2]=c[u+4>>2];c[i+8>>2]=c[u+8>>2];c[i+12>>2]=c[u+12>>2];c[i+16>>2]=c[u+16>>2];c[i+20>>2]=c[u+20>>2];c[i+24>>2]=c[u+24>>2];c[i+28>>2]=c[u+28>>2];i=1;break}}else{c[f+48>>2]=4;k=+h[u>>3];if(+h[b>>3]<+h[j+16>>3]){z=k+-1.0;y=+h[b+8>>3];b=u+16|0;k=+h[b>>3];m=+h[j+80>>3]*.5+ +h[j+24>>3];m=m+ +((c[(c[(ro(w)|0)+16>>2]|0)+252>>2]|0)/2|0|0);i=c[r>>2]|0;h[b>>3]=+h[i+16>>3]-+h[i+88>>3];h[u+24>>3]=y;h[u+8>>3]=+h[i+24>>3]-+h[i+80>>3]*.5;h[u>>3]=z;h[f+56>>3]=z;h[f+64>>3]=y;h[f+72>>3]=k;h[f+80>>3]=m;i=f+88|0;c[i>>2]=c[u>>2];c[i+4>>2]=c[u+4>>2];c[i+8>>2]=c[u+8>>2];c[i+12>>2]=c[u+12>>2];c[i+16>>2]=c[u+16>>2];c[i+20>>2]=c[u+20>>2];c[i+24>>2]=c[u+24>>2];c[i+28>>2]=c[u+28>>2];i=2;break}else{m=+h[b+8>>3];i=u+16|0;y=+h[i>>3]+1.0;z=+h[j+80>>3]*.5+ +h[j+24>>3];z=z+ +((c[(c[(ro(w)|0)+16>>2]|0)+252>>2]|0)/2|0|0);b=c[r>>2]|0;h[u>>3]=+h[b+96>>3]+ +h[b+16>>3];h[u+24>>3]=m;h[u+8>>3]=+h[b+24>>3]-+h[b+80>>3]*.5;h[i>>3]=y;h[f+56>>3]=k;h[f+64>>3]=m;h[f+72>>3]=y;h[f+80>>3]=z;i=f+88|0;c[i>>2]=c[u>>2];c[i+4>>2]=c[u+4>>2];c[i+8>>2]=c[u+8>>2];c[i+12>>2]=c[u+12>>2];c[i+16>>2]=c[u+16>>2];c[i+20>>2]=c[u+20>>2];c[i+24>>2]=c[u+24>>2];c[i+28>>2]=c[u+28>>2];i=2;break}}while(0);c[f+52>>2]=i;while(1){i=c[d+16>>2]|0;if(!(a[i+112>>0]|0))break;d=c[i+116>>2]|0}a[((w|0)==(c[((c[d>>2]&3|0)==3?d:d+48|0)+40>>2]|0)?i+16|0:i+56|0)+30>>0]=0}else{j=1;v=47}break}case 2:{s=a[(c[t>>2]|0)+49>>0]|0;j=s&255;if(!(s<<24>>24))v=46;else{c[u>>2]=c[f>>2];c[u+4>>2]=c[f+4>>2];c[u+8>>2]=c[f+8>>2];c[u+12>>2]=c[f+12>>2];c[u+16>>2]=c[f+16>>2];c[u+20>>2]=c[f+20>>2];c[u+24>>2]=c[f+24>>2];c[u+28>>2]=c[f+28>>2];do if(!(j&4)){if(j&1|0)if((c[f+48>>2]|0)==4){i=c[r>>2]|0;z=+h[i+24>>3]-+h[i+80>>3]*.5;i=u+16|0;y=+h[i>>3]+1.0;k=+h[b>>3];m=z-+((c[(c[(ro(w)|0)+16>>2]|0)+252>>2]|0)/2|0|0);b=c[r>>2]|0;h[u>>3]=+h[b+96>>3]+ +h[b+16>>3];h[u+8>>3]=z;h[u+24>>3]=+h[b+80>>3]*.5+ +h[b+24>>3];h[i>>3]=y;h[f+56>>3]=k;h[f+64>>3]=m;h[f+72>>3]=y;h[f+80>>3]=z;i=f+88|0;c[i>>2]=c[u>>2];c[i+4>>2]=c[u+4>>2];c[i+8>>2]=c[u+8>>2];c[i+12>>2]=c[u+12>>2];c[i+16>>2]=c[u+16>>2];c[i+20>>2]=c[u+20>>2];c[i+24>>2]=c[u+24>>2];c[i+28>>2]=c[u+28>>2];i=2;break}else{i=u+24|0;h[i>>3]=+h[(+h[i>>3]>+h[b+8>>3]?u+16|0:b)+8>>3];i=f+56|0;c[i>>2]=c[u>>2];c[i+4>>2]=c[u+4>>2];c[i+8>>2]=c[u+8>>2];c[i+12>>2]=c[u+12>>2];c[i+16>>2]=c[u+16>>2];c[i+20>>2]=c[u+20>>2];c[i+24>>2]=c[u+24>>2];c[i+28>>2]=c[u+28>>2];i=1;break}k=+h[b>>3];if(!(j&8)){h[u>>3]=k;e=c[r>>2]|0;k=+h[e+24>>3];m=+h[e+80>>3]*.5;if((c[f+48>>2]|0)==4){h[u+24>>3]=m+k;k=+h[b+8>>3];i=u}else{h[u+8>>3]=k-m;k=+h[b+8>>3]+1.0;i=u+16|0}h[i+8>>3]=k;i=f+56|0;c[i>>2]=c[u>>2];c[i+4>>2]=c[u+4>>2];c[i+8>>2]=c[u+8>>2];c[i+12>>2]=c[u+12>>2];c[i+16>>2]=c[u+16>>2];c[i+20>>2]=c[u+20>>2];c[i+24>>2]=c[u+24>>2];c[i+28>>2]=c[u+28>>2];i=1;break}else{i=u+16|0;h[i>>3]=k+1.0;e=c[r>>2]|0;k=+h[e+24>>3];m=+h[e+80>>3]*.5;if((c[f+48>>2]|0)==4){h[u+24>>3]=m+k;k=+h[b+8>>3]+-1.0;i=u}else{h[u+8>>3]=k-m;k=+h[b+8>>3]+1.0}h[i+8>>3]=k;i=f+56|0;c[i>>2]=c[u>>2];c[i+4>>2]=c[u+4>>2];c[i+8>>2]=c[u+8>>2];c[i+12>>2]=c[u+12>>2];c[i+16>>2]=c[u+16>>2];c[i+20>>2]=c[u+20>>2];c[i+24>>2]=c[u+24>>2];c[i+28>>2]=c[u+28>>2];i=1;break}}else{i=u+8|0;h[i>>3]=+h[(+h[i>>3]<+h[b+8>>3]?u:b)+8>>3];i=f+56|0;c[i>>2]=c[u>>2];c[i+4>>2]=c[u+4>>2];c[i+8>>2]=c[u+8>>2];c[i+12>>2]=c[u+12>>2];c[i+16>>2]=c[u+16>>2];c[i+20>>2]=c[u+20>>2];c[i+24>>2]=c[u+24>>2];c[i+28>>2]=c[u+28>>2];i=1}while(0);c[f+52>>2]=i;while(1){i=c[d+16>>2]|0;if(!(a[i+112>>0]|0))break;d=c[i+116>>2]|0}a[((w|0)==(c[((c[d>>2]&3|0)==3?d:d+48|0)+40>>2]|0)?i+16|0:i+56|0)+30>>0]=0;c[f+48>>2]=j}break}default:v=46}if((v|0)==46){j=c[f+48>>2]|0;v=47}a:do if((v|0)==47){if(n){d=f+56|0;i=f+52|0;j=db[n&3](w,(c[t>>2]|0)+16|0,j,d,i)|0;if(j){c[f+48>>2]=j;break}}else{i=f+52|0;d=f+56|0};c[d>>2]=c[f>>2];c[d+4>>2]=c[f+4>>2];c[d+8>>2]=c[f+8>>2];c[d+12>>2]=c[f+12>>2];c[d+16>>2]=c[f+16>>2];c[d+20>>2]=c[f+20>>2];c[d+24>>2]=c[f+24>>2];c[d+28>>2]=c[f+28>>2];c[i>>2]=1;switch(e|0){case 8:{ma(123205,91558,569,91568);break}case 2:{h[((c[f+48>>2]|0)==4?f+56|0:f+72|0)+8>>3]=+h[b+8>>3];break a}case 1:{h[f+80>>3]=+h[b+8>>3];c[f+48>>2]=1;break a}default:break a}}while(0);l=x;return}function Nz(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0;d=+h[c+8>>3]+ +h[b+8>>3];h[a>>3]=+h[c>>3]+ +h[b>>3];h[a+8>>3]=d;return}function Oz(a){a=a|0;var b=0.0,d=0,e=0,f=0.0,g=0,i=0,j=0,k=0.0,l=0.0;i=c[a+16>>2]|0;j=c[i+172>>2]|0;f=0.0;g=0;while(1){a=c[j+(g<<2)>>2]|0;if(!a)break;f=+h[(c[(c[((c[a>>2]&3|0)==3?a:a+48|0)+40>>2]|0)+16>>2]|0)+16>>3]+f;g=g+1|0}e=c[i+180>>2]|0;b=0.0;a=0;while(1){d=c[e+(a<<2)>>2]|0;if(!d)break;b=+h[(c[(c[((c[d>>2]&3|0)==2?d:d+-48|0)+40>>2]|0)+16>>2]|0)+16>>3]+b;a=a+1|0}k=+h[i+16>>3];l=+h[i+24>>3];j=c[j>>2]|0;f=+K(+(l-+h[(c[(c[((c[j>>2]&3|0)==3?j:j+48|0)+40>>2]|0)+16>>2]|0)+24>>3]),+(k-f/+(g|0)));j=c[e>>2]|0;return +((+K(+(+h[(c[(c[((c[j>>2]&3|0)==2?j:j+-48|0)+40>>2]|0)+16>>2]|0)+24>>3]-l),+(b/+(a|0)-k))+f)*.5)}function Pz(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var i=0,j=0,k=0.0,m=0.0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0.0,B=0.0;z=l;l=l+112|0;w=z+72|0;p=z+56|0;n=z+16|0;t=z;j=c[d>>2]&3;r=d+-48|0;y=c[((j|0)==2?d:r)+40>>2]|0;u=d+16|0;s=c[u>>2]|0;i=s+56|0;if(a[s+87>>0]|0){Bz(n,y,c[((j|0)==3?d:d+48|0)+40>>2]|0,i);j=n;n=i+40|0;do{c[i>>2]=c[j>>2];i=i+4|0;j=j+4|0}while((i|0)<(n|0))}s=y+16|0;j=c[s>>2]|0;i=c[j+8>>2]|0;if(!i)o=0;else o=c[(c[i+4>>2]|0)+16>>2]|0;n=b+40|0;i=j+16|0;j=(c[u>>2]|0)+56|0;c[p>>2]=c[i>>2];c[p+4>>2]=c[i+4>>2];c[p+8>>2]=c[i+8>>2];c[p+12>>2]=c[i+12>>2];c[w>>2]=c[j>>2];c[w+4>>2]=c[j+4>>2];c[w+8>>2]=c[j+8>>2];c[w+12>>2]=c[j+12>>2];Nz(t,p,w);c[n>>2]=c[t>>2];c[n+4>>2]=c[t+4>>2];c[n+8>>2]=c[t+8>>2];c[n+12>>2]=c[t+12>>2];if(!(g<<24>>24)){i=c[u>>2]|0;if(!(a[i+85>>0]|0))q=0;else{h[b+56>>3]=+h[i+72>>3];q=1}}else{m=+Oz(c[((c[d>>2]&3|0)==2?d:r)+40>>2]|0)+3.141592653589793;h[b+56>>3]=m;if(m<6.283185307179586)q=1;else ma(91578,91558,606,91602)}a[b+69>>0]=q;t=f+32|0;c[t>>2]=c[n>>2];c[t+4>>2]=c[n+4>>2];c[t+8>>2]=c[n+8>>2];c[t+12>>2]=c[n+12>>2];switch(e|0){case 1:{j=c[s>>2]|0;if((a[j+156>>0]|0)==0?(t=a[(c[u>>2]|0)+89>>0]|0,v=t&255,t<<24>>24!=0):0){c[w>>2]=c[f>>2];c[w+4>>2]=c[f+4>>2];c[w+8>>2]=c[f+8>>2];c[w+12>>2]=c[f+12>>2];c[w+16>>2]=c[f+16>>2];c[w+20>>2]=c[f+20>>2];c[w+24>>2]=c[f+24>>2];c[w+28>>2]=c[f+28>>2];do if(!(v&4))if(!(v&1)){i=f+48|0;if(!(v&8)){c[i>>2]=2;h[w>>3]=+h[n>>3];h[w+24>>3]=+h[j+80>>3]*.5+ +h[j+24>>3];h[w+8>>3]=+h[b+48>>3];i=f+56|0;c[i>>2]=c[w>>2];c[i+4>>2]=c[w+4>>2];c[i+8>>2]=c[w+8>>2];c[i+12>>2]=c[w+12>>2];c[i+16>>2]=c[w+16>>2];c[i+20>>2]=c[w+20>>2];c[i+24>>2]=c[w+24>>2];c[i+28>>2]=c[w+28>>2];i=1;break}else{c[i>>2]=8;h[w+16>>3]=+h[n>>3];h[w+24>>3]=+h[j+80>>3]*.5+ +h[j+24>>3];h[w+8>>3]=+h[b+48>>3];i=f+56|0;c[i>>2]=c[w>>2];c[i+4>>2]=c[w+4>>2];c[i+8>>2]=c[w+8>>2];c[i+12>>2]=c[w+12>>2];c[i+16>>2]=c[w+16>>2];c[i+20>>2]=c[w+20>>2];c[i+24>>2]=c[w+24>>2];c[i+28>>2]=c[w+28>>2];i=1;break}}else{c[f+48>>2]=1;k=+h[w>>3];if(+h[n>>3]<+h[j+16>>3]){B=k+-1.0;m=+h[b+48>>3];b=w+16|0;k=+h[b>>3];A=+h[j+80>>3]*-.5+ +h[j+24>>3];A=A-+((c[(c[(ro(y)|0)+16>>2]|0)+252>>2]|0)/2|0|0);i=c[s>>2]|0;h[b>>3]=+h[i+16>>3]-+h[i+88>>3];h[w+8>>3]=m;h[w+24>>3]=+h[i+80>>3]*.5+ +h[i+24>>3];h[w>>3]=B;h[f+56>>3]=B;h[f+64>>3]=A;h[f+72>>3]=k;h[f+80>>3]=m;i=f+88|0;c[i>>2]=c[w>>2];c[i+4>>2]=c[w+4>>2];c[i+8>>2]=c[w+8>>2];c[i+12>>2]=c[w+12>>2];c[i+16>>2]=c[w+16>>2];c[i+20>>2]=c[w+20>>2];c[i+24>>2]=c[w+24>>2];c[i+28>>2]=c[w+28>>2];i=2;break}else{B=+h[b+48>>3];i=w+16|0;A=+h[i>>3]+1.0;m=+h[j+80>>3]*-.5+ +h[j+24>>3];m=m-+((c[(c[(ro(y)|0)+16>>2]|0)+252>>2]|0)/2|0|0);b=c[s>>2]|0;h[w>>3]=+h[b+96>>3]+ +h[b+16>>3];h[w+8>>3]=B;h[w+24>>3]=+h[b+80>>3]*.5+ +h[b+24>>3];h[i>>3]=A;h[f+56>>3]=k;h[f+64>>3]=m;h[f+72>>3]=A;h[f+80>>3]=B;i=f+88|0;c[i>>2]=c[w>>2];c[i+4>>2]=c[w+4>>2];c[i+8>>2]=c[w+8>>2];c[i+12>>2]=c[w+12>>2];c[i+16>>2]=c[w+16>>2];c[i+20>>2]=c[w+20>>2];c[i+24>>2]=c[w+24>>2];c[i+28>>2]=c[w+28>>2];i=2;break}}else{c[f+48>>2]=4;i=w+8|0;h[i>>3]=+h[(+h[i>>3]<+h[b+48>>3]?w:n)+8>>3];i=f+56|0;c[i>>2]=c[w>>2];c[i+4>>2]=c[w+4>>2];c[i+8>>2]=c[w+8>>2];c[i+12>>2]=c[w+12>>2];c[i+16>>2]=c[w+16>>2];c[i+20>>2]=c[w+20>>2];c[i+24>>2]=c[w+24>>2];c[i+28>>2]=c[w+28>>2];i=1}while(0);c[f+52>>2]=i;while(1){i=c[d+16>>2]|0;if(!(a[i+112>>0]|0))break;d=c[i+116>>2]|0}a[((y|0)==(c[((c[d>>2]&3|0)==2?d:d+-48|0)+40>>2]|0)?i+56|0:i+16|0)+30>>0]=0;c[f+48>>2]=v}else{j=4;x=47}break}case 2:{v=a[(c[u>>2]|0)+89>>0]|0;j=v&255;if(!(v<<24>>24))x=46;else{c[w>>2]=c[f>>2];c[w+4>>2]=c[f+4>>2];c[w+8>>2]=c[f+8>>2];c[w+12>>2]=c[f+12>>2];c[w+16>>2]=c[f+16>>2];c[w+20>>2]=c[f+20>>2];c[w+24>>2]=c[f+24>>2];c[w+28>>2]=c[f+28>>2];do if(!(j&4)){if(j&1|0)if((c[f+48>>2]|0)==4){k=+h[w>>3]+-1.0;i=c[s>>2]|0;B=+h[i+24>>3]-+h[i+80>>3]*.5;A=+h[n>>3];m=B-+((c[(c[(ro(y)|0)+16>>2]|0)+252>>2]|0)/2|0|0);i=c[s>>2]|0;h[w+16>>3]=+h[i+16>>3]+-2.0-+h[i+88>>3];h[w+8>>3]=B;h[w+24>>3]=+h[i+80>>3]*.5+ +h[i+24>>3];h[w>>3]=k;h[f+56>>3]=k;h[f+64>>3]=m;h[f+72>>3]=A;h[f+80>>3]=B;i=f+88|0;c[i>>2]=c[w>>2];c[i+4>>2]=c[w+4>>2];c[i+8>>2]=c[w+8>>2];c[i+12>>2]=c[w+12>>2];c[i+16>>2]=c[w+16>>2];c[i+20>>2]=c[w+20>>2];c[i+24>>2]=c[w+24>>2];c[i+28>>2]=c[w+28>>2];i=2;break}else{i=w+24|0;h[i>>3]=+h[(+h[i>>3]>+h[b+8>>3]?w+16|0:b)+8>>3];i=f+56|0;c[i>>2]=c[w>>2];c[i+4>>2]=c[w+4>>2];c[i+8>>2]=c[w+8>>2];c[i+12>>2]=c[w+12>>2];c[i+16>>2]=c[w+16>>2];c[i+20>>2]=c[w+20>>2];c[i+24>>2]=c[w+24>>2];c[i+28>>2]=c[w+28>>2];i=1;break}k=+h[n>>3];if(!(j&8)){h[w>>3]=k+-1.0;e=c[s>>2]|0;k=+h[e+24>>3];m=+h[e+80>>3]*.5;if((c[f+48>>2]|0)==4){h[w+24>>3]=m+k;k=+h[b+48>>3]+-1.0;i=w}else{h[w+8>>3]=k-m;k=+h[b+48>>3];i=w+16|0}h[i+8>>3]=k;i=f+56|0;c[i>>2]=c[w>>2];c[i+4>>2]=c[w+4>>2];c[i+8>>2]=c[w+8>>2];c[i+12>>2]=c[w+12>>2];c[i+16>>2]=c[w+16>>2];c[i+20>>2]=c[w+20>>2];c[i+24>>2]=c[w+24>>2];c[i+28>>2]=c[w+28>>2];i=1;break}else{i=w+16|0;h[i>>3]=k+1.0;e=c[s>>2]|0;k=+h[e+24>>3];m=+h[e+80>>3]*.5;if((c[f+48>>2]|0)==4){h[w+24>>3]=m+k;k=+h[b+48>>3]+-1.0;i=w}else{h[w+8>>3]=k-m;k=+h[b+48>>3]+1.0}h[i+8>>3]=k;i=f+56|0;c[i>>2]=c[w>>2];c[i+4>>2]=c[w+4>>2];c[i+8>>2]=c[w+8>>2];c[i+12>>2]=c[w+12>>2];c[i+16>>2]=c[w+16>>2];c[i+20>>2]=c[w+20>>2];c[i+24>>2]=c[w+24>>2];c[i+28>>2]=c[w+28>>2];i=1;break}}else{i=w+8|0;h[i>>3]=+h[(+h[i>>3]<+h[b+48>>3]?w:n)+8>>3];i=f+56|0;c[i>>2]=c[w>>2];c[i+4>>2]=c[w+4>>2];c[i+8>>2]=c[w+8>>2];c[i+12>>2]=c[w+12>>2];c[i+16>>2]=c[w+16>>2];c[i+20>>2]=c[w+20>>2];c[i+24>>2]=c[w+24>>2];c[i+28>>2]=c[w+28>>2];i=1}while(0);c[f+52>>2]=i;while(1){i=c[d+16>>2]|0;if(!(a[i+112>>0]|0))break;d=c[i+116>>2]|0}a[((y|0)==(c[((c[d>>2]&3|0)==2?d:d+-48|0)+40>>2]|0)?i+56|0:i+16|0)+30>>0]=0;c[f+48>>2]=j}break}default:x=46}if((x|0)==46){j=c[f+48>>2]|0;x=47}a:do if((x|0)==47){if(o){d=f+56|0;i=f+52|0;j=db[o&3](y,(c[u>>2]|0)+56|0,j,d,i)|0;if(j){c[f+48>>2]=j;break}}else{i=f+52|0;d=f+56|0};c[d>>2]=c[f>>2];c[d+4>>2]=c[f+4>>2];c[d+8>>2]=c[f+8>>2];c[d+12>>2]=c[f+12>>2];c[d+16>>2]=c[f+16>>2];c[d+20>>2]=c[f+20>>2];c[d+24>>2]=c[f+24>>2];c[d+28>>2]=c[f+28>>2];c[i>>2]=1;switch(e|0){case 8:{ma(123205,91558,765,91602);break}case 2:{h[((c[f+48>>2]|0)==4?f+56|0:f+72|0)+8>>3]=+h[b+48>>3];break a}case 1:{h[f+64>>3]=+h[b+48>>3];c[f+48>>2]=4;break a}default:break a}}while(0);l=z;return}function Qz(b){b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0;g=c[b+16>>2]|0;i=c[g+96>>2]|0;if((a[g+44>>0]|0)==0?(a[g+84>>0]|0)==0:0)j=6;else{d=a[g+49>>0]|0;e=d&255;if(((e&8|0)==0?(f=a[g+89>>0]|0,(f&8)==0):0)?((e&5|0)==0?1:d<<24>>24!=f<<24>>24):0)j=6;else b=0}if((j|0)==6)if(!i)b=18;else{b=(c[(c[(ro(c[((c[b>>2]&3|0)==2?b:b+-48|0)+40>>2]|0)|0)+16>>2]|0)+116>>2]&1|0)!=0;b=~~(+h[(b?i+32|0:i+24|0)>>3]+18.0)}return b|0}function Rz(b,d,e,f,g,h,i){b=b|0;d=d|0;e=e|0;f=f|0;g=+g;h=+h;i=i|0;var j=0,k=0,l=0,m=0;b=c[(c[d+(e<<2)>>2]|0)+16>>2]|0;if((a[b+44>>0]|0)==0?(a[b+84>>0]|0)==0:0)l=6;else l=3;do if((l|0)==3){j=a[b+49>>0]|0;k=j&255;if(!(k&8)){m=a[b+89>>0]|0;if((m&8)==0?((k&5|0)==0?1:j<<24>>24!=m<<24>>24):0){l=6;break}if(!(a[b+89>>0]&8)){if(k&4|0){Tz(d,e,f,g,h,i);break}if(!(k&1))ma(123205,91558,1231,91610);else{Vz(d,e,f,g,h,i);break}}}if((j&2)==0?(a[b+89>>0]&2)==0:0){Uz(d,e,f,g,h,i);break}Tz(d,e,f,g,h,i)}while(0);if((l|0)==6)Sz(d,e,f,g,h,i);return}function Sz(b,e,f,g,i,j){b=b|0;e=e|0;f=f|0;g=+g;i=+i;j=j|0;var k=0,m=0.0,n=0.0,o=0.0,p=0.0,q=0,r=0,s=0,t=0,u=0,v=0.0,w=0,x=0,y=0,z=0.0,A=0,B=0,C=0.0,D=0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0.0,R=0.0,S=0;P=l;l=l+16080|0;L=P+80|0;M=P+64|0;N=P+48|0;O=P+32|0;J=P+16|0;K=P;B=c[b+(e<<2)>>2]|0;n=i*.5/+(f|0);n=n>2.0?n:2.0;D=(c[((c[B>>2]&3|0)==3?B:B+48|0)+40>>2]|0)+16|0;A=c[D>>2]|0;C=+h[A+16>>3];H=+h[A+24>>3];B=c[B+16>>2]|0;m=+h[B+16>>3];E=m+C;F=+h[B+24>>3]+H;i=+h[B+56>>3];G=i+C;H=+h[B+64>>3]+H;k=!(F>=H)?-1:1;p=+h[A+96>>3];switch(Wz(d[B+49>>0]|0,d[B+89>>0]|0)|0){case 65:case 32:{if(F==H)k=0-k|0;break}default:{}}Q=(p-m)*3.0;m=(p-i)*3.0;v=n*+(k|0);u=L+8|0;w=L+16|0;x=L+32|0;y=L+48|0;z=(H+F)*.5;A=L+64|0;B=L+80|0;s=L+96|0;t=L+104|0;r=0;o=0.0;i=p;n=p=(f|0))break;q=e+1|0;e=c[b+(e<<2)>>2]|0;p=i+g;n=n+g;m=m+g;o=o+v;h[L>>3]=E;h[u>>3]=F;Q=o+F;Xz(M,n*.3333333333333333+E,Q);c[w>>2]=c[M>>2];c[w+4>>2]=c[M+4>>2];c[w+8>>2]=c[M+8>>2];c[w+12>>2]=c[M+12>>2];R=p+C;Xz(N,R,Q);c[x>>2]=c[N>>2];c[x+4>>2]=c[N+4>>2];c[x+8>>2]=c[N+8>>2];c[x+12>>2]=c[N+12>>2];Xz(O,R,z);c[y>>2]=c[O>>2];c[y+4>>2]=c[O+4>>2];c[y+8>>2]=c[O+8>>2];c[y+12>>2]=c[O+12>>2];Q=H-o;Xz(J,R,Q);c[A>>2]=c[J>>2];c[A+4>>2]=c[J+4>>2];c[A+8>>2]=c[J+8>>2];c[A+12>>2]=c[J+12>>2];Xz(K,m*.3333333333333333+G,Q);c[B>>2]=c[K>>2];c[B+4>>2]=c[K+4>>2];c[B+8>>2]=c[K+8>>2];c[B+12>>2]=c[K+12>>2];h[s>>3]=G;h[t>>3]=H;k=e+16|0;if((c[(c[k>>2]|0)+96>>2]|0)!=0?(S=(c[(c[(ro(c[((c[e>>2]&3|0)==3?e:e+48|0)+40>>2]|0)|0)+16>>2]|0)+116>>2]&1|0)==0,k=c[(c[k>>2]|0)+96>>2]|0,I=+h[(S?k+24|0:k+32|0)>>3],S=c[D>>2]|0,h[k+56>>3]=I*.5+p+ +h[S+16>>3],h[k+64>>3]=+h[S+24>>3],a[k+81>>0]=1,I>g):0)i=I+i;else i=p;Jz(e,c[((c[e>>2]&3|0)==2?e:e+-48|0)+40>>2]|0,L,7,j);e=q;r=r+1|0}l=P;return}function Tz(b,e,f,g,i,j){b=b|0;e=e|0;f=f|0;g=+g;i=+i;j=j|0;var k=0.0,m=0,n=0.0,o=0.0,p=0.0,q=0.0,r=0,s=0.0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0.0,B=0,C=0,D=0.0,E=0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0.0,S=0;Q=l;l=l+16080|0;M=Q+80|0;N=Q+64|0;O=Q+48|0;P=Q+32|0;K=Q+16|0;L=Q;C=c[b+(e<<2)>>2]|0;q=g*.5/+(f|0);q=q>2.0?q:2.0;E=(c[((c[C>>2]&3|0)==3?C:C+48|0)+40>>2]|0)+16|0;m=c[E>>2]|0;H=+h[m+16>>3];D=+h[m+24>>3];C=c[C+16>>2]|0;k=+h[C+16>>3];p=+h[C+24>>3];F=k+H;G=p+D;g=+h[C+56>>3];o=+h[C+64>>3];H=g+H;I=o+D;n=!(F>=H)?-1.0:1.0;s=+h[m+80>>3]*.5;switch(Wz(d[C+49>>0]|0,d[C+89>>0]|0)|0){case 15:{k=(q-g+ +h[m+96>>3])*n;break}case 38:{k=(g+q+ +h[m+88>>3])*n;break}case 41:{k=(q-k+ +h[m+96>>3])*n;break}case 48:{k=(q-k+ +h[m+96>>3])*n;break}case 58:case 57:case 51:case 47:case 37:case 14:{k=n*.3333333333333333*(k-g+ +h[m+88>>3]+ +h[m+96>>3]);break}case 73:{k=(k+q+ +h[m+88>>3])*n;break}case 83:{k=(+h[m+88>>3]+k)*n;break}case 84:{k=((k-g+ +h[m+88>>3]+ +h[m+96>>3])*.5+q)*n;break}case 85:case 75:case 74:{k=((k-g+ +h[m+88>>3]+ +h[m+96>>3])*.5+q*2.0)*n;break}default:k=0.0}p=(s-p)*3.0;o=(s-o)*3.0;q=n*q;w=M+8|0;x=M+16|0;y=M+32|0;z=M+48|0;A=(H+F)*.5;B=M+64|0;C=M+80|0;u=M+96|0;v=M+104|0;t=0;g=s;p=s=(f|0))break;r=e+1|0;e=c[b+(e<<2)>>2]|0;o=g+i;p=p+i;n=n+i;k=k+q;h[M>>3]=F;h[w>>3]=G;s=k+F;Xz(N,s,p*.3333333333333333+G);c[x>>2]=c[N>>2];c[x+4>>2]=c[N+4>>2];c[x+8>>2]=c[N+8>>2];c[x+12>>2]=c[N+12>>2];R=o+D;Xz(O,s,R);c[y>>2]=c[O>>2];c[y+4>>2]=c[O+4>>2];c[y+8>>2]=c[O+8>>2];c[y+12>>2]=c[O+12>>2];Xz(P,A,R);c[z>>2]=c[P>>2];c[z+4>>2]=c[P+4>>2];c[z+8>>2]=c[P+8>>2];c[z+12>>2]=c[P+12>>2];s=H-k;Xz(K,s,R);c[B>>2]=c[K>>2];c[B+4>>2]=c[K+4>>2];c[B+8>>2]=c[K+8>>2];c[B+12>>2]=c[K+12>>2];Xz(L,s,n*.3333333333333333+I);c[C>>2]=c[L>>2];c[C+4>>2]=c[L+4>>2];c[C+8>>2]=c[L+8>>2];c[C+12>>2]=c[L+12>>2];h[u>>3]=H;h[v>>3]=I;m=e+16|0;if((c[(c[m>>2]|0)+96>>2]|0)!=0?(S=(c[(c[(ro(c[((c[e>>2]&3|0)==3?e:e+48|0)+40>>2]|0)|0)+16>>2]|0)+116>>2]&1|0)==0,m=c[(c[m>>2]|0)+96>>2]|0,J=+h[(S?m+32|0:m+24|0)>>3],S=c[E>>2]|0,h[m+64>>3]=J*.5+o+ +h[S+24>>3],h[m+56>>3]=+h[S+16>>3],a[m+81>>0]=1,J>i):0)g=J+g;else g=o;Jz(e,c[((c[e>>2]&3|0)==2?e:e+-48|0)+40>>2]|0,M,7,j);e=r;t=t+1|0}l=Q;return}function Uz(b,e,f,g,i,j){b=b|0;e=e|0;f=f|0;g=+g;i=+i;j=j|0;var k=0,m=0.0,n=0.0,o=0.0,p=0.0,q=0,r=0,s=0,t=0,u=0,v=0.0,w=0,x=0,y=0,z=0.0,A=0,B=0,C=0.0,D=0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0.0,R=0.0,S=0;P=l;l=l+16080|0;L=P+80|0;M=P+64|0;N=P+48|0;O=P+32|0;J=P+16|0;K=P;B=c[b+(e<<2)>>2]|0;n=i*.5/+(f|0);n=n>2.0?n:2.0;D=(c[((c[B>>2]&3|0)==3?B:B+48|0)+40>>2]|0)+16|0;A=c[D>>2]|0;C=+h[A+16>>3];H=+h[A+24>>3];B=c[B+16>>2]|0;m=+h[B+16>>3];E=m+C;F=+h[B+24>>3]+H;i=+h[B+56>>3];G=i+C;H=+h[B+64>>3]+H;k=!(F>=H)?-1:1;p=+h[A+88>>3];switch(Wz(d[B+49>>0]|0,d[B+89>>0]|0)|0){case 67:case 12:{if(F==H)k=0-k|0;break}default:{}}Q=(m+p)*3.0;m=(i+p)*3.0;v=n*+(k|0);u=L+8|0;w=L+16|0;x=L+32|0;y=L+48|0;z=(H+F)*.5;A=L+64|0;B=L+80|0;s=L+96|0;t=L+104|0;r=0;o=0.0;i=p;n=p=(f|0))break;q=e+1|0;e=c[b+(e<<2)>>2]|0;p=i+g;n=n+g;m=m+g;o=o+v;h[L>>3]=E;h[u>>3]=F;Q=o+F;Xz(M,E-n*.3333333333333333,Q);c[w>>2]=c[M>>2];c[w+4>>2]=c[M+4>>2];c[w+8>>2]=c[M+8>>2];c[w+12>>2]=c[M+12>>2];R=C-p;Xz(N,R,Q);c[x>>2]=c[N>>2];c[x+4>>2]=c[N+4>>2];c[x+8>>2]=c[N+8>>2];c[x+12>>2]=c[N+12>>2];Xz(O,R,z);c[y>>2]=c[O>>2];c[y+4>>2]=c[O+4>>2];c[y+8>>2]=c[O+8>>2];c[y+12>>2]=c[O+12>>2];Q=H-o;Xz(J,R,Q);c[A>>2]=c[J>>2];c[A+4>>2]=c[J+4>>2];c[A+8>>2]=c[J+8>>2];c[A+12>>2]=c[J+12>>2];Xz(K,G-m*.3333333333333333,Q);c[B>>2]=c[K>>2];c[B+4>>2]=c[K+4>>2];c[B+8>>2]=c[K+8>>2];c[B+12>>2]=c[K+12>>2];h[s>>3]=G;h[t>>3]=H;k=e+16|0;if((c[(c[k>>2]|0)+96>>2]|0)!=0?(S=(c[(c[(ro(c[((c[e>>2]&3|0)==3?e:e+48|0)+40>>2]|0)|0)+16>>2]|0)+116>>2]&1|0)==0,k=c[(c[k>>2]|0)+96>>2]|0,I=+h[(S?k+24|0:k+32|0)>>3],S=c[D>>2]|0,h[k+56>>3]=I*-.5-p+ +h[S+16>>3],h[k+64>>3]=+h[S+24>>3],a[k+81>>0]=1,I>g):0)i=I+i;else i=p;Jz(e,c[((c[e>>2]&3|0)==2?e:e+-48|0)+40>>2]|0,L,7,j);e=q;r=r+1|0}l=P;return}function Vz(b,e,f,g,i,j){b=b|0;e=e|0;f=f|0;g=+g;i=+i;j=j|0;var k=0.0,m=0.0,n=0.0,o=0.0,p=0,q=0,r=0,s=0,t=0,u=0,v=0.0,w=0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0,D=0,E=0,F=0.0,G=0,H=0,I=0.0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0.0,R=0.0,S=0;P=l;l=l+16080|0;L=P+80|0;M=P+64|0;N=P+48|0;O=P+32|0;J=P+16|0;K=P;C=c[b+(e<<2)>>2]|0;B=g*.5/+(f|0);w=(c[((c[C>>2]&3|0)==3?C:C+48|0)+40>>2]|0)+16|0;D=c[w>>2]|0;z=+h[D+16>>3];v=+h[D+24>>3];C=c[C+16>>2]|0;m=+h[C+24>>3];x=+h[C+16>>3]+z;y=m+v;n=+h[C+64>>3];z=+h[C+56>>3]+z;A=n+v;u=!(x>=z)?-1:1;o=+h[D+80>>3]*.5;C=(Wz(d[C+49>>0]|0,d[C+89>>0]|0)|0)==67;m=(m+o)*3.0;n=(n+o)*3.0;B=(B>2.0?B:2.0)*+((C?0-u|0:u)|0);u=L+8|0;C=L+16|0;D=L+32|0;E=L+48|0;F=(z+x)*.5;G=L+64|0;H=L+80|0;s=L+96|0;t=L+104|0;g=o;k=0.0;m=o=(f|0))break;r=e+1|0;p=c[b+(e<<2)>>2]|0;o=g+i;m=m+i;n=n+i;k=k+B;h[L>>3]=x;h[u>>3]=y;Q=k+x;Xz(M,Q,y-m*.3333333333333333);c[C>>2]=c[M>>2];c[C+4>>2]=c[M+4>>2];c[C+8>>2]=c[M+8>>2];c[C+12>>2]=c[M+12>>2];R=v-o;Xz(N,Q,R);c[D>>2]=c[N>>2];c[D+4>>2]=c[N+4>>2];c[D+8>>2]=c[N+8>>2];c[D+12>>2]=c[N+12>>2];Xz(O,F,R);c[E>>2]=c[O>>2];c[E+4>>2]=c[O+4>>2];c[E+8>>2]=c[O+8>>2];c[E+12>>2]=c[O+12>>2];Q=z-k;Xz(J,Q,R);c[G>>2]=c[J>>2];c[G+4>>2]=c[J+4>>2];c[G+8>>2]=c[J+8>>2];c[G+12>>2]=c[J+12>>2];Xz(K,Q,A-n*.3333333333333333);c[H>>2]=c[K>>2];c[H+4>>2]=c[K+4>>2];c[H+8>>2]=c[K+8>>2];c[H+12>>2]=c[K+12>>2];h[s>>3]=z;h[t>>3]=A;e=p+16|0;if((c[(c[e>>2]|0)+96>>2]|0)!=0?(S=(c[(c[(ro(c[((c[p>>2]&3|0)==3?p:p+48|0)+40>>2]|0)|0)+16>>2]|0)+116>>2]&1|0)==0,e=c[(c[e>>2]|0)+96>>2]|0,I=+h[(S?e+32|0:e+24|0)>>3],S=c[w>>2]|0,h[e+64>>3]=I*-.5-o+ +h[S+24>>3],h[e+56>>3]=+h[S+16>>3],a[e+81>>0]=1,I>i):0)g=I+g;else g=o;Jz(p,c[((c[p>>2]&3|0)==2?p:p+-48|0)+40>>2]|0,L,7,j);e=r;q=q+1|0}l=P;return}function Wz(a,b){a=a|0;b=b|0;var d=0;d=0;while(1){if((d|0)>=8){b=-1;break}if((c[21064+(d<<2)>>2]|0)==(b|0)){b=d;break}d=d+1|0}d=0;while(1){if((d|0)>=8){d=-1;break}if((c[21064+(d<<2)>>2]|0)==(a|0))break;d=d+1|0}if((d|b|0)<0)d=0;else d=c[21096+(d<<5)+(b<<2)>>2]|0;return d|0}function Xz(a,b,c){a=a|0;b=+b;c=+c;h[a>>3]=b;h[a+8>>3]=c;return}function Yz(b){b=b|0;var d=0,e=0;if((c[42247]|0)!=0|(c[42246]|0)!=0){d=b+16|0;e=c[(c[d>>2]|0)+100>>2]|0;if((e|0?(a[e+81>>0]|0)==0:0)?Zz(b,1)|0:0){e=ro(c[((c[b>>2]&3|0)==3?b:b+48|0)+40>>2]|0)|0;bB(e,c[(c[d>>2]|0)+100>>2]|0)}e=c[(c[d>>2]|0)+104>>2]|0;if((e|0?(a[e+81>>0]|0)==0:0)?Zz(b,0)|0:0){e=ro(c[((c[b>>2]&3|0)==3?b:b+48|0)+40>>2]|0)|0;bB(e,c[(c[d>>2]|0)+104>>2]|0)}}return}function Zz(b,d){b=b|0;d=d|0;var e=0,f=0.0,g=0.0,i=0,j=0.0,k=0,m=0,n=0,o=0,p=0,q=0,r=0.0;q=l;l=l+96|0;o=q+32|0;m=q+16|0;n=q;i=b+16|0;do if((a[(c[i>>2]|0)+112>>0]|0)!=6){e=c[42247]|0;if(!((e|0)!=0?(a[(Jm(b,e)|0)>>0]|0)!=0:0)){e=c[42246]|0;if(!e){e=0;break}if(!(a[(Jm(b,e)|0)>>0]|0)){e=0;break}}d=d<<24>>24==0;p=c[i>>2]|0;p=c[(d?p+104|0:p+100|0)>>2]|0;e=_z(b)|0;if(e){k=c[e>>2]|0;do if(d){if(c[k+8>>2]|0){e=c[k>>2]|0;j=+h[e>>3];g=+h[k+16>>3];e=e+8|0;f=+h[k+24>>3];break}e=c[k>>2]|0;g=+h[e>>3];f=+h[e+8>>3];e=0;while(1){if((e|0)==4)break;n=o+(e<<4)|0;i=(c[k>>2]|0)+(e<<4)|0;c[n>>2]=c[i>>2];c[n+4>>2]=c[i+4>>2];c[n+8>>2]=c[i+8>>2];c[n+12>>2]=c[i+12>>2];e=e+1|0}PA(m,o,3,.1,0,0);j=+h[m>>3];e=m+8|0}else{d=(c[e+4>>2]|0)+-1|0;i=k+(d*48|0)|0;if(c[k+(d*48|0)+12>>2]|0){o=c[i>>2]|0;e=(c[k+(d*48|0)+4>>2]|0)+-1|0;j=+h[o+(e<<4)>>3];g=+h[k+(d*48|0)+32>>3];e=o+(e<<4)+8|0;f=+h[k+(d*48|0)+40>>3];break}m=c[i>>2]|0;d=k+(d*48|0)+4|0;e=(c[d>>2]|0)+-1|0;g=+h[m+(e<<4)>>3];f=+h[m+(e<<4)+8>>3];e=0;while(1){if((e|0)==4)break;m=o+(e<<4)|0;k=(c[i>>2]|0)+(e+-4+(c[d>>2]|0)<<4)|0;c[m>>2]=c[k>>2];c[m+4>>2]=c[k+4>>2];c[m+8>>2]=c[k+8>>2];c[m+12>>2]=c[k+12>>2];e=e+1|0}PA(n,o,3,.9,0,0);j=+h[n>>3];e=n+8|0}while(0);r=+K(+(+h[e>>3]-f),+(j-g));r=+EA(b,c[42247]|0,-25.0,-180.0)*.017453292519943295+r;j=+EA(b,c[42246]|0,1.0,0.0)*10.0;h[p+56>>3]=j*+E(+r)+g;h[p+64>>3]=+F(+r)*j+f;a[p+81>>0]=1;e=1}else e=0}else e=0;while(0);l=q;return e|0}function _z(b){b=b|0;var d=0,e=0,f=0,g=0,h=0;h=l;l=l+16|0;f=h;d=b;while(1){e=c[d+16>>2]|0;d=c[e+8>>2]|0;if(d|0)break;if(!(a[e+112>>0]|0)){g=5;break}d=c[e+116>>2]|0}if((g|0)==5){g=Dn(c[((c[b>>2]&3|0)==3?b:b+48|0)+40>>2]|0)|0;d=Dn(c[((c[b>>2]&3|0)==2?b:b+-48|0)+40>>2]|0)|0;c[f>>2]=g;c[f+4>>2]=d;_l(1,91623,f)|0;d=0}l=h;return d|0}function $z(a,d,e){a=a|0;d=d|0;e=e|0;var f=0.0,g=0.0,i=0.0,j=0.0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0.0,u=0.0;s=l;l=l+96|0;m=s+80|0;n=s+64|0;o=s+48|0;p=s+32|0;q=s+16|0;r=s;k=b[(c[d+16>>2]|0)+136>>1]|0;d=e+16|0;aA(c[(c[d>>2]|0)+8>>2]|0,p,q);f=+h[p>>3];g=+h[q>>3];t=f-g;i=+h[p+8>>3];j=+h[q+8>>3];u=i-j;a:do if(u*u+t*t<1.0e-06){c[o>>2]=c[p>>2];c[o+4>>2]=c[p+4>>2];c[o+8>>2]=c[p+8>>2];c[o+12>>2]=c[p+12>>2]}else switch(k&14){case 4:case 10:{h[n>>3]=(g+f)*.5;h[n+8>>3]=(j+i)*.5;q=c[(c[d>>2]|0)+8>>2]|0;c[m>>2]=c[n>>2];c[m+4>>2]=c[n+4>>2];c[m+8>>2]=c[n+8>>2];c[m+12>>2]=c[n+12>>2];VA(r,q,m);c[o>>2]=c[r>>2];c[o+4>>2]=c[r+4>>2];c[o+8>>2]=c[r+8>>2];c[o+12>>2]=c[r+12>>2];break a}default:{bA(o,c[(c[d>>2]|0)+8>>2]|0,p,q);break a}}while(0);c[a>>2]=c[o>>2];c[a+4>>2]=c[o+4>>2];c[a+8>>2]=c[o+8>>2];c[a+12>>2]=c[o+12>>2];l=s;return}function aA(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0;h=l;l=l+32|0;g=h+16|0;f=h;j=c[a>>2]|0;e=c[j>>2]|0;i=c[j+8>>2]|0;k=j+16|0;c[g>>2]=c[k>>2];c[g+4>>2]=c[k+4>>2];c[g+8>>2]=c[k+8>>2];c[g+12>>2]=c[k+12>>2];j=j+32|0;c[f>>2]=c[j>>2];c[f+4>>2]=c[j+4>>2];c[f+8>>2]=c[j+8>>2];c[f+12>>2]=c[j+12>>2];if(!i){c[b>>2]=c[e>>2];c[b+4>>2]=c[e+4>>2];c[b+8>>2]=c[e+8>>2];c[b+12>>2]=c[e+12>>2]}else{c[b>>2]=c[g>>2];c[b+4>>2]=c[g+4>>2];c[b+8>>2]=c[g+8>>2];c[b+12>>2]=c[g+12>>2]}i=c[a>>2]|0;j=(c[a+4>>2]|0)+-1|0;e=c[i+(j*48|0)>>2]|0;a=c[i+(j*48|0)+4>>2]|0;k=c[i+(j*48|0)+12>>2]|0;b=i+(j*48|0)+16|0;c[g>>2]=c[b>>2];c[g+4>>2]=c[b+4>>2];c[g+8>>2]=c[b+8>>2];c[g+12>>2]=c[b+12>>2];j=i+(j*48|0)+32|0;c[f>>2]=c[j>>2];c[f+4>>2]=c[j+4>>2];c[f+8>>2]=c[j+8>>2];c[f+12>>2]=c[j+12>>2];if(!k){k=e+(a+-1<<4)|0;c[d>>2]=c[k>>2];c[d+4>>2]=c[k+4>>2];c[d+8>>2]=c[k+8>>2];c[d+12>>2]=c[k+12>>2]}else{c[d>>2]=c[f>>2];c[d+4>>2]=c[f+4>>2];c[d+8>>2]=c[f+8>>2];c[d+12>>2]=c[f+12>>2]}l=h;return}function bA(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0.0,i=0,j=0,k=0,l=0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0,s=0.0;r=c[b+4>>2]|0;g=0.0;f=0;while(1){if((f|0)>=(r|0))break;l=c[b>>2]|0;k=c[l+(f*48|0)>>2]|0;l=c[l+(f*48|0)+4>>2]|0;i=3;j=0;while(1){if((i|0)>=(l|0))break;q=+h[k+(j<<4)>>3]-+h[k+(i<<4)>>3];p=+h[k+(j<<4)+8>>3]-+h[k+(i<<4)+8>>3];i=i+3|0;j=j+3|0;g=+C(+(p*p+q*q))+g}f=f+1|0}l=0;g=g*.5;a:while(1){if((l|0)>=(r|0)){f=15;break}k=c[b>>2]|0;j=c[k+(l*48|0)>>2]|0;k=c[k+(l*48|0)+4>>2]|0;f=3;i=0;while(1){if((f|0)>=(k|0))break;m=+h[j+(i<<4)>>3];p=+h[j+(i<<4)+8>>3];n=+h[j+(f<<4)>>3];o=+h[j+(f<<4)+8>>3];q=m-n;s=p-o;q=+C(+(s*s+q*q));if(q>=g){f=12;break a}f=f+3|0;i=i+3|0;g=g-q}l=l+1|0}if((f|0)==12){h[d>>3]=m;h[d+8>>3]=p;h[e>>3]=n;h[e+8>>3]=o;s=q-g;h[a>>3]=(s*m+n*g)/q;h[a+8>>3]=(s*p+o*g)/q;return}else if((f|0)==15)ma(123523,91558,1316,91685)}function cA(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Yz(b);return}function dA(b,d,e,f,g){b=b|0;d=d|0;e=+e;f=f|0;g=g|0;var i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0,o=0,p=0.0,q=0.0,r=0.0,s=0,t=0.0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0.0,C=0.0,D=0,G=0,H=0,I=0,J=0,K=0,L=0;J=eA(b)|0;I=c[J+4>>2]|0;K=c[J>>2]|0;H=I+-1|0;B=+h[K+(H<<6)+16>>3];C=+(I|0);D=(g|0)==2;G=(f|0)!=0;n=0;j=0.0;i=0.0;l=0.0;m=0.0;while(1){if((n|0)>=(I|0))break;b=~~+fA(+(n+-1|0),C);A=n+1|0;L=~~+fA(+(A|0),C);o=K+(n<<6)|0;m=+h[o>>3];z=K+(n<<6)+8|0;l=+h[z>>3];s=K+(n<<6)+16|0;t=+h[s>>3];u=K+(n<<6)+24|0;v=K+(n<<6)+32|0;w=K+(n<<6)+40|0;x=K+(n<<6)+48|0;y=K+(n<<6)+56|0;k=+gA(+h[K+(L<<6)+8>>3]-l,+h[K+(L<<6)>>3]-m);q=+gA(+h[K+(b<<6)+8>>3]-l,+h[K+(b<<6)>>3]-m);r=+Za[d&7](t,B,e);b=(n|0)==0;do if(b|(n|0)==(H|0))if(b){i=k+1.5707963267948966;if(!D){b=0;p=i;j=r;break}b=0;p=i;j=r;l=l-+F(+k)*r;m=m-+E(+k)*r;break}else{i=q+-1.5707963267948966;if(!D){b=0;p=i;j=r;break}b=0;p=i;j=r;l=l-+F(+q)*r;m=m-+E(+q)*r;break}else{p=k-q;p=1.5707963267948966-(p<0.0?p+6.283185307179586:p)*.5;j=+E(+p);j=j==0.0?0.0:r/j;i=k+1.5707963267948966;k=p+i;if(G|j>r*10.0){q=+fA(q+-1.5707963267948966,6.283185307179586);b=1;p=+fA(i,6.283185307179586);j=r;i=q}else{b=0;p=k;i=k}}while(0);h[o>>3]=m;h[z>>3]=l;h[s>>3]=t;a[u>>0]=108;h[v>>3]=i;h[w>>3]=j;c[x>>2]=b;h[y>>3]=p;n=A}o=vw(12)|0;b=0;while(1){if((b|0)>=(I|0))break;m=+h[K+(b<<6)>>3];l=+h[K+(b<<6)+8>>3];i=+h[K+(b<<6)+32>>3];j=+h[K+(b<<6)+40>>3];L=c[K+(b<<6)+48>>2]|0;k=+h[K+(b<<6)+56>>3];hA(o,+E(+i)*j+m,+F(+i)*j+l);if(L|0)iA(m,l,j,1,i,k,f,o);b=b+1|0}n=(g|0)==1;k=i+3.141592653589793;if(n)jA(o,m,l,j,i,k);else{hA(o,+E(+k)*j+m,+F(+k)*j+l);i=k}b=I+-2|0;k=m;while(1){if((b|0)<=-1)break;m=+h[K+(b<<6)>>3];l=+h[K+(b<<6)+8>>3];j=+h[K+(b<<6)+40>>3];L=c[K+(b<<6)+48>>2]|0;i=+h[K+(b<<6)+32>>3]+3.141592653589793;k=+h[K+(b<<6)+56>>3]+3.141592653589793;hA(o,+E(+k)*j+m,+F(+k)*j+l);if(L|0)iA(m,l,j,0,i,k,f,o);b=b+-1|0;k=m}if(n)jA(o,k,l,j,i,i+3.141592653589793);kA(J);return o|0}function eA(a){a=a|0;var b=0.0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0.0;q=l;l=l+144|0;i=q+128|0;h=q+112|0;j=q+96|0;k=q+64|0;m=q;n=q+80|0;o=lA()|0;p=c[a+4>>2]|0;f=c[a>>2]|0;c[i>>2]=c[f>>2];c[i+4>>2]=c[f+4>>2];c[i+8>>2]=c[f+8>>2];c[i+12>>2]=c[f+12>>2];mA(o,i,0.0);g=m+48|0;c[g>>2]=c[f>>2];c[g+4>>2]=c[f+4>>2];c[g+8>>2]=c[f+8>>2];c[g+12>>2]=c[f+12>>2];d=0;b=0.0;a:while(1){e=d+3|0;if((e|0)>=(p|0))break;c[m>>2]=c[g>>2];c[m+4>>2]=c[g+4>>2];c[m+8>>2]=c[g+8>>2];c[m+12>>2]=c[g+12>>2];a=1;while(1){if((a|0)==4)break;r=m+(a<<4)|0;s=f+(a+d<<4)|0;c[r>>2]=c[s>>2];c[r+4>>2]=c[s+4>>2];c[r+8>>2]=c[s+8>>2];c[r+12>>2]=c[s+12>>2];a=a+1|0}c[j>>2]=c[m>>2];c[j+4>>2]=c[m+4>>2];c[j+8>>2]=c[m+8>>2];c[j+12>>2]=c[m+12>>2];a=1;while(1){if((a|0)==21){d=e;continue a}PA(n,m,3,+(a|0)*.05,0,0);c[k>>2]=c[n>>2];c[k+4>>2]=c[n+4>>2];c[k+8>>2]=c[n+8>>2];c[k+12>>2]=c[n+12>>2];c[h>>2]=c[j>>2];c[h+4>>2]=c[j+4>>2];c[h+8>>2]=c[j+8>>2];c[h+12>>2]=c[j+12>>2];c[i>>2]=c[n>>2];c[i+4>>2]=c[n+4>>2];c[i+8>>2]=c[n+8>>2];c[i+12>>2]=c[n+12>>2];t=+nA(h,i)+b;c[i>>2]=c[k>>2];c[i+4>>2]=c[k+4>>2];c[i+8>>2]=c[k+8>>2];c[i+12>>2]=c[k+12>>2];mA(o,i,t);c[j>>2]=c[k>>2];c[j+4>>2]=c[k+4>>2];c[j+8>>2]=c[k+8>>2];c[j+12>>2]=c[k+12>>2];a=a+1|0;b=t}}oA(o);l=q;return o|0}function fA(a,b){a=+a;b=+b;var c=0.0;c=a-+A(+(a/b))*b;return +(!(a<0.0)&!(a>=b)?a:c)}function gA(a,b){a=+a;b=+b;if(!(a==0.0&b==0.0)){a=+K(+a,+b);if(!(a>=0.0))a=a+6.283185307179586}else a=0.0;return +a}function hA(a,b,d){a=a|0;b=+b;d=+d;var e=0,f=0;e=c[a>>2]|0;f=a+4|0;if((e|0)<(c[f>>2]|0))f=c[a+8>>2]|0;else{c[f>>2]=2e3;e=a+8|0;f=yw(c[e>>2]|0,32e3)|0;c[e>>2]=f;e=c[a>>2]|0}c[a>>2]=e+1;h[f+(e<<4)>>3]=b;h[f+(e<<4)+8>>3]=d;return}function iA(a,b,c,d,e,f,g,h){a=+a;b=+b;c=+c;d=d|0;e=+e;f=+f;g=g|0;h=h|0;var i=0.0;d=(d|0)==0;i=d?e:f;do if((g|0)==1){e=(d?f:e)-i;e=!(e<=1.7453292519943296e-03)?e:e+6.283185307179586;if(e<3.141592653589793){jA(h,a,b,c,e+i,i);break}else{hA(h,+E(+i)*c+a,+F(+i)*c+a);break}}else hA(h,+E(+i)*c+a,+F(+i)*c+a);while(0);return}function jA(a,b,c,d,e,f){a=a|0;b=+b;c=+c;d=+d;e=+e;f=+f;var g=0,h=0.0;hA(a,+E(+e)*d+b,+F(+e)*d+c);a:do if(!(d==0.0)){while(1){if(!(f>e))break;f=f+-6.283185307179586}f=e-f;while(1){if(!(f>6.283185307179586))break;f=f+-6.283185307179586}f=f*.05263157894736842;g=1;while(1){if((g|0)==20)break a;h=e-f*+(g|0);hA(a,+E(+h)*d+b,+F(+h)*d+c);g=g+1|0}}while(0);return}function kA(a){a=a|0;_I(c[a>>2]|0);_I(a);return}function lA(){var a=0;a=vw(12)|0;c[a+4>>2]=0;c[a+8>>2]=2e3;c[a>>2]=vw(128e3)|0;return a|0}function mA(a,b,d){a=a|0;b=b|0;d=+d;var e=0,f=0,g=0,i=0;i=a+4|0;e=c[i>>2]|0;f=a+8|0;g=c[f>>2]|0;if((e|0)<(g|0))a=c[a>>2]|0;else{c[f>>2]=g<<1;e=yw(c[a>>2]|0,g<<7)|0;c[a>>2]=e;a=e;e=c[i>>2]|0}h[a+(e<<6)>>3]=+h[b>>3];h[a+(e<<6)+8>>3]=+h[b+8>>3];c[i>>2]=e+1;h[a+(e<<6)+16>>3]=d;return}function nA(a,b){a=a|0;b=b|0;var c=0.0,d=0.0;c=+h[a>>3]-+h[b>>3];d=+h[a+8>>3]-+h[b+8>>3];return +(+C(+(d*d+c*c)))}function oA(a){a=a|0;var b=0;b=c[a+4>>2]|0;if((c[a+8>>2]|0)>(b|0))c[a>>2]=yw(c[a>>2]|0,b<<6)|0;return}function pA(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0;k=l;l=l+16|0;j=k+8|0;i=k;g=k+12|0;c[g>>2]=0;h=c[d+4>>2]|0;if(!h)ma(91702,91713,203,91724);e=c[h>>2]|0;if(!e)ma(91738,91713,206,91724);f=h+8|0;if(!(c[f>>2]|0))c[f>>2]=qA(e)|0;if(!0)e=0;else{e=(Dv(c[h>>2]|0)|0)==0;e=e?0:g}if(!((vE(b,d,e)|0)<<24>>24))rA(d,e);do if(e|0){f=c[g>>2]|0;b=c[13918]|0;e=c[h>>2]|0;if(!f){c[j>>2]=e;zL(b,91781,j)|0;break}else{c[i>>2]=e;c[i+4>>2]=f;zL(b,91749,i)|0;break}}while(0);j=d+32|0;c[a>>2]=c[j>>2];c[a+4>>2]=c[j+4>>2];c[a+8>>2]=c[j+8>>2];c[a+12>>2]=c[j+12>>2];l=k;return}function qA(a){a=a|0;var b=0;b=c[42345]|0;if((b|0)!=0?(iK(b,a)|0)==0:0)a=c[42354]|0;else{_I(b);c[42345]=GL(a)|0;a=vM(169380,21352,35,36,29)|0;c[42354]=a}return a|0}function rA(b,d){b=b|0;d=d|0;var e=0,f=0.0,g=0,i=0.0,j=0,k=0.0;j=c[b+4>>2]|0;e=c[j>>2]|0;i=+h[j+16>>3];j=b+32|0;h[j>>3]=0.0;h[b+40>>3]=i*1.2;h[b+16>>3]=0.0;h[b+24>>3]=i*.1;c[b+8>>2]=0;c[b+12>>2]=0;if(pK(e,91815,4)|0)if((pK(e,91820,5)|0)!=0?(pK(e,91826,9)|0)!=0:0){g=4184;e=91836}else{g=8280;e=91872}else{g=6232;e=91853}if(d|0)c[d>>2]=e;e=c[b>>2]|0;if(e|0){f=0.0;while(1){b=a[e>>0]|0;if(!(b<<24>>24))break;k=f+ +h[g+((b&255)<<3)>>3];h[j>>3]=k;e=e+1|0;f=k}h[j>>3]=f*i}return}function sA(a,b){a=a|0;b=b|0;return iK(c[a>>2]|0,c[b>>2]|0)|0}function tA(a){a=a|0;var b=0;b=a+108|0;c[b>>2]=0;c[a+112>>2]=32;c[a+116>>2]=-1;c[a+120>>2]=14;c[a+124>>2]=58;c[a+128>>2]=20;c[a+132>>2]=0;c[a+136>>2]=0;c[a+140>>2]=0;b=Ql(b,c[4345]|0)|0;c[a+144>>2]=b;return b|0}function uA(a,b,d){a=a|0;b=b|0;d=d|0;d=$I(1,32)|0;a=c[b>>2]|0;if(a|0)c[d>>2]=GL(a)|0;a=c[b+4>>2]|0;if(a|0)c[d+4>>2]=GL(a)|0;c[d+24>>2]=c[b+24>>2]&127;h[d+16>>3]=+h[b+16>>3];c[d+8>>2]=c[b+8>>2];return d|0}function vA(a,b,d){a=a|0;b=b|0;d=d|0;_I(c[b>>2]|0);_I(c[b+4>>2]|0);_I(b);return}function wA(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,g=0.0,i=0,j=0;a=c[b>>2]|0;e=c[d>>2]|0;i=(e|0)==0;if(!a)if(i)j=5;else a=-1;else if(!i){a=xJ(a,e)|0;if(!a)j=5}else a=1;do if((j|0)==5){a=c[b+4>>2]|0;e=c[d+4>>2]|0;i=(e|0)==0;if(!a){if(!i){a=-1;break}}else{if(i){a=1;break}a=xJ(a,e)|0;if(a|0)break}a=(c[b+24>>2]&127)-(c[d+24>>2]&127)|0;if(!a){g=+h[b+16>>3];f=+h[d+16>>3];if(gf&1}}while(0);return a|0}function xA(){Wa(169420)|0;return}function yA(){var a=0,b=0;b=l;l=l+16|0;a=b;Wa(a|0)|0;l=b;return +(+((c[a+4>>2]|0)+(c[a>>2]|0)-(c[42355]|0)-(c[42356]|0)|0)*.016666666666666666)}function zA(a){a=a|0;var b=0,d=0;b=vw(16)|0;a=(a|0)>2?a:2;d=vw(a<<2)|0;c[b>>2]=d;c[b+12>>2]=d;c[b+8>>2]=d;c[b+4>>2]=d+(a<<2);return b|0}function AA(a){a=a|0;_I(c[a>>2]|0);_I(a);return}function BA(a,b){a=a|0;b=b|0;var d=0,e=0;d=a+12|0;e=c[d>>2]|0;c[d>>2]=e+4;c[e>>2]=b;if((c[d>>2]|0)>>>0>=(c[a+4>>2]|0)>>>0)c[d>>2]=c[a>>2];return}function CA(a){a=a|0;var b=0,d=0,e=0;d=a+8|0;b=c[d>>2]|0;if((b|0)!=(c[a+12>>2]|0)){e=b+4|0;c[d>>2]=e;b=c[b>>2]|0;if(e>>>0>=(c[a+4>>2]|0)>>>0)c[d>>2]=c[a>>2]}else b=0;return b|0}function DA(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0;i=l;l=l+16|0;g=i;if(((d|0)!=0?(h=Jm(b,d)|0,(h|0)!=0):0)?(a[h>>0]|0)!=0:0){d=BL(h,g,10)|0;e=(h|0)==(c[g>>2]|0)?e:(d|0)<(f|0)?f:d}l=i;return e|0}function EA(b,d,e,f){b=b|0;d=d|0;e=+e;f=+f;var g=0,h=0,i=0,j=0.0;i=l;l=l+16|0;g=i;if(((b|0)!=0&(d|0)!=0?(h=Jm(b,d)|0,(h|0)!=0):0)?(a[h>>0]|0)!=0:0){j=+tM(h,g);e=(h|0)==(c[g>>2]|0)?e:j>0]|0)!=0:0)d=b;return d|0}function HA(a,b,c){a=a|0;b=b|0;c=c|0;if(!b)a=c&255;else a=IA(Jm(a,b)|0)|0;return a|0}function IA(a){a=a|0;return JA(a,0)|0}function JA(b,c){b=b|0;c=c|0;var d=0;if((b|0)!=0?(d=a[b>>0]|0,d<<24>>24!=0):0)if((iK(b,122100)|0)!=0?(iK(b,92682)|0)!=0:0)if((iK(b,92685)|0)!=0?(iK(b,92690)|0)!=0:0){if(((d<<24>>24)+-48|0)>>>0<10)c=(rM(b)|0)&255}else c=1;else c=0;return c|0}function KA(a){a=a|0;var b=0,d=0;while(1){b=(c[a+16>>2]|0)+220|0;d=c[b>>2]|0;if(!((d|0)!=(a|0)&(d|0)!=0))break;a=c[(c[d+16>>2]|0)+220>>2]|0;if(!a){a=d;continue}c[b>>2]=a}return a|0}function LA(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;if((a|0)!=(b|0)){d=c[a+16>>2]|0;e=d+220|0;if(!(c[e>>2]|0)){c[e>>2]=a;c[d+216>>2]=1}else a=KA(a)|0;d=c[b+16>>2]|0;e=d+220|0;if(!(c[e>>2]|0)){c[e>>2]=b;c[d+216>>2]=1}else{d=KA(b)|0;b=d;d=c[d+16>>2]|0}g=a+16|0;e=c[g>>2]|0;f=b+16|0;h=(c[e+120>>2]|0)>(c[d+120>>2]|0);a=h?b:a;c[(h?e:d)+220>>2]=a;e=(c[(h?f:g)>>2]|0)+216|0;c[e>>2]=(c[e>>2]|0)+(c[(c[(h?g:f)>>2]|0)+216>>2]|0)}return a|0}function MA(b){b=b|0;b=c[b+16>>2]|0;c[b+216>>2]=1;c[b+220>>2]=0;a[b+159>>0]=0;return}function NA(a,b){a=a|0;b=b|0;if((KA(a)|0)==(a|0)){a=c[a+16>>2]|0;c[a+220>>2]=b;b=(c[b+16>>2]|0)+216|0;c[b>>2]=(c[b>>2]|0)+(c[a+216>>2]|0);return}else ma(92702,92694,194,92718)}function OA(a,b){a=a|0;b=b|0;var d=0.0;b=c[(c[b+16>>2]|0)+132>>2]|0;d=+h[b+8>>3]*72.0;h[a>>3]=+h[b>>3]*72.0;h[a+8>>3]=d;return}function PA(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=+e;f=f|0;g=g|0;var i=0,j=0,k=0,m=0.0,n=0,o=0,p=0;o=l;l=l+576|0;n=o;i=0;while(1){if((i|0)>(d|0))break;k=n+(i<<4)|0;j=b+(i<<4)|0;c[k>>2]=c[j>>2];c[k+4>>2]=c[j+4>>2];c[k+8>>2]=c[j+8>>2];c[k+12>>2]=c[j+12>>2];i=i+1|0}m=1.0-e;i=1;while(1){if((i|0)>(d|0))break;j=d-i|0;k=i+-1|0;b=0;while(1){if((b|0)>(j|0))break;p=b+1|0;h[n+(i*96|0)+(b<<4)>>3]=+h[n+(k*96|0)+(p<<4)>>3]*e+ +h[n+(k*96|0)+(b<<4)>>3]*m;h[n+(i*96|0)+(b<<4)+8>>3]=+h[n+(k*96|0)+(p<<4)+8>>3]*e+ +h[n+(k*96|0)+(b<<4)+8>>3]*m;b=p}i=i+1|0}a:do if(f|0){i=0;while(1){if((i|0)>(d|0))break a;p=f+(i<<4)|0;k=n+(i*96|0)|0;c[p>>2]=c[k>>2];c[p+4>>2]=c[k+4>>2];c[p+8>>2]=c[k+8>>2];c[p+12>>2]=c[k+12>>2];i=i+1|0}}while(0);b:do if(g|0){i=0;while(1){if((i|0)>(d|0))break b;p=g+(i<<4)|0;f=n+((d-i|0)*96|0)+(i<<4)|0;c[p>>2]=c[f>>2];c[p+4>>2]=c[f+4>>2];c[p+8>>2]=c[f+8>>2];c[p+12>>2]=c[f+12>>2];i=i+1|0}}while(0);p=n+(d*96|0)|0;c[a>>2]=c[p>>2];c[a+4>>2]=c[p+4>>2];c[a+8>>2]=c[p+8>>2];c[a+12>>2]=c[p+12>>2];l=o;return}function QA(b){b=b|0;var d=0,e=0,f=0,g=0;e=0;do{d=c[42359]|0;f=d+1024|0;if((d-e|0)<1024){c[42359]=f;f=yw(c[42360]|0,f)|0;c[42360]=f;d=c[42359]|0}else f=c[42360]|0;d=gL(f+e|0,d-e|0,b)|0;if(!d){g=6;break}e=(rJ(d)|0)+e|0;d=c[42360]|0}while((a[d+(e+-1)>>0]|0)!=10);if((g|0)==6)d=c[42360]|0;return ((e|0)>0?d:0)|0}function RA(b){b=b|0;var d=0,e=0,f=0;f=l;l=l+16|0;do if((b|0)!=0?(a[b>>0]|0)!=0:0)if(!0){d=c[42178]|0;e=c[42362]|0;if((c[42361]|0)==(d|0))d=e;else{if(e){_I(c[e>>2]|0);_I(c[42362]|0);c[42362]=0;d=c[42178]|0}c[42361]=d;if(!d)break;if(!(a[d>>0]|0))break;d=SA(d)|0;c[42362]=d}if(!((a[b>>0]|0)!=47&(d|0)!=0))break;b=TA(d,c[42363]|0,b)|0;break}else S();else b=0;while(0);l=f;return b|0}function SA(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;e=0;f=0;g=0;b=GL(a)|0;d=0;while(1){b=DL(b,93017)|0;if(!b)break;a=(g<<2)+8|0;if(!f)a=ww(a)|0;else a=yw(d,a)|0;c[a+(g<<2)>>2]=b;f=rJ(b)|0;e=e>>>0>f>>>0?e:f;f=a;g=g+1|0;b=0;d=a}c[f+(g<<2)>>2]=0;c[42363]=e;return f|0}function TA(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0;g=l;l=l+16|0;e=g;h=c[42364]|0;c[42364]=aJ(h,b+2+(rJ(d)|0)|0)|0;while(1){b=c[a>>2]|0;if(!b){a=0;break}h=c[42364]|0;c[e>>2]=b;c[e+4>>2]=93015;c[e+8>>2]=d;pL(h,93008,e)|0;if(!($L(c[42364]|0,4)|0)){f=4;break}else a=a+4|0}if((f|0)==4)a=c[42364]|0;l=g;return a|0}function UA(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;g=(b|0)==0;f=0;while(1){h=c[d+(f<<2)>>2]|0;if(!h)break;if((!g?(a[b>>0]|0)==(a[h>>0]|0):0)?(xJ(b,h)|0)==0:0)break;f=f+1|0}return c[e+(f<<2)>>2]|0}function VA(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0.0,i=0.0,j=0.0,k=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,C=0;z=l;l=l+80|0;x=z+16|0;y=z;u=c[b+4>>2]|0;v=c[b>>2]|0;w=d+8|0;f=0;e=-1;g=1.e+38;b=-1;while(1){if((f|0)>=(u|0))break;s=c[v+(f*48|0)>>2]|0;t=c[v+(f*48|0)+4>>2]|0;r=0;while(1){if((r|0)>=(t|0))break;q=+h[s+(r<<4)>>3]-+h[d>>3];p=+h[s+(r<<4)+8>>3]-+h[w>>3];q=p*p+q*q;A=(e|0)==-1|q>2]|0;e=e+(((e|0)==((c[v+(b*48|0)+4>>2]|0)+-1|0))<<31>>31)|0;e=e-((e|0)%3|0)|0;b=0;while(1){if((b|0)==4)break;C=b+e|0;h[x+(b<<4)>>3]=+h[f+(C<<4)>>3];h[x+(b<<4)+8>>3]=+h[f+(C<<4)+8>>3];b=b+1|0}q=+h[d>>3];k=+h[x>>3]-q;o=+h[w>>3];p=+h[x+8>>3]-o;j=+h[x+48>>3]-q;n=+h[x+56>>3]-o;b=y+8|0;g=1.0;i=0.0;j=n*n+j*j;k=p*p+k*k;while(1){p=(g+i)*.5;PA(y,x,3,p,0,0);m=+h[y>>3];n=+h[b>>3];if(+B(+(k-j))<1.0)break;if(+B(+(g-i))<1.0e-05)break;C=k>3]=m;h[a+8>>3]=n;l=z;return}function WA(b){b=b|0;var d=0.0,e=0,f=0,g=0,i=0,j=0,k=0,l=0;d=+EA(b,c[42190]|0,.75,.01);g=b+16|0;h[(c[g>>2]|0)+32>>3]=d;d=+EA(b,c[42189]|0,.5,.02);h[(c[g>>2]|0)+40>>3]=d;l=Qy(GA(b,c[42191]|0,93019)|0,b)|0;c[(c[g>>2]|0)+8>>2]=l;l=Jm(b,c[42198]|0)|0;d=+EA(b,c[42194]|0,14.0,1.0);e=GA(b,c[42195]|0,93027)|0;f=GA(b,c[42196]|0,122106)|0;i=(cp(l)|0)!=0;k=(By(b)|0)==2;i=lw(b,l,(k?4:0)|(i?2:0),d,e,f)|0;c[(c[g>>2]|0)+104>>2]=i;i=c[42199]|0;if((i|0?(j=Jm(b,i)|0,j|0):0)?a[j>>0]|0:0){l=(cp(j)|0)!=0;l=lw(b,j,l?2:0,d,e,f)|0;c[(c[g>>2]|0)+108>>2]=l;l=(c[(ro(b)|0)+16>>2]|0)+113|0;a[l>>0]=a[l>>0]|16}k=(DA(b,c[42202]|0,0,0)|0)&255;l=c[g>>2]|0;a[l+144>>0]=k;gb[c[c[(c[l+8>>2]|0)+4>>2]>>2]&127](b);return}function XA(b){b=b|0;var d=0,e=0,f=0,g=0,i=0.0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;v=l;l=l+112|0;m=v+96|0;n=v+80|0;s=v+40|0;u=v;r=b+48|0;p=ro(c[((c[b>>2]&3|0)==3?b:r)+40>>2]|0)|0;g=m+8|0;c[g>>2]=0;o=n+8|0;c[o>>2]=0;d=c[42226]|0;if(((d|0)!=0?(e=Jm(b,d)|0,(e|0)!=0):0)?(a[e>>0]|0)!=0:0){YA(b,m);t=(cp(e)|0)!=0;i=+h[m>>3];f=c[g>>2]|0;d=c[m+12>>2]|0;e=lw(b,e,t?2:0,i,f,d)|0;t=b+16|0;c[(c[t>>2]|0)+96>>2]=e;e=(c[p+16>>2]|0)+113|0;a[e>>0]=a[e>>0]|1;e=IA(FA(b,c[42236]|0,122100)|0)|0;a[(c[t>>2]|0)+114>>0]=e;t=1;e=f}else{t=0;d=0;i=0.0;e=0}f=c[42227]|0;if((f|0?(j=Jm(b,f)|0,j|0):0)?a[j>>0]|0:0){if(!e){YA(b,m);i=+h[m>>3];e=c[g>>2]|0;d=c[m+12>>2]|0}g=(cp(j)|0)!=0;j=lw(b,j,g?2:0,i,e,d)|0;c[(c[b+16>>2]|0)+108>>2]=j;j=(c[p+16>>2]|0)+113|0;a[j>>0]=a[j>>0]|32}d=c[42241]|0;if(((d|0)!=0?(k=Jm(b,d)|0,(k|0)!=0):0)?(a[k>>0]|0)!=0:0){ZA(b,m,n);j=(cp(k)|0)!=0;i=+h[n>>3];d=c[o>>2]|0;e=c[n+12>>2]|0;k=lw(b,k,j?2:0,i,d,e)|0;c[(c[b+16>>2]|0)+100>>2]=k;k=(c[p+16>>2]|0)+113|0;a[k>>0]=a[k>>0]|2}else{e=0;i=0.0;d=0}f=c[42242]|0;if((f|0?(q=Jm(b,f)|0,q|0):0)?a[q>>0]|0:0){if(!d){ZA(b,m,n);e=c[n+12>>2]|0;i=+h[n>>3];d=c[o>>2]|0}o=(cp(q)|0)!=0;q=lw(b,q,o?2:0,i,d,e)|0;c[(c[b+16>>2]|0)+104>>2]=q;q=(c[p+16>>2]|0)+113|0;a[q>>0]=a[q>>0]|4}d=Im(b,96242)|0;d=d|0?d:174181;if(a[d>>0]|0)a[(c[(c[((c[b>>2]&3|0)==3?b:r)+40>>2]|0)+16>>2]|0)+145>>0]=1;g=b+16|0;f=(c[g>>2]|0)+16|0;e=c[((c[b>>2]&3|0)==3?b:r)+40>>2]|0;_A(s,c[(c[(c[(c[e+16>>2]|0)+8>>2]|0)+4>>2]|0)+8>>2]|0,e,d);d=s;e=f+40|0;do{c[f>>2]=c[d>>2];f=f+4|0;d=d+4|0}while((f|0)<(e|0));if(($A(b,c[42248]|0)|0)<<24>>24)a[(c[g>>2]|0)+46>>0]=0;d=Im(b,96251)|0;d=d|0?d:174181;if(!(a[d>>0]|0))e=b+-48|0;else{e=b+-48|0;a[(c[(c[((c[b>>2]&3|0)==2?b:e)+40>>2]|0)+16>>2]|0)+145>>0]=1}f=(c[g>>2]|0)+56|0;e=c[((c[b>>2]&3|0)==2?b:e)+40>>2]|0;_A(u,c[(c[(c[(c[e+16>>2]|0)+8>>2]|0)+4>>2]|0)+8>>2]|0,e,d);d=u;e=f+40|0;do{c[f>>2]=c[d>>2];f=f+4|0;d=d+4|0}while((f|0)<(e|0));if(($A(b,c[42249]|0)|0)<<24>>24)a[(c[g>>2]|0)+86>>0]=0;l=v;return t|0}function YA(a,b){a=a|0;b=b|0;h[b>>3]=+EA(a,c[42223]|0,14.0,1.0);c[b+8>>2]=GA(a,c[42224]|0,93027)|0;c[b+12>>2]=GA(a,c[42225]|0,122106)|0;return}function ZA(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=b+8|0;if(!(c[e>>2]|0))YA(a,b);h[d>>3]=+EA(a,c[42243]|0,+h[b>>3],1.0);c[d+8>>2]=GA(a,c[42244]|0,c[e>>2]|0)|0;c[d+12>>2]=GA(a,c[42245]|0,c[b+12>>2]|0)|0;return}function _A(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,m=0;m=l;l=l+128|0;k=m+80|0;h=m+40|0;g=m;if((f|0)!=0?(j=WJ(f,58)|0,(j|0)!=0):0){a[j>>0]=0;i=j+1|0;kb[d&31](h,e,f,i);e=k;g=h;d=e+36|0;do{c[e>>2]=c[g>>2];e=e+4|0;g=g+4|0}while((e|0)<(d|0));a[j>>0]=58;f=i}else{kb[d&31](g,e,f,0);e=k;d=e+36|0;do{c[e>>2]=c[g>>2];e=e+4|0;g=g+4|0}while((e|0)<(d|0))}e=b;g=k;d=e+36|0;do{c[e>>2]=c[g>>2];e=e+4|0;g=g+4|0}while((e|0)<(d|0));c[b+36>>2]=f;l=m;return}function $A(b,c){b=b|0;c=c|0;var d=0;if(((c|0)!=0?(d=Jm(b,c)|0,(d|0)!=0):0)?(a[d>>0]|0)!=0:0)b=(IA(d)|0)<<24>>24==0&1;else b=0;return b|0}function aB(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0,k=0,m=0,n=0.0,o=0.0;k=l;l=l+32|0;i=k;j=c[b+8>>2]|0;d=c[b+4>>2]|0;d=(c[b+44>>2]|0)+((O((d|0)>1?d+-1|0:0,j)|0)<<4)|0;e=i+16|0;c[e>>2]=c[d>>2];c[e+4>>2]=c[d+4>>2];c[e+8>>2]=c[d+8>>2];c[e+12>>2]=c[d+12>>2];c[i>>2]=c[d>>2];c[i+4>>2]=c[d+4>>2];c[i+8>>2]=c[d+8>>2];c[i+12>>2]=c[d+12>>2];f=i+8|0;g=i+24|0;b=1;while(1){if((b|0)>=(j|0))break;m=d+(b<<4)|0;o=+h[m>>3];h[i>>3]=+h[(+h[i>>3]>3];n=+h[m+8>>3];h[f>>3]=+h[(+h[f>>3]>3];h[e>>3]=+h[(+h[e>>3]>o?e:m)>>3];h[g>>3]=+h[(+h[g>>3]>n?e:m)+8>>3];b=b+1|0}c[a>>2]=c[i>>2];c[a+4>>2]=c[i+4>>2];c[a+8>>2]=c[i+8>>2];c[a+12>>2]=c[i+12>>2];c[a+16>>2]=c[i+16>>2];c[a+20>>2]=c[i+20>>2];c[a+24>>2]=c[i+24>>2];c[a+28>>2]=c[i+28>>2];l=k;return}function bB(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;d=l;l=l+64|0;g=d+32|0;e=d;f=c[a+16>>2]|0;a=f+16|0;f=c[f+116>>2]&1;c[g>>2]=c[a>>2];c[g+4>>2]=c[a+4>>2];c[g+8>>2]=c[a+8>>2];c[g+12>>2]=c[a+12>>2];c[g+16>>2]=c[a+16>>2];c[g+20>>2]=c[a+20>>2];c[g+24>>2]=c[a+24>>2];c[g+28>>2]=c[a+28>>2];cB(e,g,b,f);c[a>>2]=c[e>>2];c[a+4>>2]=c[e+4>>2];c[a+8>>2]=c[e+8>>2];c[a+12>>2]=c[e+12>>2];c[a+16>>2]=c[e+16>>2];c[a+20>>2]=c[e+20>>2];c[a+24>>2]=c[e+24>>2];c[a+28>>2]=c[e+28>>2];l=d;return}function cB(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,g=0.0,i=0.0,j=0,k=0.0,l=0.0,m=0.0;g=+h[d+56>>3];l=+h[d+64>>3];j=e<<24>>24==0;k=+h[d+24>>3];i=+h[d+32>>3];m=(j?k:i)*.5;f=g-m;g=m+g;if(f<+h[b>>3])h[b>>3]=f;e=b+16|0;if(g>+h[e>>3])h[e>>3]=g;g=(j?i:k)*.5;f=l-g;g=g+l;e=b+8|0;if(f<+h[e>>3])h[e>>3]=f;e=b+24|0;if(g>+h[e>>3])h[e>>3]=g;c[a>>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];c[a+12>>2]=c[b+12>>2];c[a+16>>2]=c[b+16>>2];c[a+20>>2]=c[b+20>>2];c[a+24>>2]=c[b+24>>2];c[a+28>>2]=c[b+28>>2];return}function dB(b){b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0.0,N=0.0,O=0.0,P=0.0;L=l;l=l+448|0;H=L+416|0;t=L+384|0;u=L+304|0;K=L+256|0;G=L+192|0;B=L+144|0;C=L+96|0;d=L+400|0;e=L+368|0;f=L+352|0;g=L+336|0;v=L+288|0;w=L+224|0;x=L+160|0;y=L+112|0;z=L+64|0;A=L+32|0;I=L;J=b+16|0;if((mn(b)|0)==0?(c[(c[J>>2]|0)+180>>2]|0)==0:0){eB(d,0.0,0.0);c[K>>2]=c[d>>2];c[K+4>>2]=c[d+4>>2];c[K+8>>2]=c[d+8>>2];c[K+12>>2]=c[d+12>>2];K=K+16|0;eB(e,0.0,0.0);c[K>>2]=c[e>>2];c[K+4>>2]=c[e+4>>2];c[K+8>>2]=c[e+8>>2];c[K+12>>2]=c[e+12>>2]}else{eB(f,2147483647.0,2147483647.0);c[K>>2]=c[f>>2];c[K+4>>2]=c[f+4>>2];c[K+8>>2]=c[f+8>>2];c[K+12>>2]=c[f+12>>2];F=K+16|0;eB(g,-2147483647.0,-2147483647.0);c[F>>2]=c[g>>2];c[F+4>>2]=c[g+4>>2];c[F+8>>2]=c[g+8>>2];c[F+12>>2]=c[g+12>>2];o=C+8|0;p=u+16|0;D=K+8|0;q=u+8|0;E=K+24|0;r=u+24|0;s=B+8|0;n=co(b)|0;while(1){if(!n)break;OA(B,n);d=n+16|0;m=c[d>>2]|0;h[C>>3]=(+h[m+96>>3]+ +h[m+88>>3])*.5;h[o>>3]=+h[m+80>>3]*.5;c[t>>2]=c[B>>2];c[t+4>>2]=c[B+4>>2];c[t+8>>2]=c[B+8>>2];c[t+12>>2]=c[B+12>>2];c[H>>2]=c[C>>2];c[H+4>>2]=c[C+4>>2];c[H+8>>2]=c[C+8>>2];c[H+12>>2]=c[C+12>>2];fB(u,t,H);c[t>>2]=c[B>>2];c[t+4>>2]=c[B+4>>2];c[t+8>>2]=c[B+8>>2];c[t+12>>2]=c[B+12>>2];c[H>>2]=c[C>>2];c[H+4>>2]=c[C+4>>2];c[H+8>>2]=c[C+8>>2];c[H+12>>2]=c[C+12>>2];gB(v,t,H);c[p>>2]=c[v>>2];c[p+4>>2]=c[v+4>>2];c[p+8>>2]=c[v+8>>2];c[p+12>>2]=c[v+12>>2];h[K>>3]=+h[(+h[K>>3]<+h[u>>3]?K:u)>>3];h[D>>3]=+h[(+h[D>>3]<+h[q>>3]?K:u)+8>>3];h[F>>3]=+h[(+h[F>>3]>+h[p>>3]?K:u)+16>>3];h[E>>3]=+h[(+h[E>>3]>+h[r>>3]?K:u)+24>>3];d=c[(c[d>>2]|0)+108>>2]|0;if(d|0?a[d+81>>0]|0:0){m=c[(c[J>>2]|0)+116>>2]&1;c[H>>2]=c[K>>2];c[H+4>>2]=c[K+4>>2];c[H+8>>2]=c[K+8>>2];c[H+12>>2]=c[K+12>>2];c[H+16>>2]=c[K+16>>2];c[H+20>>2]=c[K+20>>2];c[H+24>>2]=c[K+24>>2];c[H+28>>2]=c[K+28>>2];cB(w,H,d,m);c[K>>2]=c[w>>2];c[K+4>>2]=c[w+4>>2];c[K+8>>2]=c[w+8>>2];c[K+12>>2]=c[w+12>>2];c[K+16>>2]=c[w+16>>2];c[K+20>>2]=c[w+20>>2];c[K+24>>2]=c[w+24>>2];c[K+28>>2]=c[w+28>>2]}m=Pm(b,n)|0;while(1){if(!m)break;k=m+16|0;d=c[k>>2]|0;j=d+8|0;e=c[j>>2]|0;if(e|0){i=0;while(1){if((i|0)<(c[e+4>>2]|0))g=0;else break;while(1){f=c[e>>2]|0;if((g|0)>=(c[f+(i*48|0)+4>>2]|0))break;e=(c[f+(i*48|0)>>2]|0)+(g<<4)|0;c[B>>2]=c[e>>2];c[B+4>>2]=c[e+4>>2];c[B+8>>2]=c[e+8>>2];c[B+12>>2]=c[e+12>>2];N=+h[B>>3];h[K>>3]=+h[(+h[K>>3]>3];M=+h[s>>3];h[D>>3]=+h[(+h[D>>3]>3];h[F>>3]=+h[(+h[F>>3]>N?F:B)>>3];h[E>>3]=+h[(+h[E>>3]>M?F:B)+8>>3];g=g+1|0;e=c[j>>2]|0}i=i+1|0}e=c[d+96>>2]|0;if((e|0)!=0?(a[e+81>>0]|0)!=0:0){d=c[(c[J>>2]|0)+116>>2]&1;c[H>>2]=c[K>>2];c[H+4>>2]=c[K+4>>2];c[H+8>>2]=c[K+8>>2];c[H+12>>2]=c[K+12>>2];c[H+16>>2]=c[K+16>>2];c[H+20>>2]=c[K+20>>2];c[H+24>>2]=c[K+24>>2];c[H+28>>2]=c[K+28>>2];cB(x,H,e,d);c[K>>2]=c[x>>2];c[K+4>>2]=c[x+4>>2];c[K+8>>2]=c[x+8>>2];c[K+12>>2]=c[x+12>>2];c[K+16>>2]=c[x+16>>2];c[K+20>>2]=c[x+20>>2];c[K+24>>2]=c[x+24>>2];c[K+28>>2]=c[x+28>>2];d=c[k>>2]|0}e=c[d+100>>2]|0;if((e|0)!=0?(a[e+81>>0]|0)!=0:0){d=c[(c[J>>2]|0)+116>>2]&1;c[H>>2]=c[K>>2];c[H+4>>2]=c[K+4>>2];c[H+8>>2]=c[K+8>>2];c[H+12>>2]=c[K+12>>2];c[H+16>>2]=c[K+16>>2];c[H+20>>2]=c[K+20>>2];c[H+24>>2]=c[K+24>>2];c[H+28>>2]=c[K+28>>2];cB(y,H,e,d);c[K>>2]=c[y>>2];c[K+4>>2]=c[y+4>>2];c[K+8>>2]=c[y+8>>2];c[K+12>>2]=c[y+12>>2];c[K+16>>2]=c[y+16>>2];c[K+20>>2]=c[y+20>>2];c[K+24>>2]=c[y+24>>2];c[K+28>>2]=c[y+28>>2];d=c[k>>2]|0}e=c[d+104>>2]|0;if((e|0)!=0?(a[e+81>>0]|0)!=0:0){d=c[(c[J>>2]|0)+116>>2]&1;c[H>>2]=c[K>>2];c[H+4>>2]=c[K+4>>2];c[H+8>>2]=c[K+8>>2];c[H+12>>2]=c[K+12>>2];c[H+16>>2]=c[K+16>>2];c[H+20>>2]=c[K+20>>2];c[H+24>>2]=c[K+24>>2];c[H+28>>2]=c[K+28>>2];cB(z,H,e,d);c[K>>2]=c[z>>2];c[K+4>>2]=c[z+4>>2];c[K+8>>2]=c[z+8>>2];c[K+12>>2]=c[z+12>>2];c[K+16>>2]=c[z+16>>2];c[K+20>>2]=c[z+20>>2];c[K+24>>2]=c[z+24>>2];c[K+28>>2]=c[z+28>>2];d=c[k>>2]|0}d=c[d+108>>2]|0;if(d|0?a[d+81>>0]|0:0){k=c[(c[J>>2]|0)+116>>2]&1;c[H>>2]=c[K>>2];c[H+4>>2]=c[K+4>>2];c[H+8>>2]=c[K+8>>2];c[H+12>>2]=c[K+12>>2];c[H+16>>2]=c[K+16>>2];c[H+20>>2]=c[K+20>>2];c[H+24>>2]=c[K+24>>2];c[H+28>>2]=c[K+28>>2];cB(A,H,d,k);c[K>>2]=c[A>>2];c[K+4>>2]=c[A+4>>2];c[K+8>>2]=c[A+8>>2];c[K+12>>2]=c[A+12>>2];c[K+16>>2]=c[A+16>>2];c[K+20>>2]=c[A+20>>2];c[K+24>>2]=c[A+24>>2];c[K+28>>2]=c[A+28>>2]}}m=Rm(b,m)|0}n=eo(b,n)|0}d=c[J>>2]|0;f=c[d+180>>2]|0;g=d+184|0;i=G+8|0;j=G+16|0;k=G+24|0;e=1;while(1){if((e|0)>(f|0))break;P=+h[(c[(c[(c[g>>2]|0)+(e<<2)>>2]|0)+16>>2]|0)+16>>3];h[G>>3]=P;C=c[(c[(c[g>>2]|0)+(e<<2)>>2]|0)+16>>2]|0;O=+h[C+24>>3];h[i>>3]=O;M=+h[C+32>>3];h[j>>3]=M;N=+h[C+40>>3];h[k>>3]=N;h[K>>3]=+h[(+h[K>>3]>3];h[D>>3]=+h[(+h[D>>3]>3];h[F>>3]=+h[(+h[F>>3]>M?K:G)+16>>3];h[E>>3]=+h[(+h[E>>3]>N?K:G)+24>>3];e=e+1|0}e=c[d+12>>2]|0;if((e|0)!=0?(a[e+81>>0]|0)!=0:0){d=c[d+116>>2]&1;c[H>>2]=c[K>>2];c[H+4>>2]=c[K+4>>2];c[H+8>>2]=c[K+8>>2];c[H+12>>2]=c[K+12>>2];c[H+16>>2]=c[K+16>>2];c[H+20>>2]=c[K+20>>2];c[H+24>>2]=c[K+24>>2];c[H+28>>2]=c[K+28>>2];cB(I,H,e,d);c[K>>2]=c[I>>2];c[K+4>>2]=c[I+4>>2];c[K+8>>2]=c[I+8>>2];c[K+12>>2]=c[I+12>>2];c[K+16>>2]=c[I+16>>2];c[K+20>>2]=c[I+20>>2];c[K+24>>2]=c[I+24>>2];c[K+28>>2]=c[I+28>>2];d=c[J>>2]|0}J=d+16|0;c[J>>2]=c[K>>2];c[J+4>>2]=c[K+4>>2];c[J+8>>2]=c[K+8>>2];c[J+12>>2]=c[K+12>>2];c[J+16>>2]=c[K+16>>2];c[J+20>>2]=c[K+20>>2];c[J+24>>2]=c[K+24>>2];c[J+28>>2]=c[K+28>>2]}l=L;return}function eB(a,b,c){a=a|0;b=+b;c=+c;h[a>>3]=b;h[a+8>>3]=c;return}function fB(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0;d=+h[b+8>>3]-+h[c+8>>3];h[a>>3]=+h[b>>3]-+h[c>>3];h[a+8>>3]=d;return}function gB(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0;d=+h[c+8>>3]+ +h[b+8>>3];h[a>>3]=+h[c>>3]+ +h[b>>3];h[a+8>>3]=d;return}function hB(a){a=a|0;if((c[a+60>>2]|0)==(a|0))a=1;else a=(pK(Dn(a)|0,93039,7)|0)==0&1;return a|0}function iB(a){a=a|0;var b=0;b=Ql(22612,c[4345]|0)|0;lB(a,b);return b|0}function jB(a,b){a=a|0;b=b|0;a=bb[c[a>>2]&31](a,b,512)|0;if(!a)a=0;else a=c[a+12>>2]|0;return a|0}function kB(a,b,c){a=a|0;b=b|0;c=c|0;c=an(ro(b)|0,b,c,0,1)|0;No(c,122254,176,1)|0;Mm(a,c)|0;return c|0}function lB(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;h=l;l=l+16|0;g=h;f=a+16|0;e=1;while(1){a=c[f>>2]|0;if((e|0)>(c[a+180>>2]|0))break;a=c[(c[a+184>>2]|0)+(e<<2)>>2]|0;d=Dn(a)|0;if(!(bb[c[b>>2]&31](b,d,512)|0)){i=vw(16)|0;c[i+8>>2]=d;c[i+12>>2]=a;bb[c[b>>2]&31](b,i,1)|0}else{c[g>>2]=d;_l(0,93062,g)|0}lB(a,b);e=e+1|0}l=h;return}function mB(a,b,c){a=a|0;b=b|0;c=c|0;_I(b);return}function nB(a){a=a|0;var b=0,c=0,d=0;d=Ip(a,93047,1)|0;No(d,122277,280,1)|0;b=co(a)|0;while(1){if(!b)break;c=Pm(a,b)|0;while(1){if(!c)break;oB(c,d);c=Rm(a,c)|0}b=eo(a,b)|0}b=co(d)|0;while(1){if(!b)break;c=eo(d,b)|0;pB(b);qo(a,b)|0;b=c}ln(d)|0;return}function oB(b,d){b=b|0;d=d|0;var e=0,f=0;e=c[b>>2]&3;f=c[((e|0)==3?b:b+48|0)+40>>2]|0;e=c[((e|0)==2?b:b+-48|0)+40>>2]|0;if(!((a[(c[f+16>>2]|0)+118>>0]|0)==0?!(a[(c[e+16>>2]|0)+118>>0]|0):0)){f=qB(f,d)|0;e=kB(b,f,qB(e,d)|0)|0;f=c[b+16>>2]|0;d=f+8|0;e=c[e+16>>2]|0;c[e+8>>2]=c[d>>2];c[d>>2]=0;d=f+96|0;c[e+96>>2]=c[d>>2];c[d>>2]=0;d=f+108|0;c[e+108>>2]=c[d>>2];c[d>>2]=0;d=f+100|0;c[e+100>>2]=c[d>>2];c[d>>2]=0;f=f+104|0;c[e+104>>2]=c[f>>2];c[f>>2]=0;rB(b)}return}function pB(a){a=a|0;var b=0,d=0,e=0;e=a+16|0;b=c[e>>2]|0;d=c[b+132>>2]|0;if(d){_I(d);b=c[e>>2]|0}d=c[b+8>>2]|0;if(d){gb[c[(c[d+4>>2]|0)+4>>2]&127](a);b=c[e>>2]|0}ow(c[b+104>>2]|0);ow(c[(c[e>>2]|0)+108>>2]|0);Po(a,122241)|0;return}function qB(b,d){b=b|0;d=d|0;var e=0,f=0,g=0;f=ro(b)|0;a:do if(a[(c[b+16>>2]|0)+118>>0]|0){io(d,b,1)|0;b=WJ(Dn(b)|0,58)|0;if(!b)ma(96030,92694,1225,93114);d=b+1|0;b=no(f,d,0)|0;if(!b){b=no(f,d,1)|0;No(b,122241,304,1)|0;d=Dm(f,1,0)|0;while(1){if(!d)break a;g=Jm(b,d)|0;e=c[d+12>>2]|0;if((g|0)!=(e|0))Cm(b,d,e)|0;d=Dm(f,1,d)|0}}}while(0);return b|0}function rB(a){a=a|0;var b=0;b=a+16|0;_I(c[(c[b>>2]|0)+144>>2]|0);sB(a);ow(c[(c[b>>2]|0)+96>>2]|0);ow(c[(c[b>>2]|0)+108>>2]|0);ow(c[(c[b>>2]|0)+100>>2]|0);ow(c[(c[b>>2]|0)+104>>2]|0);Po(a,122254)|0;return}function sB(a){a=a|0;var b=0,d=0,e=0;e=a+16|0;a=c[e>>2]|0;b=c[a+8>>2]|0;if(b){d=0;while(1){a=c[b>>2]|0;if((d|0)>=(c[b+4>>2]|0))break;_I(c[a+(d*48|0)>>2]|0);d=d+1|0;b=c[(c[e>>2]|0)+8>>2]|0}_I(a);_I(c[(c[e>>2]|0)+8>>2]|0);a=c[e>>2]|0}c[a+8>>2]=0;return}function tB(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=ym(a,b,c,0)|0;if(!e)e=ym(a,b,c,d)|0;return e|0}function uB(a,b){a=a|0;b=b|0;return xJ(c[a>>2]|0,c[b>>2]|0)|0}function vB(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0;q=l;l=l+1072|0;k=q+8|0;j=q;i=q+16|0;o=q+24|0;c[i>>2]=b;if((c[42365]|0)!=(d|0)){c[42365]=d;a[174080]=0}cm(o,1024,q+40|0);p=o+4|0;n=o+8|0;while(1){f=b+1|0;c[i>>2]=f;e=a[b>>0]|0;if(!(e<<24>>24))break;do if((e&255)<192)if(e<<24>>24==38){f=xB(i)|0;if(!f)e=38;else{if(f>>>0<127){e=f&255;break}b=c[p>>2]|0;e=b>>>0>=(c[n>>2]|0)>>>0;if(f>>>0<2047){if(e){dm(o,1)|0;b=c[p>>2]|0}c[p>>2]=b+1;a[b>>0]=f>>>6|192;e=(f&63|128)&255;break}if(e){dm(o,1)|0;b=c[p>>2]|0}c[p>>2]=b+1;a[b>>0]=f>>>12|224;b=c[p>>2]|0;if(b>>>0>=(c[n>>2]|0)>>>0){dm(o,1)|0;b=c[p>>2]|0}c[p>>2]=b+1;a[b>>0]=f>>>6&63|128;e=(f&63|128)&255}}else{h=0;m=9}else if((e&255)>=224)if((e&255)>=240)if((e&255)<248){h=3;m=9}else{if(!(a[174080]|0)){c[j>>2]=Dn(d)|0;_l(0,94529,j)|0;a[174080]=1}h=-1;e=wB(e,o)|0;m=9}else{h=2;m=9}else{h=1;m=9}while(0);do if((m|0)==9){m=0;g=0;while(1){if((g|0)>=(h|0)){m=34;break}if((a[f>>0]&-64)<<24>>24!=-128)break;b=c[p>>2]|0;if(b>>>0>=(c[n>>2]|0)>>>0){dm(o,1)|0;b=c[p>>2]|0}c[p>>2]=b+1;a[b>>0]=e;g=g+1|0;e=a[f>>0]|0;f=f+1|0}if((m|0)==34){m=0;c[i>>2]=f;break}c[i>>2]=f;if(!(a[174080]|0)){g=Dn(d)|0;c[k>>2]=h+1;c[k+4>>2]=g;_l(0,94650,k)|0;a[174080]=1}e=wB(e,o)|0}while(0);b=c[p>>2]|0;if(b>>>0>=(c[n>>2]|0)>>>0){dm(o,1)|0;b=c[p>>2]|0}c[p>>2]=b+1;a[b>>0]=e;b=c[i>>2]|0}b=c[p>>2]|0;if(b>>>0>=(c[n>>2]|0)>>>0){dm(o,1)|0;b=c[p>>2]|0}a[b>>0]=0;n=c[o>>2]|0;c[p>>2]=n;p=GL(n)|0;gm(o);l=q;return p|0}function wB(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0;j=l;l=l+16|0;g=j;a[g>>0]=b;a[g+1>>0]=0;g=yB(g)|0;h=d+4|0;i=d+8|0;e=rJ(g)|0;f=g;while(1){if((e|0)<=1)break;b=c[h>>2]|0;if(b>>>0>=(c[i>>2]|0)>>>0){dm(d,1)|0;b=c[h>>2]|0}k=a[f>>0]|0;c[h>>2]=b+1;a[b>>0]=k;e=e+-1|0;f=f+1|0}k=a[f>>0]|0;_I(g);l=j;return k|0}function xB(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;i=l;l=l+32|0;h=i;d=i+8|0;e=c[b>>2]|0;a:do if((a[e>>0]|0)!=35){c[h>>2]=d;g=0;b:while(1){if((g|0)>=8){d=0;break a}f=a[e+g>>0]|0;switch(f<<24>>24){case 0:{d=0;break a}case 59:break b;default:{}}a[d>>0]=f;d=d+1|0;g=g+1|0}a[d>>0]=0;d=vM(h,22648,252,8,30)|0;if(!d)d=0;else{e=e+(g+1)|0;d=c[d+4>>2]|0}}else{h=a[e+1>>0]|0;d=h&255;c:do if((h|32)<<24>>24==120){h=0;g=2;while(1){if((g|0)>=8){f=h;break c}f=a[e+g>>0]|0;d=f&255;if((f+-65&255)>=6)if((f+-97&255)>=6)if((f+-48&255)<10)f=-48;else{f=h;break c}else f=-87;else f=-55;d=f+d|0;h=d+(h<<4)|0;g=g+1|0}}else{f=0;g=1;while(1){if((g|0)>=8)break c;h=a[e+g>>0]|0;d=h&255;if((h+-48&255)>=10)break c;f=(f*10|0)+-48+d|0;g=g+1|0}}while(0);d=(d|0)==59;e=d?e+(g+1)|0:e;d=d?f:0}while(0);c[b>>2]=e;l=i;return d|0}function yB(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;k=l;l=l+1056|0;g=k;i=k+8|0;c[g>>2]=b;cm(i,1024,k+24|0);j=i+4|0;h=i+8|0;while(1){c[g>>2]=b+1;d=a[b>>0]|0;if(!(d<<24>>24))break;b=d&255;if(d<<24>>24==38){b=xB(g)|0;if(!b){b=38;f=6}else f=5}else f=5;do if((f|0)==5){f=0;if(b>>>0<127)f=6;else{d=c[j>>2]|0;e=d>>>0>=(c[h>>2]|0)>>>0;if(b>>>0<2047){if(e){dm(i,1)|0;d=c[j>>2]|0}c[j>>2]=d+1;a[d>>0]=b>>>6|192;d=c[j>>2]|0;if(d>>>0>=(c[h>>2]|0)>>>0){dm(i,1)|0;d=c[j>>2]|0}b=b&63|128;break}if(e){dm(i,1)|0;d=c[j>>2]|0}c[j>>2]=d+1;a[d>>0]=b>>>12|224;d=c[j>>2]|0;if(d>>>0>=(c[h>>2]|0)>>>0){dm(i,1)|0;d=c[j>>2]|0}c[j>>2]=d+1;a[d>>0]=b>>>6&63|128;d=c[j>>2]|0;if(d>>>0>=(c[h>>2]|0)>>>0){dm(i,1)|0;d=c[j>>2]|0}b=b&63|128}}while(0);if((f|0)==6){d=c[j>>2]|0;if(d>>>0>=(c[h>>2]|0)>>>0){dm(i,1)|0;d=c[j>>2]|0}}c[j>>2]=d+1;a[d>>0]=b;b=c[g>>2]|0}b=c[j>>2]|0;if(b>>>0>=(c[h>>2]|0)>>>0){dm(i,1)|0;b=c[j>>2]|0}a[b>>0]=0;h=c[i>>2]|0;c[j>>2]=h;j=GL(h)|0;gm(i);l=k;return j|0}function zB(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;i=l;l=l+1040|0;g=i;cm(g,1024,i+16|0);h=g+4|0;f=g+8|0;while(1){d=b+1|0;e=a[b>>0]|0;if(!(e<<24>>24))break;if((e&255)<127){b=c[h>>2]|0;if(b>>>0>=(c[f>>2]|0)>>>0){dm(g,1)|0;b=c[h>>2]|0}c[h>>2]=b+1;a[b>>0]=e;b=d;continue}else{e=a[d>>0]&63|e<<6&255;d=c[h>>2]|0;if(d>>>0>=(c[f>>2]|0)>>>0){dm(g,1)|0;d=c[h>>2]|0}c[h>>2]=d+1;a[d>>0]=e;b=b+2|0;continue}}b=c[h>>2]|0;if(b>>>0>=(c[f>>2]|0)>>>0){dm(g,1)|0;b=c[h>>2]|0}a[b>>0]=0;f=c[g>>2]|0;c[h>>2]=f;h=GL(f)|0;gm(g);l=i;return h|0}function AB(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0,k=0,m=0,n=0;n=l;l=l+80|0;e=n+48|0;d=n+32|0;f=n+64|0;g=n+16|0;i=n;j=b+16|0;k=a+16|0;m=c[k>>2]|0;if(((+h[j>>3]>=+h[m+48>>3]?+h[m+64>>3]>=+h[b>>3]:0)?+h[b+24>>3]>=+h[m+56>>3]:0)?+h[m+72>>3]>=+h[b+8>>3]:0){m=m+16|0;c[d>>2]=c[j>>2];c[d+4>>2]=c[j+4>>2];c[d+8>>2]=c[j+8>>2];c[d+12>>2]=c[j+12>>2];c[e>>2]=c[b>>2];c[e+4>>2]=c[b+4>>2];c[e+8>>2]=c[b+8>>2];c[e+12>>2]=c[b+12>>2];BB(g,d,e);c[d>>2]=c[m>>2];c[d+4>>2]=c[m+4>>2];c[d+8>>2]=c[m+8>>2];c[d+12>>2]=c[m+12>>2];c[e>>2]=c[g>>2];c[e+4>>2]=c[g+4>>2];c[e+8>>2]=c[g+8>>2];c[e+12>>2]=c[g+12>>2];fB(i,d,e);c[f>>2]=a;c[f+4>>2]=0;d=c[(c[(c[(c[k>>2]|0)+8>>2]|0)+4>>2]|0)+12>>2]|0;c[e>>2]=c[i>>2];c[e+4>>2]=c[i+4>>2];c[e+8>>2]=c[i+8>>2];c[e+12>>2]=c[i+12>>2];d=ab[d&63](f,e)|0}else d=0;l=n;return d|0}function BB(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0;d=(+h[c+8>>3]+ +h[b+8>>3])*.5;h[a>>3]=(+h[c>>3]+ +h[b>>3])*.5;h[a+8>>3]=d;return}function CB(a,b){a=a|0;b=b|0;var d=0.0,e=0,f=0.0,g=0,i=0.0,j=0,k=0,m=0,n=0;e=l;l=l+80|0;j=e+64|0;k=e+48|0;m=e;n=e+32|0;g=e+16|0;h[m>>3]=+h[a+24>>3]*.5;h[m+8>>3]=+h[a+32>>3]*.5;a=a+56|0;c[k>>2]=c[a>>2];c[k+4>>2]=c[a+4>>2];c[k+8>>2]=c[a+8>>2];c[k+12>>2]=c[a+12>>2];c[j>>2]=c[m>>2];c[j+4>>2]=c[m+4>>2];c[j+8>>2]=c[m+8>>2];c[j+12>>2]=c[m+12>>2];fB(n,k,j);i=+h[n>>3];f=+h[n+8>>3];c[k>>2]=c[a>>2];c[k+4>>2]=c[a+4>>2];c[k+8>>2]=c[a+8>>2];c[k+12>>2]=c[a+12>>2];c[j>>2]=c[m>>2];c[j+4>>2]=c[m+4>>2];c[j+8>>2]=c[m+8>>2];c[j+12>>2]=c[m+12>>2];gB(g,k,j);d=+h[g+8>>3];if((+h[b+16>>3]>=i?+h[g>>3]>=+h[b>>3]:0)?+h[b+24>>3]>=f:0)a=d>=+h[b+8>>3]&1;else a=0;l=e;return a|0}function DB(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0;n=l;l=l+80|0;k=n+48|0;j=n;h=a+16|0;a=c[h>>2]|0;i=c[a+8>>2]|0;a:do if((i|0)!=0?(g=i+8|0,c[j>>2]=c[g>>2],c[j+4>>2]=c[g+4>>2],c[j+8>>2]=c[g+8>>2],c[j+12>>2]=c[g+12>>2],c[j+16>>2]=c[g+16>>2],c[j+20>>2]=c[g+20>>2],c[j+24>>2]=c[g+24>>2],c[j+28>>2]=c[g+28>>2],c[k>>2]=c[b>>2],c[k+4>>2]=c[b+4>>2],c[k+8>>2]=c[b+8>>2],c[k+12>>2]=c[b+12>>2],c[k+16>>2]=c[b+16>>2],c[k+20>>2]=c[b+20>>2],c[k+24>>2]=c[b+24>>2],c[k+28>>2]=c[b+28>>2],(EB(j,k)|0)!=0):0){d=i+4|0;a=0;while(1){if((a|0)>=(c[d>>2]|0))break;e=j;f=(c[i>>2]|0)+(a*48|0)|0;g=e+48|0;do{c[e>>2]=c[f>>2];e=e+4|0;f=f+4|0}while((e|0)<(g|0));c[k>>2]=c[b>>2];c[k+4>>2]=c[b+4>>2];c[k+8>>2]=c[b+8>>2];c[k+12>>2]=c[b+12>>2];c[k+16>>2]=c[b+16>>2];c[k+20>>2]=c[b+20>>2];c[k+24>>2]=c[b+24>>2];c[k+28>>2]=c[b+28>>2];if(!((FB(j,k)|0)<<24>>24))a=a+1|0;else{a=1;break a}}a=c[h>>2]|0;m=7}else m=7;while(0);do if((m|0)==7){a=c[a+96>>2]|0;if(a|0?(c[k>>2]=c[b>>2],c[k+4>>2]=c[b+4>>2],c[k+8>>2]=c[b+8>>2],c[k+12>>2]=c[b+12>>2],c[k+16>>2]=c[b+16>>2],c[k+20>>2]=c[b+20>>2],c[k+24>>2]=c[b+24>>2],c[k+28>>2]=c[b+28>>2],(CB(a,k)|0)<<24>>24):0){a=1;break}a=0}while(0);l=n;return a|0} +function si(a){a=a|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;h=a+16|0;i=vw((b[(c[h>>2]|0)+238>>1]<<2)+8|0)|0;g=co(a)|0;while(1){if(!g)break;f=i+(c[(c[g+16>>2]|0)+232>>2]<<2)|0;c[f>>2]=(c[f>>2]|0)+1;f=Pm(a,g)|0;while(1){if(!f)break;j=c[f>>2]&3;d=c[(c[(c[((j|0)==3?f:f+48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0;j=c[(c[(c[((j|0)==2?f:f+-48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0;k=(d|0)>(j|0);e=k?d:j;d=k?j:d;while(1){d=d+1|0;if((d|0)>=(e|0))break;k=i+(d<<2)|0;c[k>>2]=(c[k>>2]|0)+1}f=Rm(a,f)|0}g=eo(a,g)|0}f=vw((b[(c[h>>2]|0)+238>>1]<<6)+128|0)|0;e=c[h>>2]|0;c[e+196>>2]=f;d=b[e+236>>1]|0;while(1){if((d|0)>(b[e+238>>1]|0))break;j=i+(d<<2)|0;e=c[j>>2]|0;c[f+(d<<6)>>2]=e;c[f+(d<<6)+8>>2]=e;j=vw((c[j>>2]<<2)+4|0)|0;e=c[h>>2]|0;k=c[e+196>>2]|0;c[k+(d<<6)+4>>2]=j;c[k+(d<<6)+12>>2]=j;d=d+1|0;f=k}_I(i);return}function ti(a,d,e,f){a=a|0;d=d|0;e=e|0;f=f|0;var g=0,i=0,j=0,k=0,l=0,m=0;m=a+16|0;i=1;while(1){g=c[m>>2]|0;if((i|0)>(c[g+180>>2]|0))break;l=ti(c[(c[g+184>>2]|0)+(i<<2)>>2]|0,d,e,f)|0;i=i+1|0;f=l}a:do if((Vf(a)|0)!=(a|0)){VN(d|0,0,e<<2|0)|0;g=co(a)|0;while(1){if(!g)break;k=g+16|0;c[d+(c[(c[k>>2]|0)+232>>2]<<2)>>2]=1;i=Pm(a,g)|0;while(1){if(!i)break;l=i+-48|0;j=c[(c[k>>2]|0)+232>>2]|0;while(1){e=j+1|0;if((j|0)>=(c[(c[(c[((c[i>>2]&3|0)==2?i:l)+40>>2]|0)+16>>2]|0)+232>>2]|0))break;c[d+(e<<2)>>2]=1;j=e}i=Rm(a,i)|0}g=eo(a,g)|0}g=c[m>>2]|0;i=b[g+236>>1]|0;while(1){if((i|0)>(b[g+238>>1]|0))break a;if(!(c[d+(i<<2)>>2]|0)){if(!f)f=Ip(Vf(a)|0,79522,1)|0;g=no(f,0,1)|0;No(g,122241,304,1)|0;l=g+16|0;j=c[l>>2]|0;c[j+232>>2]=i;h[j+96>>3]=.5;h[j+88>>3]=.5;h[j+80>>3]=1.0;c[j+216>>2]=1;c[j+176>>2]=0;j=vw(20)|0;k=c[l>>2]|0;c[k+172>>2]=j;c[k+184>>2]=0;k=vw(20)|0;c[(c[l>>2]|0)+180>>2]=k;io(a,g,1)|0;g=c[m>>2]|0}i=i+1|0}}while(0);return f|0}function ui(a){a=a|0;var b=0,d=0;Kh(a);b=a+16|0;a=1;while(1){d=c[b>>2]|0;if((a|0)>(c[d+180>>2]|0))break;ui(c[(c[d+184>>2]|0)+(a<<2)>>2]|0);a=a+1|0}return}function vi(a){a=a|0;var b=0,d=0;b=c[a>>2]&3;d=wi(c[((b|0)==3?a:a+48|0)+40>>2]|0)|0;b=c[17236+(d*12|0)+((wi(c[((b|0)==2?a:a+-48|0)+40>>2]|0)|0)<<2)>>2]|0;a=(c[a+16>>2]|0)+156|0;c[a>>2]=O(c[a>>2]|0,b)|0;return}function wi(b){b=b|0;b=c[b+16>>2]|0;if((a[b+156>>0]|0)==1)b=2;else b=(a[b+160>>0]|0)<2&1;return b|0}function xi(b,d){b=b|0;d=d|0;if(c[(c[b+16>>2]|0)+192>>2]|0){Yk(b);yi(b);if(a[174076]|0)kl(b);zi(b);if(Cl(b)|0)yi(b);Ai(b);if(gx(b,2,Bi(b)|0)|0?(Ci(b),gx(b,2,Bi(b)|0)|0):0)ma(79540,79568,134,79579);Di(b);Ei(b,d);Fi(b)}return}function yi(d){d=d|0;var e=0,f=0,g=0,i=0,j=0.0,k=0.0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0.0,z=0.0;v=d+16|0;e=c[v>>2]|0;w=c[e+196>>2]|0;t=b[e+236>>1]|0;while(1){if((t|0)>(b[e+238>>1]|0))break;n=w+(t<<6)|0;o=w+(t<<6)+4|0;p=w+(t<<6)+40|0;q=w+(t<<6)+24|0;r=w+(t<<6)+32|0;s=w+(t<<6)+16|0;m=0;while(1){if((m|0)>=(c[n>>2]|0))break;l=(c[(c[o>>2]|0)+(m<<2)>>2]|0)+16|0;e=c[l>>2]|0;j=+h[e+80>>3]*.5;i=c[e+204>>2]|0;a:do if(i){g=0;while(1){f=c[i+(g<<2)>>2]|0;if(!f)break a;x=c[f>>2]&3;if((c[((x|0)==3?f:f+48|0)+40>>2]|0)==(c[((x|0)==2?f:f+-48|0)+40>>2]|0)?(u=c[(c[f+16>>2]|0)+96>>2]|0,(u|0)!=0):0){k=+h[u+32>>3]*.5;j=j>k?j:k}g=g+1|0}}while(0);if(+h[p>>3]>3]=j;h[p>>3]=j}if(+h[r>>3]>3]=j;h[r>>3]=j}f=c[e+212>>2]|0;if(f|0){if((f|0)==(d|0))g=0;else{g=DA(f,c[42188]|0,8,0)|0;e=c[l>>2]|0}i=c[e+232>>2]|0;f=c[f+16>>2]|0;e=f+128|0;j=j+ +(g|0);if((i|0)==(b[f+236>>1]|0)){k=+h[e>>3];h[e>>3]=k>j?k:j}e=f+120|0;if((i|0)==(b[f+238>>1]|0)){k=+h[e>>3];h[e>>3]=k>j?k:j}}m=m+1|0}t=t+1|0;e=c[v>>2]|0}m=ej(d)|0;g=c[v>>2]|0;e=b[g+238>>1]|0;h[(c[(c[c[w+(e<<6)+4>>2]>>2]|0)+16>>2]|0)+24>>3]=+h[w+(e<<6)+16>>3];f=b[g+236>>1]|0;i=g+252|0;k=0.0;while(1){l=e+-1|0;if((e|0)<=(f|0))break;y=+h[w+(l<<6)+32>>3]+ +h[w+(e<<6)+40>>3]+ +(c[i>>2]|0);j=+h[w+(e<<6)+24>>3]+8.0+ +h[w+(l<<6)+16>>3];j=y>j?y:j;if((c[w+(l<<6)>>2]|0)>0)h[(c[(c[c[w+(l<<6)+4>>2]>>2]|0)+16>>2]|0)+24>>3]=+h[(c[(c[c[w+(e<<6)+4>>2]>>2]|0)+16>>2]|0)+24>>3]+j;k=k>j?k:j;e=l}b:do if((m|0)!=0?(c[g+116>>2]&1|0)!=0:0){fj(d,0);g=c[v>>2]|0;if(a[g+276>>0]|0){e=b[g+238>>1]|0;f=b[g+236>>1]|0;j=+h[(c[(c[c[w+(e<<6)+4>>2]>>2]|0)+16>>2]|0)+24>>3];k=0.0;while(1){i=e+-1|0;if((e|0)<=(f|0))break b;z=+h[(c[(c[c[w+(i<<6)+4>>2]>>2]|0)+16>>2]|0)+24>>3];y=z-j;j=z;k=k>y?k:y;e=i}}}while(0);c:do if(a[g+276>>0]|0){i=b[g+236>>1]|0;f=b[g+238>>1]|0;while(1){e=f+-1|0;if((f|0)<=(i|0))break c;if((c[w+(e<<6)>>2]|0)<=0){f=e;continue}h[(c[(c[c[w+(e<<6)+4>>2]>>2]|0)+16>>2]|0)+24>>3]=+h[(c[(c[c[w+(f<<6)+4>>2]>>2]|0)+16>>2]|0)+24>>3]+k;f=e}}while(0);e=g+192|0;while(1){e=c[e>>2]|0;if(!e)break;e=c[e+16>>2]|0;h[e+24>>3]=+h[(c[(c[c[w+(c[e+232>>2]<<6)+4>>2]>>2]|0)+16>>2]|0)+24>>3];e=e+164|0}return}function zi(a){a=a|0;var b=0,d=0,e=0;aj(a);b=(c[a+16>>2]|0)+192|0;while(1){b=c[b>>2]|0;if(!b)break;e=b+16|0;b=c[e>>2]|0;d=c[b+224>>2]|0;if(d){bj(a,d);b=c[e>>2]|0}d=c[b+228>>2]|0;if(!d)d=b;else{bj(a,d);d=c[e>>2]|0}e=c[d+204>>2]|0;if(e|0){b=0;while(1)if(!(c[e+(b<<2)>>2]|0))break;else b=b+1|0}b=d+164|0}return}function Ai(a){a=a|0;Oi(a);Pi(a);Qi(a);Ri(a);Si(a);return}function Bi(a){a=a|0;var b=0,c=0.0;b=Im(a,79768)|0;if(!b)a=2147483647;else{c=+sM(b);a=~~(c*+(mn(a)|0))}return a|0}function Ci(d){d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;r=d+16|0;e=c[r>>2]|0;q=b[e+236>>1]|0;while(1){p=b[e+238>>1]|0;if((q|0)>(p|0)){s=19;break}n=c[e+196>>2]|0;o=n+(q<<6)|0;m=c[o>>2]|0;n=n+(q<<6)+4|0;l=0;f=0;a:while(1){if((l|0)>=(m|0)){s=14;break}f=c[(c[n>>2]|0)+(l<<2)>>2]|0;h=c[f+16>>2]|0;i=c[h+256>>2]|0;b:do if(i|0){g=0;while(1){j=c[i+(g<<2)>>2]|0;if(!j)break b;k=c[j>>2]&3;if((c[(c[(c[((k|0)==2?j:j+-48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)>(q|0))break a;if((c[(c[(c[((k|0)==3?j:j+48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)>(q|0))break a;else g=g+1|0}}while(0);h=c[h+248>>2]|0;c:do if(h|0){g=0;while(1){i=c[h+(g<<2)>>2]|0;if(!i)break c;j=c[i>>2]&3;if((c[(c[(c[((j|0)==3?i:i+48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)>(q|0))break a;if((c[(c[(c[((j|0)==2?i:i+-48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)>(q|0))break a;else g=g+1|0}}while(0);l=l+1|0}if((s|0)==14){s=0;if(f){f=c[c[n>>2]>>2]|0;e=c[c[o+(((q|0)<(p|0)?1:-1)<<6)+4>>2]>>2]|0;if(!e){s=16;break}o=fh(d)|0;p=o+16|0;a[(c[p>>2]|0)+156>>0]=2;Mi(o,f,0.0,0)|0;Mi(o,e,0.0,0)|0;c[(c[p>>2]|0)+232>>2]=c[(c[((c[(c[f+16>>2]|0)+232>>2]|0)<(c[(c[e+16>>2]|0)+232>>2]|0)?f:e)+16>>2]|0)+232>>2];e=c[r>>2]|0}}q=q+1|0}if((s|0)==16)ma(79676,79568,111,79679);else if((s|0)==19)return}function Di(a){a=a|0;var d=0,e=0,f=0,g=0,i=0,j=0,k=0;a=c[a+16>>2]|0;i=c[a+196>>2]|0;e=b[a+238>>1]|0;a=b[a+236>>1]|0;while(1){if((a|0)>(e|0))break;f=c[i+(a<<6)>>2]|0;g=i+(a<<6)+4|0;d=0;while(1){if((d|0)>=(f|0))break;k=c[(c[(c[g>>2]|0)+(d<<2)>>2]|0)+16>>2]|0;j=k+232|0;h[k+16>>3]=+(c[j>>2]|0);c[j>>2]=a;d=d+1|0}a=a+1|0}return}function Ei(a,d){a=a|0;d=d|0;var e=0,f=0.0,g=0,i=0.0,j=0,k=0,l=0.0,m=0,n=0,o=0,p=0;Gi(a,a);g=a+16|0;k=c[g>>2]|0;a:do if((b[k+238>>1]|0)>0?(j=c[k+8>>2]|0,e=c[j+84>>2]|0,e|0):0){o=~~(+h[k+32>>3]-+h[k+16>>3]);m=~~(+h[k+40>>3]-+h[k+24>>3]);p=(c[k+116>>2]&1|0)==0;n=p?m:o;m=p?o:m;if((e|0)==4){e=Hi(a)|0;k=c[g>>2]|0;j=c[k+8>>2]|0}else e=(e|0)==2&1;b:do if(!(e<<24>>24)){switch(c[j+84>>2]|0){case 5:{f=+h[j+64>>3];if(f<=0.0)break a;i=f/+h[k+32>>3];l=+h[j+72>>3]/+h[k+40>>3];f=i1.0&l>1.0){l=f;break b}else break a}case 1:break;default:break a}i=+h[j+16>>3];f=+(n|0)/+(m|0);if(f>3];if(f<=0.0)break a;i=f/+(m|0);f=+h[j+72>>3]/+(n|0);if(i<1.0|f<1.0)if(i>2]&1|0)==0;i=e?f:l;f=e?l:f;e=k+192|0;while(1){e=c[e>>2]|0;if(!e)break;e=c[e+16>>2]|0;p=e+16|0;l=+h[p>>3]*f;h[p>>3]=+(~~(l+(l>=0.0?.5:-.5))|0);p=e+24|0;l=+h[p>>3]*i;h[p>>3]=+(~~(l+(l>=0.0?.5:-.5))|0);e=e+164|0}Ii(a,f,i)}while(0);if(d|0)Ji(a,d);return}function Fi(b){b=b|0;var d=0,e=0,f=0,g=0,h=0;h=b+16|0;b=(c[h>>2]|0)+192|0;while(1){b=c[b>>2]|0;if(!b)break;g=b+16|0;d=0;while(1){b=c[g>>2]|0;f=c[b+180>>2]|0;e=c[f+(d<<2)>>2]|0;if(!e)break;_I(c[e+16>>2]|0);_I(e);d=d+1|0}if(f){_I(f);b=c[g>>2]|0}d=c[b+172>>2]|0;if(d){_I(d);b=c[g>>2]|0}f=b+256|0;e=c[f+4>>2]|0;b=b+180|0;c[b>>2]=c[f>>2];c[b+4>>2]=e;b=c[g>>2]|0;e=b+248|0;f=c[e+4>>2]|0;b=b+172|0;c[b>>2]=c[e>>2];c[b+4>>2]=f;b=(c[g>>2]|0)+164|0}b=0;d=c[(c[h>>2]|0)+192>>2]|0;a:while(1){g=(b|0)==0;f=b+16|0;b=d;while(1){if(!b)break a;e=c[b+16>>2]|0;d=c[e+164>>2]|0;if((a[e+156>>0]|0)!=2)continue a;if(g)c[(c[h>>2]|0)+192>>2]=d;else c[(c[f>>2]|0)+164>>2]=d;_I(e);_I(b);b=d}}c[(c[(c[(c[h>>2]|0)+192>>2]|0)+16>>2]|0)+168>>2]=0;return}function Gi(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;e=a+16|0;d=1;while(1){f=c[e>>2]|0;if((d|0)>(c[f+180>>2]|0))break;Gi(c[(c[f+184>>2]|0)+(d<<2)>>2]|0,b);d=d+1|0}Li(a,b);return}function Hi(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,i=0,j=0.0,k=0.0,m=0,n=0.0,o=0.0,p=0.0,q=0.0,r=0,s=0,t=0;s=l;l=l+80|0;e=s+64|0;d=s+48|0;f=s+16|0;m=s;r=s+32|0;a=a+16|0;b=c[(c[a>>2]|0)+8>>2]|0;t=b+48|0;c[f>>2]=c[t>>2];c[f+4>>2]=c[t+4>>2];c[f+8>>2]=c[t+8>>2];c[f+12>>2]=c[t+12>>2];if((!(+h[f>>3]<.001)?(g=f+8|0,!(+h[g>>3]<.001)):0)?(i=b+32|0,c[m>>2]=c[i>>2],c[m+4>>2]=c[i+4>>2],c[m+8>>2]=c[i+8>>2],c[m+12>>2]=c[i+12>>2],c[d>>2]=c[f>>2],c[d+4>>2]=c[f+4>>2],c[d+8>>2]=c[f+8>>2],c[d+12>>2]=c[f+12>>2],c[e>>2]=c[i>>2],c[e+4>>2]=c[i+4>>2],c[e+8>>2]=c[i+8>>2],c[e+12>>2]=c[i+12>>2],Ki(r,d,e),c[f>>2]=c[r>>2],c[f+4>>2]=c[r+4>>2],c[f+8>>2]=c[r+8>>2],c[f+12>>2]=c[r+12>>2],c[d>>2]=c[r>>2],c[d+4>>2]=c[r+4>>2],c[d+8>>2]=c[r+8>>2],c[d+12>>2]=c[r+12>>2],c[e>>2]=c[m>>2],c[e+4>>2]=c[m+4>>2],c[e+8>>2]=c[m+8>>2],c[e+12>>2]=c[m+12>>2],Ki(f,d,e),i=c[a>>2]|0,j=+h[i+32>>3],k=+h[i+40>>3],n=+h[f>>3],o=n/j,p=+h[g>>3],q=p/k,!(o>=1.0&q>=1.0)):0){o=o.5?o:.5;q=+N(+(o*k/p))*p/k;p=+N(+(o*j/n))*n/j*j;a=c[i+8>>2]|0;h[a+64>>3]=p;h[a+72>>3]=q*k;a=1}else a=0;l=s;return a|0}function Ii(a,b,d){a=a|0;b=+b;d=+d;var e=0,f=0;e=a+16|0;a=1;while(1){f=c[e>>2]|0;if((a|0)>(c[f+180>>2]|0))break;Ii(c[(c[f+184>>2]|0)+(a<<2)>>2]|0,b,d);a=a+1|0}e=f+16|0;h[e>>3]=+h[e>>3]*b;e=f+24|0;h[e>>3]=+h[e>>3]*d;e=f+32|0;h[e>>3]=+h[e>>3]*b;f=f+40|0;h[f>>3]=+h[f>>3]*d;return}function Ji(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0,g=0,i=0.0,j=0,k=0,m=0,n=0;m=l;l=l+32|0;j=m+24|0;g=m+16|0;f=m;n=c[a+16>>2]|0;e=+h[n+32>>3]-+h[n+16>>3];d=+h[n+40>>3]-+h[n+24>>3];i=e/d;if(0){n=c[13918]|0;h[f>>3]=i;h[f+8>>3]=e*.0001*d;zL(n,79592,f)|0;c[g>>2]=kk(a)|0;zL(n,79617,g)|0}d=+h[b>>3];do if(!(i>d*1.1)){a=b+24|0;if(!(i<=d*.8)){c[a>>2]=0;k=9;break}c[a>>2]=-1;if(0){XL(79627,34,1,c[13918]|0)|0;k=9}}else{c[b+24>>2]=~~(d*+((c[b+20>>2]|0)-(c[b+16>>2]|0)|0)/i);k=9}while(0);if((k|0)==9?0:0){n=c[13918]|0;c[j>>2]=c[b+24>>2];zL(n,79662,j)|0}l=m;return}function Ki(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0;d=+h[b+8>>3]-+h[c+8>>3];h[a>>3]=+h[b>>3]-+h[c>>3];h[a+8>>3]=d;return}function Li(d,e){d=d|0;e=e|0;var f=0,g=0.0,i=0.0,j=0,k=0,l=0,m=0.0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0.0;s=(Vf(d)|0)==(d|0);v=d+16|0;w=c[v>>2]|0;a:do if(s){f=b[w+236>>1]|0;d=b[w+238>>1]|0;q=d<<16>>16;r=w+196|0;s=w+196|0;p=f<<16>>16;i=-2147483647.0;g=2147483647.0;while(1){if((p|0)>(q|0))break;j=c[r>>2]|0;o=c[j+(p<<6)>>2]|0;if((o|0)!=0?(t=c[j+(p<<6)+4>>2]|0,u=c[t>>2]|0,(u|0)!=0):0){l=1;j=u;while(1){j=c[j+16>>2]|0;k=a[j+156>>0]|0;if(!((l|0)<(o|0)&k<<24>>24!=0))break;j=c[t+(l<<2)>>2]|0;l=l+1|0}if(!(k<<24>>24)){m=+h[j+16>>3]-+h[j+88>>3];n=g>2]|0)+(p<<6)+4>>2]|0;k=o+-2|0;j=o+-1|0;while(1){j=c[(c[l+(j<<2)>>2]|0)+16>>2]|0;if(!(a[j+156>>0]|0))break;else{j=k;k=k+-1|0}}x=+h[j+96>>3]+ +h[j+16>>3];i=i>x?i:x;g=n?g:m}}p=p+1|0}k=c[w+180>>2]|0;l=w+184|0;j=1;while(1){if((j|0)>(k|0))break a;u=c[(c[(c[l>>2]|0)+(j<<2)>>2]|0)+16>>2]|0;x=+h[u+16>>3]+-8.0;m=+h[u+32>>3]+8.0;j=j+1|0;i=i>m?i:m;g=g>2]|0)+16>>2]|0)+232>>2]|0);g=+(c[(c[(c[w+256>>2]|0)+16>>2]|0)+232>>2]|0);f=b[w+236>>1]|0;d=b[w+238>>1]|0}while(0);e=c[(c[e+16>>2]|0)+196>>2]|0;m=+h[(c[(c[c[e+(d<<16>>16<<6)+4>>2]>>2]|0)+16>>2]|0)+24>>3]-+h[w+120>>3];x=+h[w+128>>3]+ +h[(c[(c[c[e+(f<<16>>16<<6)+4>>2]>>2]|0)+16>>2]|0)+24>>3];h[w+16>>3]=g;h[w+24>>3]=m;e=c[v>>2]|0;h[e+32>>3]=i;h[e+40>>3]=x;return}function Mi(a,d,e,f){a=a|0;d=d|0;e=+e;f=f|0;var g=0,h=0,i=0,j=0;i=vw(96)|0;j=i+48|0;c[j>>2]=c[j>>2]|3;c[i>>2]=c[i>>2]&-4|2;g=vw(176)|0;h=i+16|0;c[h>>2]=g;c[((c[i>>2]&3|0)==3?i:j)+40>>2]=a;c[((c[i>>2]&3|0)==2?i:i+-48|0)+40>>2]=d;if(e>65535.0){Ni(e);e=65535.0;g=c[h>>2]|0}b[g+170>>1]=~~(e+(e>=0.0?.5:-.5));c[g+156>>2]=f;Vg(i)|0;return i|0}function Ni(a){a=+a;var b=0,d=0;b=l;l=l+16|0;d=b;h[d>>3]=a;c[d+8>>2]=65535;_l(1,79692,d)|0;l=b;return}function Oi(a){a=a|0;var b=0,d=0,e=0,f=0;a=(c[a+16>>2]|0)+192|0;while(1){a=c[a>>2]|0;if(!a)break;f=a+16|0;e=c[f>>2]|0;a=e+172|0;d=c[a+4>>2]|0;e=e+248|0;c[e>>2]=c[a>>2];c[e+4>>2]=d;e=c[f>>2]|0;d=e+180|0;a=c[d+4>>2]|0;e=e+256|0;c[e>>2]=c[d>>2];c[e+4>>2]=a;e=c[f>>2]|0;a=c[e+180>>2]|0;d=0;while(1)if(!(c[a+(d<<2)>>2]|0))break;else d=d+1|0;b=c[e+172>>2]|0;a=0;while(1)if(!(c[b+(a<<2)>>2]|0))break;else a=a+1|0;c[e+176>>2]=0;a=vw((a+d<<2)+16|0)|0;e=c[f>>2]|0;c[e+172>>2]=a;c[e+184>>2]=0;e=vw(16)|0;a=c[f>>2]|0;c[a+180>>2]=e;a=a+164|0}return}function Pi(d){d=d|0;var f=0,g=0,i=0.0,j=0,k=0,m=0,n=0,o=0,p=0.0,q=0,r=0,s=0,t=0.0,u=0,v=0,w=0,x=0,y=0,z=0,A=0.0,B=0.0;z=l;l=l+16|0;w=z;x=d+16|0;u=c[x>>2]|0;y=c[u+196>>2]|0;d=(a[(c[(c[d+60>>2]|0)+16>>2]|0)+113>>0]&1)!=0;v=c[u+248>>2]|0;c[w>>2]=v;c[w+4>>2]=d?5:v;v=b[u+236>>1]|0;d=u;while(1){if((v|0)>(b[d+238>>1]|0))break;r=y+(v<<6)+4|0;c[(c[(c[c[r>>2]>>2]|0)+16>>2]|0)+232>>2]=0;s=y+(v<<6)|0;t=+(c[w+((v&1)<<2)>>2]|0);p=0.0;k=0;a:while(1){if((k|0)>=(c[s>>2]|0))break;f=c[r>>2]|0;m=c[f+(k<<2)>>2]|0;u=m+16|0;d=c[u>>2]|0;i=+h[d+96>>3];h[d+240>>3]=i;if((c[d+208>>2]|0)>0){j=0;f=0;while(1){g=c[(c[d+204>>2]|0)+(j<<2)>>2]|0;if(!g)break;q=c[g>>2]&3;if((c[((q|0)==3?g:g+48|0)+40>>2]|0)==(c[((q|0)==2?g:g+-48|0)+40>>2]|0)){f=(Qz(g)|0)+f|0;d=c[u>>2]|0}j=j+1|0}q=d+96|0;i=+h[q>>3]+ +(f|0);h[q>>3]=i;f=c[r>>2]|0}q=k+1|0;f=c[f+(q<<2)>>2]|0;if(f){o=f+16|0;i=i+t+ +h[(c[o>>2]|0)+88>>3];Mi(m,f,i,0)|0;d=~~(i+p);c[(c[o>>2]|0)+232>>2]=d;p=+(d|0);d=c[u>>2]|0}f=c[d+112>>2]|0;if(f){j=c[d+256>>2]|0;k=c[j>>2]|0;j=c[j+4>>2]|0;d=(c[(c[(c[((c[k>>2]&3|0)==2?k:k+-48|0)+40>>2]|0)+16>>2]|0)+236>>2]|0)>(c[(c[(c[((c[j>>2]&3|0)==2?j:j+-48|0)+40>>2]|0)+16>>2]|0)+236>>2]|0);g=d?j:k;j=d?k:j;k=f+16|0;d=c[k>>2]|0;i=+((O(c[(c[x>>2]|0)+248>>2]|0,e[d+170>>1]|0)|0)/2|0|0);o=c[g>>2]&3;f=c[((o|0)==2?g:g+-48|0)+40>>2]|0;g=c[((o|0)==3?g:g+48|0)+40>>2]|0;if(!(_i(g,f)|0))Mi(f,g,+(~~(+h[(c[f+16>>2]|0)+96>>3]+i+ +h[(c[g+16>>2]|0)+88>>3])|0),c[d+156>>2]|0)|0;d=c[j>>2]&3;f=c[((d|0)==3?j:j+48|0)+40>>2]|0;d=c[((d|0)==2?j:j+-48|0)+40>>2]|0;if(!(_i(d,f)|0)){Mi(f,d,+(~~(+h[(c[f+16>>2]|0)+96>>3]+i+ +h[(c[d+16>>2]|0)+88>>3])|0),c[(c[k>>2]|0)+156>>2]|0)|0;o=0}else o=0}else o=0;while(1){d=c[u>>2]|0;if((o|0)>=(c[d+192>>2]|0)){k=q;continue a}m=c[(c[d+188>>2]|0)+(o<<2)>>2]|0;k=c[m>>2]&3;g=c[((k|0)==3?m:m+48|0)+40>>2]|0;k=c[((k|0)==2?m:m+-48|0)+40>>2]|0;j=(c[(c[g+16>>2]|0)+236>>2]|0)<(c[(c[k+16>>2]|0)+236>>2]|0);f=j?g:k;g=j?k:g;i=+h[(c[g+16>>2]|0)+88>>3]+ +h[(c[f+16>>2]|0)+96>>3];k=m+16|0;j=~~(i+ +(O(c[(c[x>>2]|0)+248>>2]|0,e[(c[k>>2]|0)+170>>1]|0)|0));n=Sg(f,g)|0;if(!n){d=c[k>>2]|0;if(!(c[d+96>>2]|0))Mi(f,g,+(j|0),c[d+156>>2]|0)|0}else{A=+(j|0);d=c[k>>2]|0;B=+h[d+136>>3];i=i+ +(c[(c[x>>2]|0)+248>>2]|0)+ +(~~(B+(B>=0.0?.5:-.5))|0);f=~~(i65535){Ni(+(f|0));f=65535;d=c[k>>2]|0}k=c[n+16>>2]|0;j=k+170|0;g=e[j>>1]|0;b[j>>1]=(f|0)<(g|0)?g:f;k=k+156|0;c[k>>2]=c[(c[((c[k>>2]|0)>(c[d+156>>2]|0)?n:m)+16>>2]|0)+156>>2]}o=o+1|0}}v=v+1|0;d=c[x>>2]|0}l=z;return}function Qi(b){b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0;d=(c[b+16>>2]|0)+192|0;while(1){d=c[d>>2]|0;if(!d)break;g=d+16|0;d=c[g>>2]|0;e=c[d+256>>2]|0;a:do if(e){f=0;while(1){e=c[e+(f<<2)>>2]|0;if(!e)break a;n=fh(b)|0;d=n+16|0;a[(c[d>>2]|0)+156>>0]=2;l=e+16|0;k=c[l>>2]|0;i=~~(+h[k+56>>3]-+h[k+16>>3]);m=(i|0)>0;j=m?0:0-i|0;i=m?i:0;m=e+48|0;Mi(n,c[((c[e>>2]&3|0)==3?e:m)+40>>2]|0,+(i+1|0),c[k+156>>2]|0)|0;k=e+-48|0;Mi(n,c[((c[e>>2]&3|0)==2?e:k)+40>>2]|0,+(j+1|0),c[(c[l>>2]|0)+156>>2]|0)|0;l=c[e>>2]&3;i=(c[(c[(c[((l|0)==3?e:m)+40>>2]|0)+16>>2]|0)+232>>2]|0)-i|0;e=(c[(c[(c[((l|0)==2?e:k)+40>>2]|0)+16>>2]|0)+232>>2]|0)-j|0;c[(c[d>>2]|0)+232>>2]=((i|0)<(e|0)?i:e)+-1;d=c[g>>2]|0;f=f+1|0;e=c[d+256>>2]|0}}while(0);d=d+164|0}return}function Ri(a){a=a|0;if((c[(c[a+16>>2]|0)+180>>2]|0)>0){Vi(a);Wi(a);Xi(a);Yi(a)}return}function Si(a){a=a|0;var b=0.0,d=0.0,e=0,f=0;e=a+16|0;f=c[(c[e>>2]|0)+8>>2]|0;if((c[f+84>>2]|0)==3?(b=+h[f+64>>3],d=+h[f+72>>3],!(d*b<=1.0)):0){Ti(a);f=c[e>>2]|0;d=(c[f+116>>2]&1|0)==0?b:d;Mi(c[f+256>>2]|0,c[f+260>>2]|0,d<65535.0?d:65535.0,1e3)|0}return}function Ti(a){a=a|0;var d=0,e=0,f=0.0,g=0,i=0,j=0,k=0,m=0,n=0;n=l;l=l+16|0;m=n;e=DA(a,c[42188]|0,8,0)|0;Ui(a);i=a+16|0;g=c[i>>2]|0;j=c[g+256>>2]|0;k=c[g+260>>2]|0;f=+(e|0);e=b[g+236>>1]|0;while(1){if((e|0)>(b[g+238>>1]|0))break;d=c[g+196>>2]|0;do if(c[d+(e<<6)>>2]|0){d=c[c[d+(e<<6)+4>>2]>>2]|0;if(!d){c[m>>2]=Dn(a)|0;c[m+4>>2]=e;_l(1,79776,m)|0;break}else{Mi(j,d,+h[(c[d+16>>2]|0)+88>>3]+f+ +h[g+96>>3],0)|0;g=c[i>>2]|0;d=c[g+196>>2]|0;d=c[(c[d+(e<<6)+4>>2]|0)+((c[d+(e<<6)>>2]|0)+-1<<2)>>2]|0;Mi(d,k,+h[(c[d+16>>2]|0)+96>>3]+f+ +h[g+64>>3],0)|0;break}}while(0);e=e+1|0;g=c[i>>2]|0}l=n;return}function Ui(b){b=b|0;var d=0,e=0,f=0;d=b+16|0;if(!(c[(c[d>>2]|0)+256>>2]|0)){f=fh(Vf(b)|0)|0;a[(c[f+16>>2]|0)+156>>0]=2;e=fh(Vf(b)|0)|0;a[(c[e+16>>2]|0)+156>>0]=2;if((c[(c[d>>2]|0)+12>>2]|0?(Vf(b)|0)!=(b|0):0)?(c[(c[(so(b)|0)+16>>2]|0)+116>>2]&1|0)==0:0){b=c[d>>2]|0;Mi(f,e,+(~~+h[b+48+((+h[b+48>>3]>+h[b+80>>3]?0:2)<<4)>>3]|0),0)|0}d=c[d>>2]|0;c[d+256>>2]=f;c[d+260>>2]=e}return}function Vi(a){a=a|0;var b=0,d=0;do if((Vf(a)|0)!=(a|0)){Ti(a);a=a+16|0;b=c[a>>2]|0;b=Sg(c[b+256>>2]|0,c[b+260>>2]|0)|0;if(!b){d=c[a>>2]|0;Mi(c[d+256>>2]|0,c[d+260>>2]|0,1.0,128)|0;break}else{d=(c[b+16>>2]|0)+156|0;c[d>>2]=(c[d>>2]|0)+128;break}}else a=a+16|0;while(0);b=1;while(1){d=c[a>>2]|0;if((b|0)>(c[d+180>>2]|0))break;Vi(c[(c[d+184>>2]|0)+(b<<2)>>2]|0);b=b+1|0}return}function Wi(d){d=d|0;var e=0,f=0,g=0,i=0,j=0,k=0,l=0,m=0.0,n=0,o=0;k=DA(d,c[42188]|0,8,0)|0;o=d+16|0;e=c[o>>2]|0;m=+(k|0);k=b[e+236>>1]|0;while(1){if((k|0)>(b[e+238>>1]|0)){f=1;break}e=c[e+196>>2]|0;a:do if(c[e+(k<<6)>>2]|0?(l=c[c[e+(k<<6)+4>>2]>>2]|0,l|0):0){i=l+16|0;f=c[(c[i>>2]|0)+236>>2]|0;while(1){if((f|0)<=0)break;f=f+-1|0;j=c[(c[(c[(c[(Vf(d)|0)+16>>2]|0)+196>>2]|0)+(k<<6)+4>>2]|0)+(f<<2)>>2]|0;g=j+16|0;e=c[g>>2]|0;if(!(a[e+156>>0]|0)){n=10;break}if(Zi(d,j)|0){n=9;break}}if((n|0)==9){e=c[g>>2]|0;n=10}if((n|0)==10){n=0;Mi(j,c[(c[o>>2]|0)+256>>2]|0,+h[e+96>>3]+m,0)|0}f=(c[(c[(c[o>>2]|0)+196>>2]|0)+(k<<6)>>2]|0)+(c[(c[i>>2]|0)+236>>2]|0)|0;while(1){if((f|0)>=(c[(c[(c[(Vf(d)|0)+16>>2]|0)+196>>2]|0)+(k<<6)>>2]|0))break a;i=c[(c[(c[(c[(Vf(d)|0)+16>>2]|0)+196>>2]|0)+(k<<6)+4>>2]|0)+(f<<2)>>2]|0;g=i+16|0;e=c[g>>2]|0;if(!(a[e+156>>0]|0))break;if(!(Zi(d,i)|0))f=f+1|0;else{n=15;break}}if((n|0)==15){n=0;e=c[g>>2]|0}Mi(c[(c[o>>2]|0)+260>>2]|0,i,+h[e+88>>3]+m,0)|0}while(0);k=k+1|0;e=c[o>>2]|0}while(1){if((f|0)>(c[e+180>>2]|0))break;Wi(c[(c[e+184>>2]|0)+(f<<2)>>2]|0);f=f+1|0;e=c[o>>2]|0}return}function Xi(a){a=a|0;var b=0,d=0.0,e=0,f=0,g=0;e=DA(a,c[42188]|0,8,0)|0;Ui(a);b=a+16|0;d=+(e|0);a=1;while(1){e=c[b>>2]|0;if((a|0)>(c[e+180>>2]|0))break;e=c[(c[e+184>>2]|0)+(a<<2)>>2]|0;Ui(e);f=c[b>>2]|0;g=e+16|0;Mi(c[f+256>>2]|0,c[(c[g>>2]|0)+256>>2]|0,+h[f+96>>3]+d,0)|0;f=c[b>>2]|0;Mi(c[(c[g>>2]|0)+260>>2]|0,c[f+260>>2]|0,+h[f+64>>3]+d,0)|0;Xi(e);a=a+1|0}return}function Yi(a){a=a|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0.0,n=0,o=0;d=DA(a,c[42188]|0,8,0)|0;n=a+16|0;a=1;while(1){f=c[n>>2]|0;e=c[f+180>>2]|0;if((a|0)>(e|0))break;Ui(c[(c[f+184>>2]|0)+(a<<2)>>2]|0);a=a+1|0}m=+(d|0);l=1;a=e;d=f;while(1){if((l|0)>(a|0))break;k=l+1|0;j=k;while(1){e=c[d+184>>2]|0;f=c[e+(l<<2)>>2]|0;if((j|0)>(a|0))break;e=c[e+(j<<2)>>2]|0;g=(b[(c[f+16>>2]|0)+236>>1]|0)>(b[(c[e+16>>2]|0)+236>>1]|0);i=g?e:f;e=g?f:e;f=c[i+16>>2]|0;g=c[e+16>>2]|0;o=b[g+236>>1]|0;h=o<<16>>16;if((b[f+238>>1]|0)>=o<<16>>16){a=(c[(c[(c[c[(c[f+196>>2]|0)+(h<<6)+4>>2]>>2]|0)+16>>2]|0)+236>>2]|0)<(c[(c[(c[c[(c[g+196>>2]|0)+(h<<6)+4>>2]>>2]|0)+16>>2]|0)+236>>2]|0);Mi(c[(c[(a?i:e)+16>>2]|0)+260>>2]|0,c[(c[(a?e:i)+16>>2]|0)+256>>2]|0,m,0)|0;a=c[n>>2]|0;d=a;a=c[a+180>>2]|0}j=j+1|0}Yi(f);d=c[n>>2]|0;l=k;a=c[d+180>>2]|0}return}function Zi(b,d){b=b|0;d=d|0;var e=0;d=c[d+16>>2]|0;if((a[d+156>>0]|0)==1){d=c[c[d+256>>2]>>2]|0;while(1){e=c[(c[d+16>>2]|0)+116>>2]|0;if(!e)break;else d=e}if(!(Bo(b,c[((c[d>>2]&3|0)==3?d:d+48|0)+40>>2]|0)|0))d=(Bo(b,c[((c[d>>2]&3|0)==2?d:d+-48|0)+40>>2]|0)|0)==0&1;else d=0}else d=0;return d|0}function _i(a,b){a=a|0;b=b|0;return $i(a,b)|0}function $i(a,b){a=a|0;b=b|0;var d=0,e=0;a:do if((a|0)==(b|0))a=1;else{d=c[(c[a+16>>2]|0)+180>>2]|0;a=0;while(1){e=c[d+(a<<2)>>2]|0;if(!e){a=0;break a}if(!($i(c[((c[e>>2]&3|0)==2?e:e+-48|0)+40>>2]|0,b)|0))a=a+1|0;else{a=1;break}}}while(0);return a|0}function aj(d){d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0;k=d+16|0;d=c[k>>2]|0;j=b[d+236>>1]|0;while(1){if((j|0)>(b[d+238>>1]|0))break;h=c[d+196>>2]|0;g=c[h+(j<<6)>>2]|0;h=h+(j<<6)+4|0;i=0;f=0;while(1){if((f|0)>=(g|0))break;e=c[(c[(c[h>>2]|0)+(f<<2)>>2]|0)+16>>2]|0;c[e+236>>2]=i;if((a[e+159>>0]|0)==6)e=c[e+216>>2]|0;else e=1;i=e+i|0;f=f+1|0}if((i|0)>(g|0)){d=c[h>>2]|0;if(!d)d=ww((i<<2)+4|0)|0;else d=yw(d,(i<<2)+4|0)|0;f=c[(c[k>>2]|0)+196>>2]|0;c[f+(j<<6)+4>>2]=d;e=c[f+(j<<6)>>2]|0;while(1){d=e+-1|0;if((e|0)<=0)break;h=c[f+(j<<6)+4>>2]|0;e=c[h+(d<<2)>>2]|0;c[h+(c[(c[e+16>>2]|0)+236>>2]<<2)>>2]=e;e=d;f=c[(c[k>>2]|0)+196>>2]|0}c[f+(j<<6)>>2]=i;c[(c[f+(j<<6)+4>>2]|0)+(i<<2)>>2]=0;d=c[k>>2]|0}j=j+1|0}return}function bj(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0;o=l;l=l+48|0;n=o+32|0;m=o+8|0;d=o+24|0;k=o+16|0;j=o;e=b+16|0;f=c[e>>2]|0;a:do if((c[f+216>>2]|0)>=2){c[m>>2]=~~(+h[f+16>>3]-+h[f+88>>3]);c[m+4>>2]=~~+h[f+24>>3];c[n>>2]=c[m>>2];c[n+4>>2]=c[m+4>>2];cj(d,b,n);g=d;i=c[g+4>>2]|0;d=m;c[d>>2]=c[g>>2];c[d+4>>2]=i;d=c[e>>2]|0;if((c[d+184>>2]|0)>0){j=c[c[d+180>>2]>>2]|0;d=(c[d+236>>2]|0)+1|0;j=Sm(a,c[((c[j>>2]&3|0)==2?j:j+-48|0)+40>>2]|0)|0;while(1){if(!j)break a;i=(c[j>>2]&3|0)==2?j:j+-48|0;e=i+48|0;f=c[((c[i>>2]&3|0)==3?i:e)+40>>2]|0;if((f|0)!=(b|0)?(KA(f)|0)==(b|0):0){f=c[((c[i>>2]&3|0)==3?i:e)+40>>2]|0;c[n>>2]=c[m>>2];c[n+4>>2]=c[m+4>>2];dj(k,a,f,n,d);f=k;e=c[f+4>>2]|0;g=m;c[g>>2]=c[f>>2];c[g+4>>2]=e;kh(i);g=i+-48|0;e=c[(c[((c[i>>2]&3|0)==2?i:g)+40>>2]|0)+16>>2]|0;f=c[e+172>>2]|0;if(!f)e=ww((c[e+176>>2]<<2)+8|0)|0;else e=yw(f,(c[e+176>>2]<<2)+8|0)|0;c[(c[(c[((c[i>>2]&3|0)==2?i:g)+40>>2]|0)+16>>2]|0)+172>>2]=e;p=c[(c[((c[i>>2]&3|0)==2?i:g)+40>>2]|0)+16>>2]|0;e=c[p+172>>2]|0;p=p+176|0;f=c[p>>2]|0;c[p>>2]=f+1;c[e+(f<<2)>>2]=i;i=c[(c[((c[i>>2]&3|0)==2?i:g)+40>>2]|0)+16>>2]|0;c[(c[i+172>>2]|0)+(c[i+176>>2]<<2)>>2]=0;d=d+1|0}j=Tm(a,j)|0}}else{i=c[c[d+172>>2]>>2]|0;d=(c[d+236>>2]|0)+1|0;i=Pm(a,c[((c[i>>2]&3|0)==3?i:i+48|0)+40>>2]|0)|0;while(1){if(!i)break a;e=i+-48|0;f=c[((c[i>>2]&3|0)==2?i:e)+40>>2]|0;if((f|0)!=(b|0)?(KA(f)|0)==(b|0):0){f=c[((c[i>>2]&3|0)==2?i:e)+40>>2]|0;c[n>>2]=c[m>>2];c[n+4>>2]=c[m+4>>2];dj(j,a,f,n,d);f=j;e=c[f+4>>2]|0;g=m;c[g>>2]=c[f>>2];c[g+4>>2]=e;kh(i);g=i+48|0;e=c[(c[((c[i>>2]&3|0)==3?i:g)+40>>2]|0)+16>>2]|0;f=c[e+180>>2]|0;if(!f)e=ww((c[e+184>>2]<<2)+8|0)|0;else e=yw(f,(c[e+184>>2]<<2)+8|0)|0;c[(c[(c[((c[i>>2]&3|0)==3?i:g)+40>>2]|0)+16>>2]|0)+180>>2]=e;f=c[(c[((c[i>>2]&3|0)==3?i:g)+40>>2]|0)+16>>2]|0;k=c[f+180>>2]|0;f=f+184|0;p=c[f>>2]|0;c[f>>2]=p+1;c[k+(p<<2)>>2]=i;p=c[(c[((c[i>>2]&3|0)==3?i:g)+40>>2]|0)+16>>2]|0;c[(c[p+180>>2]|0)+(c[p+184>>2]<<2)>>2]=0;d=d+1|0}i=Rm(a,i)|0}}}while(0);l=o;return}function cj(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0.0;KB(b,c[(c[(ro(b)|0)+16>>2]|0)+116>>2]&1);e=c[b+16>>2]|0;h[e+24>>3]=+(c[d+4>>2]|0);f=+h[e+88>>3]+ +(c[d>>2]|0);h[e+16>>3]=f;f=f+ +h[e+96>>3];c[d>>2]=~~(f+ +(c[(c[(ro(b)|0)+16>>2]|0)+248>>2]|0));e=d;b=c[e+4>>2]|0;d=a;c[d>>2]=c[e>>2];c[d+4>>2]=b;return}function dj(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0;i=l;l=l+16|0;h=i;b=Vf(b)|0;g=KA(d)|0;if((g|0)!=(d|0))ch(g,d);j=c[d+16>>2]|0;c[j+236>>2]=f;g=c[(c[g+16>>2]|0)+232>>2]|0;c[j+232>>2]=g;c[(c[(c[(c[b+16>>2]|0)+196>>2]|0)+(g<<6)+4>>2]|0)+(f<<2)>>2]=d;c[h>>2]=c[e>>2];c[h+4>>2]=c[e+4>>2];cj(a,d,h);l=i;return}function ej(a){a=a|0;var d=0.0,e=0.0,f=0,g=0,i=0,j=0.0,k=0,l=0,m=0,n=0.0;m=c[(c[(Vf(a)|0)+16>>2]|0)+196>>2]|0;if((Vf(a)|0)==(a|0))j=8.0;else j=+(DA(a,c[42188]|0,8,0)|0);l=a+16|0;g=c[l>>2]|0;f=0;k=1;e=+h[g+120>>3];d=+h[g+128>>3];while(1){if((k|0)>(c[g+180>>2]|0))break;i=c[(c[g+184>>2]|0)+(k<<2)>>2]|0;f=ej(i)|0|f;i=c[i+16>>2]|0;g=c[l>>2]|0;if((b[i+238>>1]|0)==(b[g+238>>1]|0)){n=+h[i+120>>3]+j;e=e>n?e:n}if((b[i+236>>1]|0)==(b[g+236>>1]|0)){n=+h[i+128>>3]+j;d=d>n?d:n}k=k+1|0}if((Vf(a)|0)!=(a|0)?(c[(c[l>>2]|0)+12>>2]|0)!=0:0)if(!(c[(c[(so(a)|0)+16>>2]|0)+116>>2]&1)){k=c[l>>2]|0;f=1;e=+h[k+56>>3]+e;d=+h[k+88>>3]+d}else f=1;k=c[l>>2]|0;h[k+120>>3]=e;h[k+128>>3]=d;if((Vf(a)|0)!=(a|0)){l=c[l>>2]|0;a=m+(b[l+236>>1]<<6)+24|0;n=+h[a>>3];h[a>>3]=n>d?n:d;m=m+(b[l+238>>1]<<6)+16|0;n=+h[m>>3];h[m>>3]=n>e?n:e}return f|0}function fj(a,d){a=a|0;d=d|0;var e=0,f=0.0,g=0.0,i=0,j=0,k=0.0,l=0,m=0,n=0,o=0,p=0.0,q=0.0;o=c[(c[(Vf(a)|0)+16>>2]|0)+196>>2]|0;if((Vf(a)|0)==(a|0))e=0;else e=DA(a,c[42188]|0,8,0)|0;l=a+16|0;i=c[l>>2]|0;m=e+d|0;k=+(e|0);j=1;f=+h[i+128>>3];g=+h[i+120>>3];e=i;while(1){if((j|0)>(c[e+180>>2]|0))break;i=c[(c[e+184>>2]|0)+(j<<2)>>2]|0;fj(i,m);i=c[i+16>>2]|0;e=c[l>>2]|0;if((b[i+238>>1]|0)==(b[e+238>>1]|0)){q=+h[i+120>>3]+k;g=g>q?g:q}if((b[i+236>>1]|0)==(b[e+236>>1]|0)){q=+h[i+128>>3]+k;f=f>q?f:q}j=j+1|0}h[e+120>>3]=g;h[e+128>>3]=f;if(((Vf(a)|0)!=(a|0)?(n=c[l>>2]|0,c[n+12>>2]|0):0)?(p=-g-f+ +h[n+48+((+h[n+104>>3]>+h[n+72>>3]?3:1)<<4)+8>>3]-+h[(c[(c[c[o+(b[n+236>>1]<<6)+4>>2]>>2]|0)+16>>2]|0)+24>>3]+ +h[(c[(c[c[o+(b[n+238>>1]<<6)+4>>2]>>2]|0)+16>>2]|0)+24>>3],p>0.0):0)gj(a,~~p,d);if((Vf(a)|0)!=(a|0)){n=c[l>>2]|0;m=o+(b[n+236>>1]<<6)+24|0;q=+h[m>>3];p=+h[n+128>>3];h[m>>3]=q>p?q:p;o=o+(b[n+238>>1]<<6)+16|0;p=+h[o>>3];q=+h[n+120>>3];h[o>>3]=p>q?p:q}return}function gj(a,d,e){a=a|0;d=d|0;e=e|0;var f=0,g=0.0,i=0.0,j=0.0,k=0,l=0,m=0,n=0.0,o=0.0,p=0,q=0,r=0;k=c[(Vf(a)|0)+16>>2]|0;q=c[k+196>>2]|0;p=c[a+16>>2]|0;a=b[p+238>>1]|0;f=b[p+236>>1]|0;l=(d+1|0)/2|0;m=p+120|0;n=+h[m>>3];o=+(l|0);i=+(e|0);e=~~(o+i+n-+h[q+(a<<6)+16>>3]);if((e|0)>0){g=+(e|0);while(1){if((a|0)<(f|0))break;if((c[q+(a<<6)>>2]|0)>0){r=(c[(c[c[q+(a<<6)+4>>2]>>2]|0)+16>>2]|0)+24|0;h[r>>3]=+h[r>>3]+g}a=a+-1|0}j=+h[p+128>>3];a=e;g=j+ +(d-l|0)}else{j=+h[p+128>>3];a=d-l|0;g=j}a=~~(+(a|0)+i+g-+h[q+(f<<6)+24>>3]);a:do if((a|0)>0){e=b[k+236>>1]|0;g=+(a|0);while(1){a=f+-1|0;if((f|0)<=(e|0))break a;if((c[q+(a<<6)>>2]|0)<=0){f=a;continue}f=(c[(c[c[q+(a<<6)+4>>2]>>2]|0)+16>>2]|0)+24|0;h[f>>3]=+h[f>>3]+g;f=a}}while(0);h[p+128>>3]=j+ +(d-l|0);h[m>>3]=n+o;return}function hj(b,d){b=b|0;d=d|0;var e=0,f=0;e=c[b+16>>2]|0;f=a[e+84>>0]|0;b=c[d+16>>2]|0;do if(f<<24>>24==(a[b+84>>0]|0)){if(+h[e+56>>3]==+h[b+56>>3]){if(!(f<<24>>24==0?1:+h[e+64>>3]==+h[b+64>>3])){b=0;break}}else if(f<<24>>24){b=0;break}if(+h[e+16>>3]==+h[b+16>>3]?+h[e+24>>3]==+h[b+24>>3]:0){b=1;break}b=(a[e+44>>0]|0)==0&1}else b=0;while(0);return b|0}function ij(a){a=a|0;var d=0,e=0,f=0,g=0,h=0,i=0;i=a+16|0;d=c[i>>2]|0;b[d+236>>1]=32767;b[d+238>>1]=-1;d=0;h=co(a)|0;while(1){e=c[i>>2]|0;if(!h)break;f=e+238|0;g=c[(c[h+16>>2]|0)+232>>2]|0;if((g|0)>(b[f>>1]|0))b[f>>1]=g;e=e+236|0;if((g|0)<(b[e>>1]|0))b[e>>1]=g;if(!d)d=h;else d=(g|0)<(c[(c[d+16>>2]|0)+232>>2]|0)?h:d;h=eo(a,h)|0}c[e+264>>2]=d;return}function jj(a){a=a|0;var b=0,d=0,e=0,f=0,g=0.0;b=Im(a,79821)|0;if(!b)b=2147483647;else{g=+sM(b);b=~~(g*+(mn(a)|0))}e=a+16|0;d=0;while(1){f=c[e>>2]|0;if((d|0)>=(c[f+220>>2]|0))break;c[f+192>>2]=c[(c[f+216>>2]|0)+(d<<2)>>2];gx(a,(c[f+180>>2]|0)==0&1,b)|0;d=d+1|0}return}function kj(a,d){a=a|0;d=d|0;var e=0,f=0,g=0;f=l;l=l+16|0;e=f;if(!(Im(a,79830)|0))mj(a,d);else{g=(c[a+16>>2]|0)+136|0;b[g>>1]=b[g>>1]|16;lj(a,d)}if(0){g=c[13918]|0;a=c[a+16>>2]|0;d=b[a+236>>1]|0;c[e>>2]=b[a+238>>1];c[e+4>>2]=d;zL(g,79838,e)|0}l=f;return}function lj(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0.0;i=l;l=l+16|0;h=i;c[41933]=0;a[h>>0]=a[17644]|0;a[h+1>>0]=a[17645]|0;a[h+2>>0]=a[17646]|0;a[h+3>>0]=a[17647]|0;h=gn(80048,h,0)|0;No(h,80077,280,1)|0;zo(h,17332,17272);nj(b);e=Im(b,79821)|0;if(!e)f=2147483647;else{j=+sM(e);f=~~(j*+(mn(b)|0))}Dj(b,0);Ej(b,h);Fj(b,h);Gj(b,h,0,0);Hj(h);g=Ij(h)|0;Jj(h);if(d|0){xk(h);lk(h)}e=Im(b,87620)|0;if(!e)e=-1;else e=rM(e)|0;zw(h,1,f,e)|0;Kj(b,h,g);ln(h)|0;l=i;return}function mj(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;g=l;l=l+32|0;f=g+16|0;e=g+8|0;d=g;nj(a);do if(!b){oj(a,a);Ak(a);pj(d,a);h=d;d=c[h+4>>2]|0;b=e;c[b>>2]=c[h>>2];c[b+4>>2]=d;tl(a,0);b=0}else{xk(a);lk(a);oj(a,a);Ak(a);pj(d,a);i=d;d=c[i+4>>2]|0;h=e;c[h>>2]=c[i>>2];c[h+4>>2]=d;tl(a,0);h=c[a+16>>2]|0;if((c[h+220>>2]|0)<=1?(c[h+180>>2]|0)<=0:0)break;c[b+32>>2]=1;b=0}while(0);ik(a);c[f>>2]=c[e>>2];c[f+4>>2]=c[e+4>>2];if(qj(a,f)|0)tl(a,0);if(!b)jj(a);else mk(a,b);rj(a,b);sj(a);l=g;return}function nj(d){d=d|0;var f=0,g=0,h=0;if(a[(c[(c[d+60>>2]|0)+16>>2]|0)+113>>0]&1){g=co(d)|0;while(1){if(!g)break;f=Pm(d,g)|0;while(1){if(!f)break;h=(c[f+16>>2]|0)+170|0;b[h>>1]=(e[h>>1]|0)<<1;f=Rm(d,f)|0}g=eo(d,g)|0}h=(c[d+16>>2]|0)+252|0;c[h>>2]=((c[h>>2]|0)+1|0)/2|0}return}function oj(a,b){a=a|0;b=b|0;var d=0;b=Jp(b)|0;while(1){if(!b)break;d=Aj(b)|0;do if(d)if((d|0)==7&(c[42179]|0)==100){wj(a,b);break}else{Bj(a,b,d);break}else oj(a,b);while(0);b=Kp(b)|0}return}function pj(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0;i=d+16|0;e=c[i>>2]|0;d=c[e+228>>2]|0;e=c[e+224>>2]|0;f=(e|0)==0;if(!d)if(f){j=0;k=0}else g=4;else if(f)g=5;else g=4;if((g|0)==4){d=KA(e)|0;e=c[i>>2]|0;c[e+224>>2]=d;d=c[e+228>>2]|0;if(!d){h=0;d=e;g=12}else g=5}do if((g|0)==5){d=KA(d)|0;e=c[i>>2]|0;c[e+228>>2]=d;if(d){e=d+16|0;d=c[e>>2]|0;f=(a[d+159>>0]|0)==5&1;while(1){d=c[c[d+180>>2]>>2]|0;if(!d){g=11;break}h=c[((c[d>>2]&3|0)==2?d:d+-48|0)+40>>2]|0;if((h|0)!=(KA(h)|0)){g=9;break}hk(d);d=c[e>>2]|0}if((g|0)==9)ma(79941,79881,346,79973);else if((g|0)==11){h=f;d=c[i>>2]|0;g=12;break}}else{h=0;d=e;g=12}}while(0);a:do if((g|0)==12){d=c[d+224>>2]|0;if(!d){j=0;k=h}else{e=d+16|0;d=c[e>>2]|0;f=(a[d+159>>0]|0)==3&1;while(1){d=c[c[d+172>>2]>>2]|0;if(!d){j=f;k=h;break a}i=c[((c[d>>2]&3|0)==3?d:d+48|0)+40>>2]|0;if((i|0)!=(KA(i)|0))break;hk(d);d=c[e>>2]|0}ma(79986,79881,353,79973)}}while(0);c[b>>2]=j;c[b+4>>2]=k;return}function qj(a,d){a=a|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;j=a+16|0;i=c[j>>2]|0;if((c[i+228>>2]|0)==0?(c[i+224>>2]|0)==0:0)d=0;else e=3;a:do if((e|0)==3){g=co(a)|0;i=d+4|0;h=c[d>>2]&65535;d=0;while(1){if(!g)break a;if((g|0)==(KA(g)|0)){f=g+16|0;e=c[f>>2]|0;if((c[e+184>>2]|0)==0?(k=c[(c[j>>2]|0)+228>>2]|0,!((k|0)==0|(g|0)==(k|0))):0){d=ah(g,k,0)|0;e=c[d+16>>2]|0;b[e+170>>1]=c[i>>2];c[e+156>>2]=0;e=c[f>>2]|0}if((c[e+176>>2]|0)==0?(l=c[(c[j>>2]|0)+224>>2]|0,!((l|0)==0|(g|0)==(l|0))):0){d=ah(l,g,0)|0;f=c[d+16>>2]|0;b[f+170>>1]=h;c[f+156>>2]=0}}g=eo(a,g)|0}}while(0);return (d|0)!=0|0}function rj(d,e){d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0;g=co(d)|0;k=d+16|0;f=c[k>>2]|0;a:do if(g){b[f+236>>1]=32767;b[f+238>>1]=-1;j=(e|0)==0;while(1){if(!g)break;f=KA(g)|0;i=c[g+16>>2]|0;e=c[i+232>>2]|0;do if((f|0)!=(g|0)){if(!j)if(!e)e=0;else break;e=e+(c[(c[f+16>>2]|0)+232>>2]|0)|0;c[i+232>>2]=e}while(0);f=c[k>>2]|0;h=f+238|0;if((e|0)>(b[h>>1]|0))b[h>>1]=e;f=f+236|0;if((e|0)<(b[f>>1]|0))b[f>>1]=e;switch(a[i+159>>0]|0){case 6:case 0:break;default:MA(g)}g=eo(d,g)|0}if((Vf(d)|0)==(d|0)){if((c[42179]|0)==100)e=1;else{vj(d);break}while(1){f=c[k>>2]|0;if((e|0)>(c[f+180>>2]|0))break a;uj(c[(c[f+184>>2]|0)+(e<<2)>>2]|0);e=e+1|0}}}else{b[f+238>>1]=0;b[f+236>>1]=0}while(0);return}function sj(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;j=b+16|0;e=0;while(1){d=c[j>>2]|0;if((e|0)>=(c[d+220>>2]|0))break;i=c[(c[d+216>>2]|0)+(e<<2)>>2]|0;c[d+192>>2]=i;d=i;while(1){if(!d)break;i=d+16|0;tj((c[i>>2]|0)+172|0);tj((c[i>>2]|0)+180|0);i=c[i>>2]|0;a[i+157>>0]=0;d=c[i+164>>2]|0}e=e+1|0}i=co(b)|0;while(1){if(!i)break;h=Pm(b,i)|0;while(1){if(!h)break;f=h+16|0;d=c[f>>2]|0;g=c[d+172>>2]|0;if((g|0)!=0?(k=g+16|0,(h|0)==(c[(c[k>>2]|0)+116>>2]|0)):0){d=co(b)|0;while(1){if(!d)break;e=Pm(b,d)|0;while(1){if(!e)break;if((h|0)!=(e|0)?(l=(c[e+16>>2]|0)+172|0,m=c[l>>2]|0,(m|0)!=0&(g|0)==(m|0)):0)c[l>>2]=0;e=Rm(b,e)|0}d=eo(b,d)|0}_I(c[k>>2]|0);_I(g);d=c[f>>2]|0}c[d+172>>2]=0;h=Rm(b,h)|0}i=eo(b,i)|0}_I(c[(c[j>>2]|0)+216>>2]|0);m=c[j>>2]|0;c[m+216>>2]=0;c[m+220>>2]=0;return}function tj(a){a=a|0;var b=0,d=0;d=a+4|0;b=c[d>>2]|0;while(1){if((b|0)<=-1)break;c[(c[a>>2]|0)+(b<<2)>>2]=0;b=b+-1|0}c[d>>2]=0;return}function uj(a){a=a|0;var d=0,f=0,g=0;d=a+16|0;f=c[d>>2]|0;g=c[(c[(c[f+264>>2]|0)+16>>2]|0)+232>>2]|0;a=f+236|0;b[a>>1]=g+(e[a>>1]|0);a=f+238|0;b[a>>1]=g+(e[a>>1]|0);a=1;while(1){if((a|0)>(c[f+180>>2]|0))break;uj(c[(c[f+184>>2]|0)+(a<<2)>>2]|0);a=a+1|0;f=c[d>>2]|0}return}function vj(b){b=b|0;var d=0;d=Jp(Vf(b)|0)|0;while(1){if(!d)break;if((a[(c[d+16>>2]|0)+274>>0]|0)==7)wj(b,d);d=Kp(d)|0}return}function wj(a,b){a=a|0;b=b|0;var d=0;d=(c[b+16>>2]|0)+200|0;do if((c[d>>2]|0)==0?(c[d>>2]=a,xj(a,b),co(b)|0):0){yj(a,b);if((c[42179]|0)==100){mj(b,0);zj(b);break}else{ij(b);break}}while(0);return}function xj(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0;h=b+16|0;g=co(d)|0;while(1){if(!g)break;i=eo(d,g)|0;j=g+16|0;if(!(a[(c[j>>2]|0)+159>>0]|0))f=1;else{qo(d,g)|0;g=i;continue}while(1){e=c[h>>2]|0;b=c[e+180>>2]|0;if((f|0)>=(b|0))break;if(Bo(c[(c[e+184>>2]|0)+(f<<2)>>2]|0,g)|0){k=7;break}f=f+1|0}if((k|0)==7){k=0;b=c[(c[h>>2]|0)+180>>2]|0}if((f|0)<(b|0))qo(d,g)|0;c[(c[j>>2]|0)+212>>2]=0;g=i}e=co(d)|0;while(1){if(!e)break;b=Pm(Vf(d)|0,e)|0;while(1){if(!b)break;if(Bo(d,c[((c[b>>2]&3|0)==2?b:b+-48|0)+40>>2]|0)|0)en(d,b,1)|0;b=Rm(Vf(d)|0,b)|0}e=eo(d,e)|0}return}function yj(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;e=a+16|0;d=c[e>>2]|0;g=d+180|0;a=c[g>>2]|0;f=a+1|0;c[g>>2]=f;d=c[d+184>>2]|0;if(!d)a=vw((a<<2)+8|0)|0;else a=xw(d,a+2|0,4,f)|0;c[(c[e>>2]|0)+184>>2]=a;c[a+(f<<2)>>2]=b;hw(b);return}function zj(b){b=b|0;var d=0,e=0,f=0,g=0,h=0;g=c[b+16>>2]|0;d=g+192|0;h=0;while(1){d=c[d>>2]|0;if(!d)break;f=c[d+16>>2]|0;if(!(c[f+232>>2]|0))e=(a[f+156>>0]|0)==0?d:h;else e=h;d=f+164|0;h=e}if(!h)ma(79866,79881,238,79888);c[g+264>>2]=h;d=co(b)|0;while(1){if(!d){d=13;break}e=d+16|0;if(!((d|0)==(h|0)?1:(c[(c[e>>2]|0)+216>>2]|0)<2)){d=11;break}LA(d,h)|0;a[(c[e>>2]|0)+159>>0]=7;d=eo(b,d)|0}if((d|0)==11)ma(79903,79881,242,79888);else if((d|0)==13)return}function Aj(b){b=b|0;var d=0;if(!(Cj(b)|0)){d=UA(Im(b,80018)|0,17284,17308)|0;a[(c[b+16>>2]|0)+274>>0]=d;b=d}else b=7;return b|0}function Bj(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;g=co(d)|0;a:do if(g|0){j=e&255;i=g+16|0;f=g;h=j;while(1){a[(c[f+16>>2]|0)+159>>0]=h;f=eo(d,f)|0;if(!f)break;LA(g,f)|0;h=a[(c[i>>2]|0)+159>>0]|0}switch(e|0){case 3:case 2:{b=b+16|0;f=c[b>>2]|0;h=c[f+224>>2]|0;if(h){g=LA(h,g)|0;f=c[b>>2]|0}c[f+224>>2]=g;break}case 5:case 4:{b=b+16|0;f=c[b>>2]|0;h=c[f+228>>2]|0;if(h){g=LA(h,g)|0;f=c[b>>2]|0}c[f+228>>2]=g;break}default:break a}switch(e|0){case 3:{f=f+224|0;break}case 5:{f=f+228|0;break}default:break a}a[(c[(c[f>>2]|0)+16>>2]|0)+159>>0]=j}while(0);return}function Cj(a){a=a|0;return (VJ(Dn(a)|0,93039,7)|0)==0|0}function Dj(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0;m=l;l=l+16|0;g=m;if(!(Yj(b)|0)){do if(hB(b)|0)if(!d){c[(c[b+16>>2]|0)+204>>2]=0;d=b;break}else{c[(c[b+16>>2]|0)+204>>2]=(c[(c[d+16>>2]|0)+204>>2]|0)+1;Zj(b,d);d=b;break}while(0);e=Jp(b)|0;while(1){if(!e)break;Dj(e,d);e=Kp(e)|0}a:do if(hB(b)|0){e=co(b)|0;while(1){if(!e)break a;f=(c[e+16>>2]|0)+212|0;if(!(c[f>>2]|0))c[f>>2]=b;e=eo(b,e)|0}}while(0);switch(_j(b)|0){case 3:{d=d+16|0;a[(c[d>>2]|0)+241>>0]=1;k=19;break}case 2:{d=d+16|0;k=19;break}case 5:{d=d+16|0;a[(c[d>>2]|0)+242>>0]=1;k=21;break}case 4:{d=d+16|0;k=21;break}case 1:{$j(b)|0;break}case 6:break;default:{e=Dn(b)|0;f=Im(b,80018)|0;c[g>>2]=e;c[g+4>>2]=f;_l(0,80201,g)|0}}if((k|0)==19){k=$j(b)|0;k=ak(k,c[(c[d>>2]|0)+208>>2]|0)|0;c[(c[d>>2]|0)+208>>2]=k}else if((k|0)==21){k=$j(b)|0;k=ak(k,c[(c[d>>2]|0)+212>>2]|0)|0;c[(c[d>>2]|0)+212>>2]=k}if((hB(b)|0?(h=b+16|0,i=c[h>>2]|0,j=c[i+208>>2]|0,j|0):0)?(j|0)==(c[i+212>>2]|0):0){j=$j(b)|0;k=c[h>>2]|0;c[k+208>>2]=j;c[k+212>>2]=j}}l=m;return}function Ej(a,b){a=a|0;b=b|0;var d=0,e=0;c[41933]=0;d=co(a)|0;while(1){if(!d)break;if((Lj(d)|0)==(d|0)){e=Oj(b,Dn(d)|0)|0;c[(c[d+16>>2]|0)+148>>2]=e}d=eo(a,d)|0}d=co(a)|0;while(1){if(!d)break;b=d+16|0;if(!(c[(c[b>>2]|0)+148>>2]|0)){e=c[(c[(Lj(d)|0)+16>>2]|0)+148>>2]|0;c[(c[b>>2]|0)+148>>2]=e}d=eo(a,d)|0}return}function Fj(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;h=co(a)|0;while(1){if(!h)break;d=c[(c[h+16>>2]|0)+148>>2]|0;i=Pm(a,h)|0;while(1){if(!i)break;do if((Tj(i)|0)==0?(j=i+-48|0,k=c[(c[(Lj(c[((c[i>>2]&3|0)==2?i:j)+40>>2]|0)|0)+16>>2]|0)+148>>2]|0,(d|0)!=(k|0)):0){f=c[i>>2]&3;g=i+48|0;e=((f|0)==3?i:g)+40|0;f=c[(c[(c[((f|0)==2?i:j)+40>>2]|0)+16>>2]|0)+212>>2]|0;if(!(Uj(i)|0)){if((Sj(c[(c[(c[e>>2]|0)+16>>2]|0)+212>>2]|0)|0)==0?(Sj(f)|0)==0:0){Vj(b,d,k,i);break}Wj(b,d,k,i);break}else{f=Lj(c[e>>2]|0)|0;e=c[i>>2]&3;if((f|0)!=(c[(c[(c[(c[(c[((e|0)==3?i:g)+40>>2]|0)+16>>2]|0)+212>>2]|0)+16>>2]|0)+212>>2]|0)?(g=Lj(c[((e|0)==2?i:j)+40>>2]|0)|0,(g|0)!=(c[(c[(c[(c[(c[((c[i>>2]&3|0)==2?i:j)+40>>2]|0)+16>>2]|0)+212>>2]|0)+16>>2]|0)+208>>2]|0)):0)e=k;else{e=d;d=k}Vj(b,d,e,i);break}}while(0);i=Rm(a,i)|0}h=eo(a,h)|0}return}function Gj(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;if((hB(a)|0)!=0?(Sj(a)|0)!=0:0){g=co(a)|0;while(1){if(!g)break;if(!(Sm(a,g)|0)){f=c[(c[(Lj(g)|0)+16>>2]|0)+148>>2]|0;if(!d)d=Oj(b,80099)|0;an(b,d,f,0,1)|0}if(!(Pm(a,g)|0)){f=c[(c[(Lj(g)|0)+16>>2]|0)+148>>2]|0;if(!e)e=Oj(b,80104)|0;an(b,f,e,0,1)|0}g=eo(a,g)|0}if((e|0)!=0&(d|0)!=0){Rj(an(b,d,e,0,1)|0,0,1e3);f=d}else f=d}else f=d;d=Jp(a)|0;while(1){if(!d)break;Gj(d,b,f,e);d=Kp(d)|0}return}function Hj(b){b=b|0;var d=0,e=0;d=co(b)|0;while(1){if(!d)break;e=c[d+16>>2]|0;a[e+158>>0]=0;a[e+157>>0]=0;d=eo(b,d)|0}d=co(b)|0;while(1){if(!d)break;Pj(b,d);d=eo(b,d)|0}return}function Ij(a){a=a|0;var b=0,d=0,e=0,f=0;b=co(a)|0;while(1){if(!b)break;c[(c[b+16>>2]|0)+128>>2]=0;b=eo(a,b)|0}b=0;e=co(a)|0;while(1){if(!e)break;d=b+1|0;if(!(c[(c[e+16>>2]|0)+128>>2]|0)){Nj(a,e,d);b=d}e=eo(a,e)|0}a:do if((b|0)>1){f=Oj(a,80093)|0;d=1;e=co(a)|0;while(1){if(!e)break a;if((c[(c[e+16>>2]|0)+128>>2]|0)==(d|0)){an(a,f,e,0,1)|0;d=d+1|0}e=eo(a,e)|0}}while(0);return b|0}function Jj(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0;g=co(a)|0;while(1){if(!g)break;h=g+16|0;f=Pm(a,g)|0;while(1){if(!f)break;b=c[h>>2]|0;d=c[b+180>>2]|0;if(!d)b=ww((c[b+184>>2]<<2)+8|0)|0;else b=yw(d,(c[b+184>>2]<<2)+8|0)|0;d=c[h>>2]|0;c[d+180>>2]=b;d=d+184|0;e=c[d>>2]|0;c[d>>2]=e+1;c[b+(e<<2)>>2]=f;e=c[h>>2]|0;c[(c[e+180>>2]|0)+(c[e+184>>2]<<2)>>2]=0;e=f+-48|0;b=c[(c[((c[f>>2]&3|0)==2?f:e)+40>>2]|0)+16>>2]|0;d=c[b+172>>2]|0;if(!d)b=ww((c[b+176>>2]<<2)+8|0)|0;else b=yw(d,(c[b+176>>2]<<2)+8|0)|0;c[(c[(c[((c[f>>2]&3|0)==2?f:e)+40>>2]|0)+16>>2]|0)+172>>2]=b;i=c[(c[((c[f>>2]&3|0)==2?f:e)+40>>2]|0)+16>>2]|0;b=c[i+172>>2]|0;i=i+176|0;d=c[i>>2]|0;c[i>>2]=d+1;c[b+(d<<2)>>2]=f;e=c[(c[((c[f>>2]&3|0)==2?f:e)+40>>2]|0)+16>>2]|0;c[(c[e+172>>2]|0)+(c[e+176>>2]<<2)>>2]=0;f=Rm(a,f)|0}g=eo(a,g)|0}return}function Kj(a,d,f){a=a|0;d=d|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;n=a+16|0;o=c[n>>2]|0;b[o+236>>1]=32767;b[o+238>>1]=-1;a:do if((f|0)>1){h=vw((f<<2)+4|0)|0;g=f+1|0;f=1;while(1){if((f|0)==(g|0)){m=h;o=h;break a}c[h+(f<<2)>>2]=32767;f=f+1|0}}else{m=0;o=0}while(0);i=(m|0)==0;h=co(a)|0;while(1){if(!h)break;j=c[(c[(c[(Lj(h)|0)+16>>2]|0)+148>>2]|0)+16>>2]|0;k=c[j+232>>2]|0;l=c[h+16>>2]|0;c[l+232>>2]=k;f=c[n>>2]|0;g=f+238|0;if((k|0)>(b[g>>1]|0))b[g>>1]=k;f=f+236|0;if((k|0)<(b[f>>1]|0))b[f>>1]=k;if(!i){j=c[j+128>>2]|0;c[l+128>>2]=j;l=m+(j<<2)|0;j=c[l>>2]|0;c[l>>2]=(j|0)<(k|0)?j:k}h=eo(a,h)|0}j=(m|0)!=0;b:do if(!j){m=b[(c[n>>2]|0)+236>>1]|0;g=m<<16>>16;if(m<<16>>16>0){f=co(a)|0;while(1){if(!f)break;m=(c[f+16>>2]|0)+232|0;c[m>>2]=(c[m>>2]|0)-g;f=eo(a,f)|0}f=c[n>>2]|0;n=f+236|0;b[n>>1]=(e[n>>1]|0)-g;f=f+238|0;b[f>>1]=(e[f>>1]|0)-g;f=0}else f=0}else{f=co(a)|0;while(1){if(!f){f=1;break b}l=c[f+16>>2]|0;n=l+232|0;c[n>>2]=(c[n>>2]|0)-(c[m+(c[l+128>>2]<<2)>>2]|0);f=eo(a,f)|0}}while(0);Mj(a,f);i=co(d)|0;while(1){if(!i)break;g=i+16|0;f=c[g>>2]|0;h=c[f+172>>2]|0;if(h){_I(h);f=c[g>>2]|0}f=c[f+180>>2]|0;if(f|0)_I(f);i=eo(d,i)|0}_I(c[(c[(co(a)|0)+16>>2]|0)+112>>2]|0);f=co(a)|0;while(1){if(!f)break;c[(c[f+16>>2]|0)+112>>2]=0;f=eo(a,f)|0}if(j)_I(o);return}function Lj(a){a=a|0;var b=0,d=0,e=0;b=a+16|0;d=(c[b>>2]|0)+152|0;e=c[d>>2]|0;if(e){if((e|0)!=(a|0)){e=Lj(e)|0;c[(c[b>>2]|0)+152>>2]=e;return e|0}}else c[d>>2]=a;return a|0}function Mj(a,d){a=a|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;i=a+16|0;e=1;while(1){f=c[i>>2]|0;if((e|0)>(c[f+180>>2]|0))break;Mj(c[(c[f+184>>2]|0)+(e<<2)>>2]|0,0);e=e+1|0}if((d|0)!=0|(c[f+200>>2]|0)!=0){b[f+236>>1]=32767;b[f+238>>1]=-1;e=0;h=co(a)|0;while(1){if(!h)break;g=c[(c[h+16>>2]|0)+232>>2]|0;d=c[i>>2]|0;f=d+238|0;if((g|0)>(b[f>>1]|0))b[f>>1]=g;d=d+236|0;if((g|0)<(b[d>>1]|0)){b[d>>1]=g;e=h}h=eo(a,h)|0}c[(c[i>>2]|0)+264>>2]=e}return}function Nj(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=(c[b+16>>2]|0)+128|0;a:do if(!(c[e>>2]|0)){c[e>>2]=d;e=Pm(a,b)|0;while(1){if(!e)break;Nj(a,c[((c[e>>2]&3|0)==2?e:e+-48|0)+40>>2]|0,d);e=Rm(a,e)|0}e=Sm(a,b)|0;while(1){if(!e)break a;Nj(a,c[((c[e>>2]&3|0)==3?e:e+48|0)+40>>2]|0,d);e=Tm(a,e)|0}}while(0);return}function Oj(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;f=no(a,b,1)|0;b=f+16|0;c[(c[b>>2]|0)+176>>2]=0;e=vw(20)|0;d=c[b>>2]|0;c[d+172>>2]=e;c[d+184>>2]=0;d=vw(20)|0;b=c[b>>2]|0;c[b+180>>2]=d;d=c[41933]|0;e=b+168|0;if(!d){c[e>>2]=0;c[(c[a+16>>2]|0)+192>>2]=f}else{c[e>>2]=d;c[(c[d+16>>2]|0)+164>>2]=f}c[41933]=f;c[b+164>>2]=0;return f|0}function Pj(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0;h=d+16|0;e=c[h>>2]|0;f=e+157|0;if(!(a[f>>0]|0)){a[f>>0]=1;a[e+158>>0]=1;d=Pm(b,d)|0;while(1){if(!d)break;e=Rm(b,d)|0;f=c[((c[d>>2]&3|0)==2?d:d+-48|0)+40>>2]|0;g=c[f+16>>2]|0;if(a[g+158>>0]|0){Qj(b,d);d=e;continue}if(a[g+157>>0]|0){d=e;continue}Pj(b,f);d=e}a[(c[h>>2]|0)+158>>0]=0}return}function Qj(a,b){a=a|0;b=b|0;var d=0,f=0,g=0;d=c[b>>2]&3;g=b+-48|0;f=b+48|0;d=an(a,c[((d|0)==2?b:g)+40>>2]|0,c[((d|0)==3?b:f)+40>>2]|0,0,0)|0;if(!d){d=c[b>>2]&3;d=an(a,c[((d|0)==2?b:g)+40>>2]|0,c[((d|0)==3?b:f)+40>>2]|0,0,1)|0}g=c[b+16>>2]|0;Rj(d,e[g+170>>1]|0,c[g+156>>2]|0);qo(a,b)|0;return}function Rj(a,d,f){a=a|0;d=d|0;f=f|0;var g=0,h=0;a=c[a+16>>2]|0;g=a+170|0;h=e[g>>1]|0;b[g>>1]=(h|0)>(d|0)?h:d;d=a+156|0;c[d>>2]=(c[d>>2]|0)+f;return}function Sj(a){a=a|0;return (JA(Im(a,80109)|0,0)|0)&255|0}function Tj(b){b=b|0;var d=0,e=0;d=c[42233]|0;if((((d|0)!=0?(e=Jm(b,d)|0,(e|0)!=0):0)?(a[e>>0]|0)!=0:0)?(IA(e)|0)<<24>>24==0:0)b=1;else b=0;return b|0}function Uj(a){a=a|0;var b=0,d=0;d=c[a>>2]&3;b=c[(c[(c[((d|0)==3?a:a+48|0)+40>>2]|0)+16>>2]|0)+212>>2]|0;a=c[(c[(c[((d|0)==2?a:a+-48|0)+40>>2]|0)+16>>2]|0)+212>>2]|0;if((b|0)==(a|0))return 1;else{d=Xj(b,a)|0;return ((d|0)==(b|0)|(d|0)==(a|0))&1|0}return 0}function Vj(a,b,d,f){a=a|0;b=b|0;d=d|0;f=f|0;var g=0,h=0,i=0,j=0;j=l;l=l+16|0;h=j;g=an(a,b,d,0,0)|0;if(!g){g=an(a,d,b,0,0)|0;if(!g){g=an(a,b,d,0,1)|0;if(!g){b=Dn(b)|0;f=Dn(d)|0;c[h>>2]=b;c[h+4>>2]=f;_l(1,80126,h)|0}else i=4}else i=4}else i=4;if((i|0)==4){i=c[f+16>>2]|0;Rj(g,e[i+170>>1]|0,c[i+156>>2]|0)}l=j;return}function Wj(a,d,f,g){a=a|0;d=d|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,m=0,n=0;m=l;l=l+112|0;j=m;i=m+4|0;h=Sm(a,d)|0;while(1){if(!h){k=6;break}n=Pm(a,c[((c[h>>2]&3|0)==3?h:h+48|0)+40>>2]|0)|0;if(n|0?(c[((c[n>>2]&3|0)==2?n:n+-48|0)+40>>2]|0)==(f|0):0)break;h=Tm(a,h)|0}if((k|0)==6){n=c[41934]|0;c[41934]=n+1;c[j>>2]=n;pL(i,80117,j)|0;i=Oj(a,i)|0;n=an(a,i,d,0,1)|0;i=an(a,i,f,0,1)|0;f=c[g+16>>2]|0;k=f+156|0;n=(c[n+16>>2]|0)+156|0;c[n>>2]=(c[n>>2]|0)+((c[k>>2]|0)*1e3|0);n=c[i+16>>2]|0;j=n+170|0;b[j>>1]=b[(c[((e[j>>1]|0)>(e[f+170>>1]|0)?i:g)+16>>2]|0)+170>>1]|0;n=n+156|0;c[n>>2]=(c[n>>2]|0)+(c[k>>2]|0)}l=m;return}function Xj(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;a:while(1){e=a+16|0;while(1){if((a|0)==(b|0))break a;f=c[e>>2]|0;d=c[b+16>>2]|0;if((c[f+204>>2]|0)>=(c[d+204>>2]|0))break;b=c[d+200>>2]|0}a=c[f+200>>2]|0}return a|0}function Yj(a){a=a|0;return (co(a)|0)==0|0}function Zj(a,b){a=a|0;b=b|0;c[(c[a+16>>2]|0)+200>>2]=b;yj(b,a);xj(b,a);return}function _j(b){b=b|0;var c=0;b=Im(b,80018)|0;if((b|0)!=0?(a[b>>0]|0)!=0:0)if(xJ(b,80028)|0)if(xJ(b,80032)|0)if(xJ(b,80039)|0)if(xJ(b,80043)|0)if(!(xJ(b,80023)|0))b=1;else c=8;else b=5;else b=4;else b=3;else b=2;else c=8;if((c|0)==8)b=6;return b|0}function $j(a){a=a|0;var b=0,c=0;c=co(a)|0;a:do if(!c)b=0;else{b=Lj(c)|0;while(1){c=eo(a,c)|0;if(!c)break a;ak(b,c)|0}}while(0);return b|0}function ak(a,b){a=a|0;b=b|0;if(b){a=Lj(a)|0;c[(c[(Lj(b)|0)+16>>2]|0)+152>>2]=a}return a|0}function bk(a,b,d){a=a|0;b=b|0;d=d|0;No(b,80077,c[d>>2]|0,1)|0;return}function ck(a,b,d){a=a|0;b=b|0;d=d|0;No(b,80244,c[d+4>>2]|0,1)|0;return}function dk(a,b,d){a=a|0;b=b|0;d=d|0;No(b,80229,c[d+8>>2]|0,1)|0;return}function ek(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0;p=l;l=l+240|0;m=p+120|0;n=p;c[42237]=ym(b,2,80259,0)|0;k=ym(b,2,80268,0)|0;c[42238]=k;a:do if((k|0)!=0|(c[42237]|0)!=0){k=co(b)|0;while(1){if(!k)break a;j=0;d=0;i=Um(b,k)|0;while(1){if(!i){f=0;break}e=c[i>>2]|0;g=e&3;f=c[((g|0)==2?i:i+-48|0)+40>>2]|0;h=i+48|0;b:do if((f|0)!=(c[((g|0)==3?i:h)+40>>2]|0)){g=c[42237]|0;do if((f|0)==(k|0)&(g|0)!=0){f=Jm(i,g)|0;if(!(a[f>>0]|0)){e=c[i>>2]|0;break}else{e=j;d=fk(m,d,k,i,f)|0;break b}}while(0);f=c[42238]|0;if((f|0?(c[((e&3|0)==3?i:h)+40>>2]|0)==(k|0):0)?(o=Jm(i,f)|0,(a[o>>0]|0)!=0):0)e=fk(n,j,k,i,o)|0;else e=j}else e=j;while(0);j=e;i=Vm(b,i,k)|0}while(1){if((f|0)>=(d|0)){e=0;break}e=m+(f*24|0)+4|0;if((c[m+(f*24|0)+8>>2]|0)>1)gk(k,e);e=c[e>>2]|0;if(e|0)_I(e);f=f+1|0}while(1){if((e|0)>=(j|0))break;d=n+(e*24|0)+4|0;if((c[n+(e*24|0)+8>>2]|0)>1)gk(k,d);d=c[d>>2]|0;if(d|0)_I(d);e=e+1|0}k=eo(b,k)|0}}while(0);l=p;return}function fk(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var i=0.0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;p=l;l=l+16|0;k=p;m=p+12|0;n=p+8|0;o=0;while(1){if((o|0)>=(d|0)){j=10;break}j=c[b+(o*24|0)>>2]|0;if((a[j>>0]|0)==(a[g>>0]|0)?(xJ(j,g)|0)==0:0){j=5;break}o=o+1|0}do if((j|0)==5){k=b+(o*24|0)+4|0;j=c[k>>2]|0;if(!j){j=b+(o*24|0)+8|0;g=j;j=ww((c[j>>2]<<2)+8|0)|0}else{q=b+(o*24|0)+8|0;g=q;j=yw(j,(c[q>>2]<<2)+8|0)|0}c[k>>2]=j;r=c[g>>2]|0;q=r+1|0;c[g>>2]=q;c[j+(r<<2)>>2]=f;c[(c[k>>2]|0)+(q<<2)>>2]=0;j=13}else if((j|0)==10)if((d|0)>4){r=Dn(e)|0;c[k>>2]=5;c[k+4>>2]=r;_l(1,80277,k)|0;break}else{s=b+(o*24|0)+8|0;c[s>>2]=0;k=vw(8)|0;r=b+(o*24|0)+4|0;c[r>>2]=k;q=c[s>>2]|0;j=q+1|0;c[s>>2]=j;c[k+(q<<2)>>2]=f;c[(c[r>>2]|0)+(j<<2)>>2]=0;c[b+(o*24|0)>>2]=g;c[b+(o*24|0)+12>>2]=0;h[b+(o*24|0)+16>>3]=0.0;d=d+1|0;j=13;break}while(0);if((j|0)==13){At(f,m,n);j=(c[((c[f>>2]&3|0)==2?f:f+-48|0)+40>>2]|0)==(e|0)?c[n>>2]|0:c[m>>2]|0;if(j){r=b+(o*24|0)+12|0;s=c[r>>2]|0;c[r>>2]=s+1;if(!s)i=+Et(f,j);else i=0.0;h[b+(o*24|0)+16>>3]=i}}l=p;return d|0}function gk(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,i=0,j=0.0,k=0.0,m=0.0,n=0,o=0.0,p=0.0,q=0.0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0.0;x=l;l=l+80|0;t=x+68|0;u=x+64|0;r=x;v=d+4|0;n=c[v>>2]|0;w=b+16|0;i=0;p=0.0;q=0.0;while(1){if((i|0)>=(n|0))break;f=c[(c[d>>2]|0)+(i<<2)>>2]|0;g=c[f>>2]&3;e=c[((g|0)==2?f:f+-48|0)+40>>2]|0;if((e|0)==(b|0))e=c[((g|0)==3?f:f+48|0)+40>>2]|0;g=c[e+16>>2]|0;s=c[w>>2]|0;k=+h[g+16>>3]-+h[s+16>>3];m=+h[g+24>>3]-+h[s+24>>3];o=+QJ(k,m);i=i+1|0;p=k/o+p;q=m/o+q}j=+QJ(p,q);s=c[w>>2]|0;k=+h[s+16>>3];m=+h[s+24>>3];y=+h[s+96>>3]+ +h[s+88>>3];o=+h[s+80>>3];s=y>o+ +(c[(c[(ro(b)|0)+16>>2]|0)+252>>2]|0);e=c[w>>2]|0;if(s)o=+h[e+96>>3]+ +h[e+88>>3];else{o=+h[e+80>>3];o=o+ +(c[(c[(ro(b)|0)+16>>2]|0)+252>>2]|0);e=c[w>>2]|0}y=+h[e+16>>3]+o*(p/j);j=+h[e+24>>3]+o*(q/j);h[r>>3]=k;n=r+8|0;h[n>>3]=m;h[r+16>>3]=(y+k*2.0)*.3333333333333333;h[r+24>>3]=(j+m*2.0)*.3333333333333333;h[r+32>>3]=(y*2.0+k)*.3333333333333333;h[r+40>>3]=(j*2.0+m)*.3333333333333333;h[r+48>>3]=y;h[r+56>>3]=j;Gz(b,r);s=c[w>>2]|0;j=+h[r>>3]-+h[s+16>>3];k=+h[n>>3]-+h[s+24>>3];j=+(~~(j+(j>=0.0?.5:-.5))|0);k=+(~~(k+(k>=0.0?.5:-.5))|0);y=+h[s+88>>3];s=~~((y+j)*256.0/(+h[s+96>>3]+y))&255;r=0;while(1){if((r|0)>=(c[v>>2]|0))break;n=c[(c[d>>2]|0)+(r<<2)>>2]|0;At(n,t,u);while(1){if(!n)break;else g=n;while(1){if(!g){i=n;break}e=c[g>>2]|0;i=g+-48|0;if((c[((e&3|0)==2?g:i)+40>>2]|0)==(b|0)){e=c[g+16>>2]|0;h[e+56>>3]=j;h[e+64>>3]=k;h[e+72>>3]=0.0;c[e+80>>2]=0;a[e+84>>0]=1;a[e+85>>0]=0;a[e+86>>0]=0;a[e+87>>0]=0;a[e+88>>0]=s;a[e+89>>0]=0;c[e+92>>2]=0;e=c[g>>2]|0}f=g+16|0;if((c[((e&3|0)==3?g:g+48|0)+40>>2]|0)==(b|0)){e=c[f>>2]|0;h[e+16>>3]=j;h[e+24>>3]=k;h[e+32>>3]=0.0;c[e+40>>2]=0;a[e+44>>0]=1;a[e+45>>0]=0;a[e+46>>0]=0;a[e+47>>0]=0;a[e+48>>0]=s;a[e+49>>0]=0;c[e+52>>2]=0}if((a[(c[f>>2]|0)+112>>0]|0)!=1){g=0;continue}e=c[(c[((c[g>>2]&3|0)==2?g:i)+40>>2]|0)+16>>2]|0;if((a[e+156>>0]|0)!=1){g=0;continue}if((c[e+184>>2]|0)!=1){g=0;continue}g=c[c[e+180>>2]>>2]|0}while(1){if(!i)break;e=c[i>>2]|0;if((c[((e&3|0)==2?i:i+-48|0)+40>>2]|0)==(b|0)){e=c[i+16>>2]|0;h[e+56>>3]=j;h[e+64>>3]=k;h[e+72>>3]=0.0;c[e+80>>2]=0;a[e+84>>0]=1;a[e+85>>0]=0;a[e+86>>0]=0;a[e+87>>0]=0;a[e+88>>0]=s;a[e+89>>0]=0;c[e+92>>2]=0;e=c[i>>2]|0}f=i+48|0;g=i+16|0;if((c[((e&3|0)==3?i:f)+40>>2]|0)==(b|0)){e=c[g>>2]|0;h[e+16>>3]=j;h[e+24>>3]=k;h[e+32>>3]=0.0;c[e+40>>2]=0;a[e+44>>0]=1;a[e+45>>0]=0;a[e+46>>0]=0;a[e+47>>0]=0;a[e+48>>0]=s;a[e+49>>0]=0;c[e+52>>2]=0}if((a[(c[g>>2]|0)+112>>0]|0)!=1){i=0;continue}e=c[(c[((c[i>>2]&3|0)==3?i:f)+40>>2]|0)+16>>2]|0;if((a[e+156>>0]|0)!=1){i=0;continue}if((c[e+176>>2]|0)!=1){i=0;continue}i=c[c[e+172>>2]>>2]|0}n=c[(c[n+16>>2]|0)+172>>2]|0}r=r+1|0}a[(c[w>>2]|0)+145>>0]=1;l=x;return}function hk(a){a=a|0;var b=0,d=0,e=0;Xg(a);b=c[a>>2]&3;d=a+-48|0;e=a+48|0;b=Sg(c[((b|0)==2?a:d)+40>>2]|0,c[((b|0)==3?a:e)+40>>2]|0)|0;if(!b){b=c[a>>2]&3;ah(c[((b|0)==2?a:d)+40>>2]|0,c[((b|0)==3?a:e)+40>>2]|0,a)|0}else ih(a,b);return}function ik(b){b=b|0;var d=0,e=0,f=0,g=0;f=b+16|0;e=0;while(1){b=c[f>>2]|0;if((e|0)>=(c[b+220>>2]|0))break;d=c[(c[b+216>>2]|0)+(e<<2)>>2]|0;c[b+192>>2]=d;b=d;d=b;while(1){if(!d)break;g=c[d+16>>2]|0;a[g+157>>0]=0;d=c[g+164>>2]|0}while(1){if(!b)break;jk(b);b=c[(c[b+16>>2]|0)+164>>2]|0}e=e+1|0}return}function jk(b){b=b|0;var d=0,e=0,f=0,g=0;g=b+16|0;d=c[g>>2]|0;b=d+157|0;if(!(a[b>>0]|0)){a[b>>0]=1;a[d+158>>0]=1;b=0;while(1){f=c[(c[d+180>>2]|0)+(b<<2)>>2]|0;if(!f)break;d=c[((c[f>>2]&3|0)==2?f:f+-48|0)+40>>2]|0;e=c[d+16>>2]|0;if(!(a[e+158>>0]|0)){if(!(a[e+157>>0]|0))jk(d)}else{hk(f);b=b+-1|0}b=b+1|0;d=c[g>>2]|0}a[d+158>>0]=0}return}function kk(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0;e=co(a)|0;b=0;while(1){if(!e)break;d=Pm(a,e)|0;while(1){if(!d)break;g=c[d>>2]&3;h=c[(c[(c[((g|0)==2?d:d+-48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0;g=c[(c[(c[((g|0)==3?d:d+48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0;f=h-g|0;d=Rm(a,d)|0;b=((h|0)==(g|0)?0:((f|0)>-1?f:0-f|0)+-1|0)+b|0}e=eo(a,e)|0}return b|0}function lk(b){b=b|0;var d=0,e=0,f=0,g=0;e=co(b)|0;while(1){if(!e)break;g=c[e+16>>2]|0;f=c[g+176>>2]|0;g=g+172|0;d=0;while(1){if((d|0)>=(f|0))break;a[(c[(c[(c[g>>2]|0)+(d<<2)>>2]|0)+16>>2]|0)+112>>0]=0;d=d+1|0}e=eo(b,e)|0}return}function mk(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,g=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0;q=l;l=l+16|0;o=q;j=c[b+24>>2]|0;nk(a);k=(j|0)==-1;m=b+8|0;i=k^1;n=c[13918]|0;f=1797693134862315708145274.0e284;g=0;while(1){if(!(k|(g|0)<(j|0)))break;d=co(a)|0;while(1){if(!d)break;c[(c[d+16>>2]|0)+232>>2]=0;d=eo(a,d)|0}jj(a);e=+ok(a);h[m>>3]=e;if(0){h[o>>3]=e;zL(n,80329,o)|0;e=+h[m>>3]}if(!(!(e<=+h[b>>3])&(!(f<=e)|i))){p=9;break}pk(a);f=e;g=g+1|0}if((p|0)==9){p=b+20|0;c[b+16>>2]=c[p>>2];c[p>>2]=g}jj(a);qk(a);rk();h[m>>3]=+ok(a);l=q;return}function nk(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,i=0,j=0,k=0,l=0.0,m=0.0,n=0;c[41938]=ww((mn(a)|0)*24|0)|0;c[41937]=0;b=co(a)|0;while(1){if(!b)break;c[(c[b+16>>2]|0)+120>>2]=-1;b=eo(a,b)|0}i=co(a)|0;while(1){if(!i)break;j=i+16|0;do if(!(c[(c[j>>2]|0)+216>>2]|0)){f=vw(4)|0;g=c[41938]|0;k=c[41937]|0;c[g+(k*24|0)>>2]=f;c[f>>2]=i;c[g+(k*24|0)+4>>2]=1;j=c[j>>2]|0;h[g+(k*24|0)+8>>3]=+h[j+32>>3];h[g+(k*24|0)+16>>3]=+h[j+40>>3];c[j+120>>2]=k;c[41937]=k+1}else{g=KA(i)|0;k=g+16|0;b=c[k>>2]|0;d=c[b+120>>2]|0;if((d|0)>-1){g=c[41938]|0;f=c[g+(d*24|0)>>2]|0;e=g+(d*24|0)+4|0;k=c[e>>2]|0;c[e>>2]=k+1;c[f+(k<<2)>>2]=i;k=c[j>>2]|0;j=g+(d*24|0)+8|0;h[j>>3]=+h[j>>3]+ +h[k+32>>3];j=g+(d*24|0)+16|0;l=+h[j>>3];m=+h[k+40>>3];h[j>>3]=l>2]=d;break}d=vw(c[b+216>>2]<<2)|0;e=c[41938]|0;f=c[41937]|0;b=e+(f*24|0)|0;c[b>>2]=d;c[d>>2]=g;if((g|0)==(i|0)){h[e+(f*24|0)+8>>3]=+h[(c[k>>2]|0)+32>>3];d=1;b=i}else{c[(c[b>>2]|0)+4>>2]=i;n=c[k>>2]|0;b=c[j>>2]|0;h[e+(f*24|0)+8>>3]=+h[b+32>>3]+ +h[n+32>>3];d=2;b=+h[n+40>>3]<+h[b+40>>3]?i:g}c[e+(f*24|0)+4>>2]=d;h[e+(f*24|0)+16>>3]=+h[(c[b+16>>2]|0)+40>>3];c[(c[k>>2]|0)+120>>2]=f;c[(c[j>>2]|0)+120>>2]=f;c[41937]=f+1}while(0);i=eo(a,i)|0}return}function ok(a){a=a|0;var b=0.0,d=0.0,e=0,f=0,g=0,i=0.0,j=0.0;qk(a);g=c[41935]|0;e=c[a+16>>2]|0;b=+(O(c[e+252>>2]|0,g+-1|0)|0);f=c[41936]|0;e=e+248|0;a=0;d=0.0;while(1){if((a|0)>=(g|0))break;i=+h[f+(a*40|0)+24>>3]+ +(O(c[e>>2]|0,c[f+(a*40|0)+16>>2]|0)|0);j=+h[f+(a*40|0)+32>>3]+b;a=a+1|0;b=j;d=d=(mn(a)|0))break;c[(c[41939]|0)+(b<<2)>>2]=b;b=b+1|0}qk(a);sk(a);tk(a);return}function qk(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,i=0,j=0.0,k=0,l=0;c[41935]=0;b=c[41936]|0;if(b|0){e=0;while(1){if((e|0)>=(c[41937]|0))break;d=c[b+(e*40|0)+4>>2]|0;if(d){_I(d);b=c[41936]|0}d=c[b+(e*40|0)+8>>2]|0;if(d){_I(d);b=c[41936]|0}e=e+1|0}_I(b)}c[41936]=vw((c[41937]|0)*40|0)|0;b=0;while(1){d=c[41937]|0;if((b|0)>=(d|0))break;k=vw(d<<2)|0;c[(c[41936]|0)+(b*40|0)+4>>2]=k;k=vw(c[41937]<<2)|0;l=c[41936]|0;c[l+(b*40|0)+8>>2]=k;c[l+(b*40|0)>>2]=b;c[l+(b*40|0)+12>>2]=0;c[l+(b*40|0)+16>>2]=0;l=l+(b*40|0)+24|0;c[l>>2]=0;c[l+4>>2]=0;c[l+8>>2]=0;c[l+12>>2]=0;b=b+1|0}e=co(a)|0;while(1){if(!e)break;d=Pm(a,e)|0;while(1){if(!d)break;i=c[d>>2]|0;f=d+-48|0;g=c[41936]|0;b=c[(c[(c[((i&3|0)==3?d:d+48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0;while(1){b=b+1|0;if((b|0)>=(c[(c[(c[((i&3|0)==2?d:f)+40>>2]|0)+16>>2]|0)+232>>2]|0))break;i=g+(b*40|0)+16|0;c[i>>2]=(c[i>>2]|0)+1;i=c[d>>2]|0}d=Rm(a,d)|0}e=eo(a,e)|0}i=c[41937]|0;k=c[41938]|0;l=c[41936]|0;d=a+16|0;b=0;while(1){if((b|0)>=(i|0))break;e=(c[c[k+(b*24|0)>>2]>>2]|0)+16|0;f=c[(c[e>>2]|0)+232>>2]|0;if((f|0)>=(c[41935]|0))c[41935]=f+1;g=l+(f*40|0)+24|0;j=+h[g>>3];h[g>>3]=j+ +h[k+(b*24|0)+8>>3]*72.0+(j>0.0?+(c[(c[d>>2]|0)+248>>2]|0):0.0);g=l+(f*40|0)+32|0;j=+h[k+(b*24|0)+16>>3]*72.0;if(+h[g>>3]>3]=j;c[(c[l+(f*40|0)+4>>2]|0)+(c[l+(f*40|0)+12>>2]<<2)>>2]=k+(b*24|0);a=l+((c[(c[e>>2]|0)+232>>2]|0)*40|0)+12|0;c[a>>2]=(c[a>>2]|0)+1;b=b+1|0}return}function rk(){var a=0,b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;k=c[41935]|0;l=c[41936]|0;j=0;b=0;a=0;while(1){if((j|0)>=(k|0))break;d=l+(j*40|0)|0;i=c[l+(j*40|0)+12>>2]|0;e=(b|0)==0;a:do if(i)if(!e){if((c[d>>2]|0)>(a|0)){f=l+(j*40|0)+4|0;d=0;while(1){if((d|0)>=(i|0))break a;g=c[(c[f>>2]|0)+(d<<2)>>2]|0;h=c[g+4>>2]|0;e=0;while(1){if((e|0)>=(h|0))break;m=(c[(c[(c[g>>2]|0)+(e<<2)>>2]|0)+16>>2]|0)+232|0;c[m>>2]=(c[m>>2]|0)-b;e=e+1|0}d=d+1|0}}}else b=0;else{if(e)a=c[d>>2]|0;b=b+1|0}while(0);j=j+1|0}return}function sk(a){a=a|0;var b=0;b=c[41939]|0;rL(b,mn(a)|0,4,15);return}function tk(b){b=b|0;var d=0.0,e=0,f=0,g=0,i=0,j=0,k=0,l=0,m=0.0,n=0,o=0,p=0,q=0,r=0.0,s=0;j=c[41935]|0;k=c[41936]|0;g=c[41939]|0;i=0;while(1){if((i|0)>=(j|0)){e=0;d=0.0;break}e=c[g+(i<<2)>>2]|0;f=i+1|0;if((c[k+(e*40|0)+12>>2]|0)<2)i=f;else{l=4;break}}if((l|0)==4)if((j|0)>(f|0))d=+h[k+((c[g+(f<<2)>>2]|0)*40|0)+24>>3];else d=0.0;a:do if((i|0)!=(j|0)){rL(c[k+(e*40|0)+4>>2]|0,c[k+(e*40|0)+12>>2]|0,4,16);g=c[41936]|0;r=+h[g+(e*40|0)+24>>3];r=!(d<=r*.25)&!(d>=r*.75)?d:r*.5;s=c[g+(e*40|0)+12>>2]|0;q=b+16|0;n=0;o=0;d=0.0;f=0;p=0;while(1){if((p|0)>=(f+s|0))break a;do if(!(c[(c[g+(e*40|0)+8>>2]|0)+(p<<2)>>2]|0)){l=c[(c[g+(e*40|0)+4>>2]|0)+(p<<2)>>2]|0;b=l+8|0;m=+h[b>>3]*72.0+d+(d>0.0?+(c[(c[q>>2]|0)+248>>2]|0):0.0);i=(o|0)!=0;if(!(i&!(m<=r))){j=i?n:l;i=i?o:1;d=m;break}j=n+4|0;k=l+4|0;i=0;while(1){if((i|0)<(c[j>>2]|0))g=0;else break;while(1){if((g|0)>=(c[k>>2]|0))break;a[(c[(ah(c[(c[n>>2]|0)+(i<<2)>>2]|0,c[(c[l>>2]|0)+(g<<2)>>2]|0,0)|0)+16>>2]|0)+112>>0]=1;g=g+1|0}i=i+1|0}g=c[41936]|0;c[(c[g+(e*40|0)+8>>2]|0)+(p<<2)>>2]=1;j=g+(e*40|0)+12|0;c[j>>2]=(c[j>>2]|0)+-1;j=g+(e*40|0)+16|0;c[j>>2]=(c[j>>2]|0)+1;j=g+(e*40|0)+24|0;h[j>>3]=+h[b>>3]*-72.0-+(c[(c[q>>2]|0)+248>>2]|0)+ +h[j>>3];j=n;i=o}else{j=n;i=o;f=f+1|0}while(0);n=j;o=i;p=p+1|0}}while(0);return}function uk(a,b){a=a|0;b=b|0;a=vk(c[a>>2]|0)|0;b=vk(c[b>>2]|0)|0;return ((b|0)<(a|0)&1)-((b|0)>(a|0)&1)|0}function vk(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;f=a+4|0;d=0;b=0;while(1){if((d|0)>=(c[f>>2]|0))break;e=c[(c[a>>2]|0)+(d<<2)>>2]|0;g=ro(e)|0;e=Pm(g,e)|0;while(1){if(!e)break;e=Rm(g,e)|0;b=b+1|0}d=d+1|0}return b|0}function wk(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0;f=c[41936]|0;e=+h[f+((c[b>>2]|0)*40|0)+24>>3];d=+h[f+((c[a>>2]|0)*40|0)+24>>3];return (e>d&1)-(e>2]|0)+216>>2]=0;b=eo(a,b)|0}return}function yk(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;g=l;l=l+32|0;f=g+16|0;e=g+8|0;d=g+20|0;c[d>>2]=5;a=Im(a,84624)|0;if(a|0?(c[e>>2]=g,c[e+4>>2]=d,(cM(a,80344,e)|0)>=1):0)_l(0,80351,f)|0;c[b+24>>2]=0;c[b+32>>2]=0;l=g;return 0}function zk(b){b=b|0;var d=0,e=0;d=c[42233]|0;if((((d|0)!=0?(e=Jm(b,d)|0,(e|0)!=0):0)?(a[e>>0]|0)!=0:0)?(IA(e)|0)<<24>>24==0:0)b=1;else b=0;return b|0}function Ak(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0;Vk(a);b=co(a)|0;while(1){if(!b)break;d=Pm(a,b)|0;while(1){if(!d)break;do if(((c[(c[d+16>>2]|0)+172>>2]|0)==0?(zk(d)|0)==0:0)?(e=d+48|0,f=KA(c[((c[d>>2]&3|0)==3?d:e)+40>>2]|0)|0,g=d+-48|0,h=KA(c[((c[d>>2]&3|0)==2?d:g)+40>>2]|0)|0,(f|0)!=(h|0)):0){if((c[(c[f+16>>2]|0)+212>>2]|0)==0?(c[(c[h+16>>2]|0)+212>>2]|0)==0:0){i=Sg(f,h)|0;if(!i){ah(f,h,d)|0;break}else{ih(d,i);break}}i=c[d>>2]&3;Bk(a,c[((i|0)==3?d:e)+40>>2]|0,c[((i|0)==2?d:g)+40>>2]|0,d)}while(0);d=Rm(a,d)|0}b=eo(a,b)|0}return}function Bk(b,d,f,g){b=b|0;d=d|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0;j=c[g>>2]&3;h=c[(c[((j|0)==3?g:g+48|0)+40>>2]|0)+16>>2]|0;i=c[h+212>>2]|0;if(!i)k=0;else k=(c[h+232>>2]|0)-(c[(c[(c[(c[i+16>>2]|0)+264>>2]|0)+16>>2]|0)+232>>2]|0)|0;h=c[(c[((j|0)==2?g:g+-48|0)+40>>2]|0)+16>>2]|0;i=c[h+212>>2]|0;if(!i)h=0;else h=(c[(c[(c[(c[i+16>>2]|0)+264>>2]|0)+16>>2]|0)+232>>2]|0)-(c[h+232>>2]|0)|0;j=g+16|0;k=h+k+(e[(c[j>>2]|0)+170>>1]|0)|0;b=fh(b)|0;a[(c[b+16>>2]|0)+156>>0]=2;i=KA(d)|0;d=KA(f)|0;f=Mi(b,i,(k|0)>0?0.0:+(0-k|0),(c[(c[j>>2]|0)+156>>2]|0)*10|0)|0;c[(c[(Mi(b,d,+(((k|0)>0?k:0)|0),c[(c[j>>2]|0)+156>>2]|0)|0)+16>>2]|0)+116>>2]=g;c[(c[f+16>>2]|0)+116>>2]=g;return}function Ck(a,d,f,g){a=a|0;d=d|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0;j=c[d>>2]&3;i=(j|0)==3?d:d+48|0;j=(j|0)==2?d:d+-48|0;j=c[(c[(c[((c[(c[(c[i+40>>2]|0)+16>>2]|0)+232>>2]|0)>(c[(c[(c[j+40>>2]|0)+16>>2]|0)+232>>2]|0)?i:j)+40>>2]|0)+16>>2]|0)+232>>2]|0;i=d+16|0;d=(c[i>>2]|0)+172|0;if(c[d>>2]|0)ma(80440,80462,148,80471);c[d>>2]=f;h=(g|0)==0;do{d=c[i>>2]|0;if(h)g=c[f+16>>2]|0;else{g=c[f+16>>2]|0;k=g+168|0;b[k>>1]=(e[k>>1]|0)+(e[d+168>>1]|0)}k=g+154|0;b[k>>1]=(e[k>>1]|0)+(e[d+154>>1]|0);g=g+156|0;c[g>>2]=(c[g>>2]|0)+(c[d+156>>2]|0);d=f+-48|0;g=c[((c[f>>2]&3|0)==2?f:d)+40>>2]|0;if((c[(c[g+16>>2]|0)+232>>2]|0)==(j|0))break;Dk(a,g);f=c[c[(c[(c[((c[f>>2]&3|0)==2?f:d)+40>>2]|0)+16>>2]|0)+180>>2]>>2]|0}while((f|0)!=0);return}function Dk(a,b){a=a|0;b=b|0;var d=0.0;d=+((c[(c[a+16>>2]|0)+248>>2]|0)/2|0|0);b=c[b+16>>2]|0;a=b+88|0;h[a>>3]=+h[a>>3]+d;b=b+96|0;h[b>>3]=+h[b>>3]+d;return}function Ek(a,b){a=a|0;b=b|0;var d=0,e=0;if(((((a|0)!=0&(b|0)!=0?(e=c[a>>2]&3,d=c[b>>2]&3,(c[((e|0)==3?a:a+48|0)+40>>2]|0)==(c[((d|0)==3?b:b+48|0)+40>>2]|0)):0)?(c[((e|0)==2?a:a+-48|0)+40>>2]|0)==(c[((d|0)==2?b:b+-48|0)+40>>2]|0):0)?(c[(c[a+16>>2]|0)+96>>2]|0)==(c[(c[b+16>>2]|0)+96>>2]|0):0)?(hj(a,b)|0)!=0:0)a=1;else a=0;return a|0}function Fk(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;r=b+16|0;d=c[r>>2]|0;c[d+192>>2]=0;c[d+232>>2]=0;Vk(b);d=1;while(1){e=c[r>>2]|0;if((d|0)>(c[e+180>>2]|0))break;Wk(b,c[(c[e+184>>2]|0)+(d<<2)>>2]|0);d=d+1|0}h=co(b)|0;while(1){if(!h)break;g=Pm(b,h)|0;while(1){if(!g)break;d=c[g>>2]|0;e=(c[(c[((d&3|0)==2?g:g+-48|0)+40>>2]|0)+16>>2]|0)+160|0;f=a[e>>0]|0;if(f<<24>>24<3){a[e>>0]=f+1<<24>>24;d=c[g>>2]|0}d=(c[(c[((d&3|0)==3?g:g+48|0)+40>>2]|0)+16>>2]|0)+160|0;e=a[d>>0]|0;if(e<<24>>24<3)a[d>>0]=e+1<<24>>24;g=Rm(b,g)|0}h=eo(b,h)|0}m=co(b)|0;while(1){if(!m)break;if((c[(c[m+16>>2]|0)+212>>2]|0)==0?(m|0)==(KA(m)|0):0){bh(b,m);l=(c[r>>2]|0)+232|0;c[l>>2]=(c[l>>2]|0)+1}d=0;l=Pm(b,m)|0;while(1){if(!l)break;k=l+16|0;h=c[k>>2]|0;a:do if(!(c[h+172>>2]|0)){if(Gk(l)|0){if(!(Ek(d,l)|0)){Hk(b,l);d=l;break}e=c[(c[d+16>>2]|0)+172>>2]|0;if(e|0){Ck(b,l,e,0);Yg(l);break}k=c[l>>2]&3;if((c[(c[(c[((k|0)==3?l:l+48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)!=(c[(c[(c[((k|0)==2?l:l+-48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0))break;ih(l,d);Yg(l);break}if(d){i=c[l>>2]&3;e=l+48|0;f=c[((i|0)==3?l:e)+40>>2]|0;g=c[d>>2]&3;if((f|0)==(c[((g|0)==3?d:d+48|0)+40>>2]|0)?(n=c[((i|0)==2?l:l+-48|0)+40>>2]|0,(n|0)==(c[((g|0)==2?d:d+-48|0)+40>>2]|0)):0){if((c[(c[f+16>>2]|0)+232>>2]|0)==(c[(c[n+16>>2]|0)+232>>2]|0)){ih(l,d);Yg(l);break}if(((c[h+96>>2]|0)==0?(o=d+16|0,(c[(c[o>>2]|0)+96>>2]|0)==0):0)?(hj(l,d)|0)!=0:0)if(!(a[174076]|0)){Ck(b,l,c[(c[o>>2]|0)+172>>2]|0,1);Yg(l);break}else{a[(c[k>>2]|0)+112>>0]=6;break}else i=e}else i=e}else i=l+48|0;h=c[l>>2]&3;e=c[((h|0)==3?l:i)+40>>2]|0;j=l+-48|0;if((e|0)==(c[((h|0)==2?l:j)+40>>2]|0)){Yg(l);d=l;break}e=KA(e)|0;f=KA(c[((c[l>>2]&3|0)==2?l:j)+40>>2]|0)|0;h=c[l>>2]&3;if((c[((h|0)==3?l:i)+40>>2]|0)==(e|0)?(c[((h|0)==2?l:j)+40>>2]|0)==(f|0):0){g=c[(c[e+16>>2]|0)+232>>2]|0;h=c[(c[f+16>>2]|0)+232>>2]|0;if((g|0)==(h|0)){gh(b,l);d=l;break}if((h|0)>(g|0)){Ik(b,e,f,l);d=l;break}e=an(b,f,e,0,0)|0;do if(e|0?(p=c[e>>2]&3,q=c[((p|0)==2?e:e+-48|0)+40>>2]|0,(q|0)!=(c[((c[l>>2]&3|0)==2?l:j)+40>>2]|0)):0){f=e+16|0;if(!(c[(c[f>>2]|0)+172>>2]|0))Ik(b,c[((p|0)==3?e:e+48|0)+40>>2]|0,q,e);if((c[(c[k>>2]|0)+96>>2]|0)==0?(c[(c[f>>2]|0)+96>>2]|0)==0:0){if(!(hj(l,e)|0))break;if(!(a[174076]|0)){Yg(l);Ck(b,l,c[(c[f>>2]|0)+172>>2]|0,1);break a}else{a[(c[k>>2]|0)+112>>0]=6;a[(c[f>>2]|0)+153>>0]=1;break a}}}while(0);d=c[l>>2]&3;Ik(b,c[((d|0)==2?l:j)+40>>2]|0,c[((d|0)==3?l:i)+40>>2]|0,l);d=l}}else d=l;while(0);l=Rm(b,l)|0}m=eo(b,m)|0}if((Vf(b)|0)!=(b|0)){d=c[(c[r>>2]|0)+216>>2]|0;if(!d)d=ww(4)|0;else d=yw(d,4)|0;r=c[r>>2]|0;c[r+216>>2]=d;c[d>>2]=c[r+192>>2]}return}function Gk(b){b=b|0;var d=0;d=c[b>>2]&3;if((a[(c[(c[((d|0)==3?b:b+48|0)+40>>2]|0)+16>>2]|0)+159>>0]|0)==7)b=1;else b=(a[(c[(c[((d|0)==2?b:b+-48|0)+40>>2]|0)+16>>2]|0)+159>>0]|0)==7&1;return b|0}function Hk(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;f=Lk(c[((c[d>>2]&3|0)==3?d:d+48|0)+40>>2]|0)|0;g=Lk(c[((c[d>>2]&3|0)==2?d:d+-48|0)+40>>2]|0)|0;i=(c[(c[f+16>>2]|0)+232>>2]|0)>(c[(c[g+16>>2]|0)+232>>2]|0);e=i?f:g;f=i?g:f;g=f+16|0;i=e+16|0;a:do if((c[(c[g>>2]|0)+212>>2]|0)!=(c[(c[i>>2]|0)+212>>2]|0)){h=Sg(f,e)|0;if(h|0){Ck(b,d,h,1);break}if((c[(c[g>>2]|0)+232>>2]|0)!=(c[(c[i>>2]|0)+232>>2]|0)){Ik(b,f,e,d);e=(c[d+16>>2]|0)+172|0;while(1){e=c[e>>2]|0;if(!e)break a;f=e+-48|0;if((c[(c[(c[((c[e>>2]&3|0)==2?e:f)+40>>2]|0)+16>>2]|0)+232>>2]|0)>(c[(c[i>>2]|0)+232>>2]|0))break a;a[(c[e+16>>2]|0)+112>>0]=5;e=c[(c[(c[((c[e>>2]&3|0)==2?e:f)+40>>2]|0)+16>>2]|0)+180>>2]|0}}}while(0);return}function Ik(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0;k=e+16|0;f=c[k>>2]|0;if(!(c[f+96>>2]|0))j=-1;else j=((c[(c[d+16>>2]|0)+232>>2]|0)+(c[(c[b+16>>2]|0)+232>>2]|0)|0)/2|0;if(c[f+172>>2]|0)ma(80483,80462,89,80508);i=d+16|0;h=c[(c[b+16>>2]|0)+232>>2]|0;while(1){g=h+1|0;f=c[(c[i>>2]|0)+232>>2]|0;if((h|0)>=(f|0))break;if((g|0)<(f|0)){if((g|0)==(j|0))f=Jk(a,e)|0;else f=Kk(a)|0;c[(c[f+16>>2]|0)+232>>2]=g}else f=d;vi(ah(b,f,e)|0);h=g;b=f}if(!(c[(c[k>>2]|0)+172>>2]|0))ma(80519,80462,103,80508);else return}function Jk(b,d){b=b|0;d=d|0;var e=0.0,f=0.0,g=0,i=0,j=0.0;i=d+16|0;g=c[(c[i>>2]|0)+96>>2]|0;e=+h[g+24>>3];f=+h[g+32>>3];g=fh(b)|0;d=g+16|0;c[(c[d>>2]|0)+104>>2]=c[(c[i>>2]|0)+96>>2];j=+(c[(c[(so(g)|0)+16>>2]|0)+248>>2]|0);h[(c[d>>2]|0)+88>>3]=j;if(!(a[(c[i>>2]|0)+114>>0]|0)){b=(c[(c[(so(b)|0)+16>>2]|0)+116>>2]&1|0)==0;i=c[d>>2]|0;h[i+80>>3]=b?f:e;h[i+96>>3]=b?e:f}return g|0}function Kk(a){a=a|0;var b=0;b=fh(a)|0;Dk(a,b);return b|0}function Lk(b){b=b|0;var d=0;d=c[b+16>>2]|0;if((a[d+159>>0]|0)==7)b=c[(c[(c[(c[d+212>>2]|0)+16>>2]|0)+268>>2]|0)+(c[d+232>>2]<<2)>>2]|0;else b=KA(b)|0;return b|0}function Mk(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;j=Vf(a)|0;h=co(a)|0;while(1){if(!h)break;b=Um(j,h)|0;i=0;while(1){if(!b)break;l=Vm(j,b,h)|0;if(Bo(a,b)|0){k=i;b=l;i=k;continue}k=(c[b>>2]&3|0)==2?b:b+-48|0;m=(Ek(i,k)|0)==0;e=c[k>>2]&3;b=c[((e|0)==3?k:k+48|0)+40>>2]|0;d=c[(c[b+16>>2]|0)+232>>2]|0;e=c[((e|0)==2?k:k+-48|0)+40>>2]|0;f=c[(c[e+16>>2]|0)+232>>2]|0;g=(d|0)==(f|0);if(!m){c[(c[k+16>>2]|0)+172>>2]=g?i:0;b=c[(c[i+16>>2]|0)+172>>2]|0;if(!b){m=i;b=l;i=m;continue}Ck(a,k,b,0);Zg(k);m=i;b=l;i=m;continue}if(!g)if((f|0)>(d|0)){Nk(b,e,k);b=l;i=k;continue}else{Nk(e,b,k);b=l;i=k;continue}b=Ug(b,e)|0;if(!b){gh(j,k);b=l;i=k;continue}if((k|0)==(b|0)){m=i;b=l;i=m;continue}Zg(k);if(c[(c[k+16>>2]|0)+172>>2]|0){m=i;b=l;i=m;continue}ih(k,b);m=i;b=l;i=m}h=eo(a,h)|0}return}function Nk(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;f=Ok(a)|0;e=Ok(b)|0;Pk(f,e,d,c[(c[d+16>>2]|0)+172>>2]|0,(f|0)==(a|0)&(e|0)==(b|0)?1:5);return}function Ok(b){b=b|0;var d=0,e=0,f=0;d=c[b+16>>2]|0;e=c[d+212>>2]|0;if((e|0)!=0?(f=c[e+16>>2]|0,(a[f+272>>0]|0)==0):0)b=c[(c[f+268>>2]|0)+(c[d+232>>2]<<2)>>2]|0;return b|0}function Pk(d,e,f,g,h){d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0;n=d+16|0;k=c[(c[n>>2]|0)+232>>2]|0;o=e+16|0;i=c[(c[o>>2]|0)+232>>2]|0;if((i|0)<=(k|0))ma(80544,80572,81,80582);m=c[g>>2]&3;if(!((c[((m|0)==3?g:g+48|0)+40>>2]|0)==(d|0)?(c[((m|0)==2?g:g+-48|0)+40>>2]|0)==(e|0):0))l=5;a:do if((l|0)==5){if((b[(c[g+16>>2]|0)+168>>1]|0)>1){c[(c[f+16>>2]|0)+172>>2]=0;if(((i-k|0)==1?(j=Sg(d,e)|0,j|0):0)?hj(f,j)|0:0){ih(f,j);if(a[(c[n>>2]|0)+156>>0]|0)break;if(a[(c[o>>2]|0)+156>>0]|0)break;Yg(f);break}m=h&255;h=d;l=c[(c[n>>2]|0)+232>>2]|0;while(1){i=c[(c[o>>2]|0)+232>>2]|0;if((l|0)>=(i|0))break a;if((l|0)<(i+-1|0)){i=Vf(d)|0;j=g+-48|0;i=Qk(i,c[((c[g>>2]&3|0)==2?g:j)+40>>2]|0)|0;k=g}else{i=e;j=g+-48|0;k=g}a[(c[(ah(h,i,f)|0)+16>>2]|0)+112>>0]=m;n=(c[g+16>>2]|0)+168|0;b[n>>1]=(b[n>>1]|0)+-1<<16>>16;h=i;l=l+1|0;g=c[c[(c[(c[((c[k>>2]&3|0)==2?g:j)+40>>2]|0)+16>>2]|0)+180>>2]>>2]|0}}do if((i-k|0)==1){g=Sg(d,e)|0;if(g|0?hj(f,g)|0:0){c[(c[f+16>>2]|0)+172>>2]=g;m=c[g+16>>2]|0;a[m+112>>0]=h;m=m+168|0;b[m>>1]=(b[m>>1]|0)+1<<16>>16;if(a[(c[n>>2]|0)+156>>0]|0)break;if(a[(c[o>>2]|0)+156>>0]|0)break;Yg(f);break}c[(c[f+16>>2]|0)+172>>2]=0;g=ah(d,e,f)|0;a[(c[g+16>>2]|0)+112>>0]=h}while(0);i=c[(c[o>>2]|0)+232>>2]|0;if((i-(c[(c[n>>2]|0)+232>>2]|0)|0)>1){if((c[((c[g>>2]&3|0)==3?g:g+48|0)+40>>2]|0)==(d|0))l=i;else{n=f+16|0;c[(c[n>>2]|0)+172>>2]=0;l=ah(d,c[((c[g>>2]&3|0)==2?g:g+-48|0)+40>>2]|0,f)|0;c[(c[n>>2]|0)+172>>2]=l;Xg(g);g=l;l=c[(c[o>>2]|0)+232>>2]|0}while(1){i=c[g>>2]&3;j=c[((i|0)==2?g:g+-48|0)+40>>2]|0;k=c[j+16>>2]|0;if((c[k+232>>2]|0)==(l|0))break;g=c[c[k+180>>2]>>2]|0}if((j|0)!=(e|0)){a[(c[(ah(c[((i|0)==3?g:g+48|0)+40>>2]|0,e,f)|0)+16>>2]|0)+112>>0]=h;Xg(g)}}}while(0);return}function Qk(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=b+16|0;b=c[d>>2]|0;e=c[b+232>>2]|0;Rk(a,e,c[b+236>>2]|0,2);b=fh(a)|0;d=c[d>>2]|0;f=c[b+16>>2]|0;h[f+88>>3]=+h[d+88>>3];h[f+96>>3]=+h[d+96>>3];c[f+232>>2]=c[d+232>>2];d=(c[d+236>>2]|0)+1|0;c[f+236>>2]=d;c[(c[(c[(c[a+16>>2]|0)+196>>2]|0)+(e<<6)+4>>2]|0)+(d<<2)>>2]=b;return b|0}function Rk(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;h=a+16|0;f=c[(c[h>>2]|0)+196>>2]|0;i=c[f+(b<<6)+4>>2]|0;a:do if((e|0)<1){d=d-e|0;while(1){g=d+1|0;a=c[f+(b<<6)>>2]|0;if((g|0)>=(a|0))break;a=c[i+(g<<2)>>2]|0;f=d+e|0;c[(c[a+16>>2]|0)+236>>2]=f;c[i+(f<<2)>>2]=a;d=g;f=c[(c[h>>2]|0)+196>>2]|0}g=e+-1|0;d=g+a|0;while(1){if((d|0)>=(a|0))break a;c[i+(d<<2)>>2]=0;f=c[(c[h>>2]|0)+196>>2]|0;d=d+1|0;a=c[f+(b<<6)>>2]|0}}else{g=e+-1|0;a=c[f+(b<<6)>>2]|0;while(1){a=a+-1|0;if((a|0)<=(d|0))break;j=c[i+(a<<2)>>2]|0;f=g+a|0;c[(c[j+16>>2]|0)+236>>2]=f;c[i+(f<<2)>>2]=j}f=e+d|0;a=d;while(1){a=a+1|0;if((a|0)>=(f|0))break;c[i+(a<<2)>>2]=0}a=c[(c[h>>2]|0)+196>>2]|0;f=a;a=c[a+(b<<6)>>2]|0}while(0);c[f+(b<<6)>>2]=g+a;return}function Sk(a){a=a|0;var b=0;Fk(a);b=c[a+16>>2]|0;c[b+220>>2]=1;c[c[b+216>>2]>>2]=c[b+192>>2];si(a);Zh(a,0);Tk(a);Mk(a);Uk(a);return}function Tk(d){d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;k=Vf(d)|0;l=d+16|0;f=c[l>>2]|0;j=b[f+236>>1]|0;e=j<<16>>16;m=k+16|0;if(j<<16>>16>0)a[(c[(c[m>>2]|0)+196>>2]|0)+(e+-1<<6)+49>>0]=0;j=e;while(1){if((j|0)>(b[f+238>>1]|0))break;i=c[(c[(c[(c[f+268>>2]|0)+(j<<2)>>2]|0)+16>>2]|0)+236>>2]|0;Rk(k,j,i,c[(c[f+196>>2]|0)+(j<<6)>>2]|0);g=0;h=i;while(1){f=c[l>>2]|0;e=c[f+196>>2]|0;if((g|0)>=(c[e+(j<<6)>>2]|0))break;e=c[(c[e+(j<<6)+4>>2]|0)+(g<<2)>>2]|0;c[(c[(c[(c[m>>2]|0)+196>>2]|0)+(j<<6)+4>>2]|0)+(h<<2)>>2]=e;f=c[e+16>>2]|0;c[f+236>>2]=h;if((a[f+156>>0]|0)==1)c[e+24>>2]=so(k)|0;dh(d,e);bh(k,e);f=(c[m>>2]|0)+232|0;c[f>>2]=(c[f>>2]|0)+1;g=g+1|0;h=h+1|0}h=c[(c[m>>2]|0)+196>>2]|0;c[e+(j<<6)+4>>2]=(c[h+(j<<6)+4>>2]|0)+(i<<2);a[h+(j<<6)+49>>0]=0;j=j+1|0}e=c[m>>2]|0;if((j|0)<(b[e+238>>1]|0))a[(c[e+196>>2]|0)+(j<<6)+49>>0]=0;a[f+272>>0]=1;return}function Uk(a){a=a|0;var d=0,e=0,f=0,g=0,h=0,i=0;i=a+16|0;d=c[i>>2]|0;h=b[d+236>>1]|0;while(1){if((h|0)>(b[d+238>>1]|0))break;f=c[(c[d+268>>2]|0)+(h<<2)>>2]|0;g=f+16|0;while(1){d=c[g>>2]|0;e=c[c[d+180>>2]>>2]|0;if(!e)break;Xg(e)}while(1){d=c[c[d+172>>2]>>2]|0;if(!d)break;Xg(d);d=c[g>>2]|0}dh(Vf(a)|0,f);c[(c[(c[i>>2]|0)+268>>2]|0)+(h<<2)>>2]=0;h=h+1|0;d=c[i>>2]|0}return}function Vk(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0;o=l;l=l+16|0;n=o;f=co(b)|0;while(1){if(!f)break;e=f+16|0;d=c[e>>2]|0;if((a[d+159>>0]|0)==7){MA(f);d=c[e>>2]|0}c[d+212>>2]=0;f=eo(b,f)|0}m=b+16|0;k=1;while(1){d=c[m>>2]|0;if((k|0)>(c[d+180>>2]|0))break;h=c[(c[d+184>>2]|0)+(k<<2)>>2]|0;i=h+16|0;d=co(h)|0;a:while(1){if(!d)break;j=eo(h,d)|0;e=d+16|0;if(a[(c[e>>2]|0)+159>>0]|0){f=Dn(d)|0;g=Dn(b)|0;c[n>>2]=f;c[n+4>>2]=g;_l(0,80591,n)|0;qo(h,d)|0;d=j;continue}NA(d,c[(c[i>>2]|0)+264>>2]|0);g=c[e>>2]|0;c[g+212>>2]=h;a[g+159>>0]=7;g=Pm(h,d)|0;while(1){if(!g){d=j;continue a}d=c[(c[g+16>>2]|0)+172>>2]|0;b:do if(d|0)do{e=d+-48|0;f=c[(c[((c[d>>2]&3|0)==2?d:e)+40>>2]|0)+16>>2]|0;if((a[f+156>>0]|0)!=1)break b;c[f+212>>2]=h;d=c[c[(c[(c[((c[d>>2]&3|0)==2?d:e)+40>>2]|0)+16>>2]|0)+180>>2]>>2]|0}while((d|0)!=0);while(0);g=Rm(h,g)|0}}k=k+1|0}l=o;return}function Wk(d,e){d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0;k=e+16|0;g=vw((b[(c[k>>2]|0)+238>>1]<<2)+8|0)|0;f=c[k>>2]|0;c[f+268>>2]=g;g=0;h=b[f+236>>1]|0;while(1){if((h|0)>(b[f+238>>1]|0))break;f=fh(d)|0;c[(c[(c[k>>2]|0)+268>>2]|0)+(h<<2)>>2]=f;j=c[f+16>>2]|0;c[j+232>>2]=h;a[j+159>>0]=7;c[j+212>>2]=e;if(g|0){j=(c[(ah(g,f,0)|0)+16>>2]|0)+154|0;b[j>>1]=(b[j>>1]|0)*1e3}g=f;h=h+1|0;f=c[k>>2]|0}j=co(e)|0;while(1){f=c[k>>2]|0;if(!j)break;h=(c[(c[f+268>>2]|0)+(c[(c[j+16>>2]|0)+232>>2]<<2)>>2]|0)+16|0;f=(c[h>>2]|0)+216|0;c[f>>2]=(c[f>>2]|0)+1;f=Pm(e,j)|0;while(1){if(!f)break;i=c[f>>2]|0;d=f+-48|0;g=c[(c[(c[((i&3|0)==3?f:f+48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0;while(1){if((g|0)>=(c[(c[(c[((i&3|0)==2?f:d)+40>>2]|0)+16>>2]|0)+232>>2]|0))break;i=(c[(c[c[(c[h>>2]|0)+180>>2]>>2]|0)+16>>2]|0)+168|0;b[i>>1]=(b[i>>1]|0)+1<<16>>16;g=g+1|0;i=c[f>>2]|0}f=Rm(e,f)|0}j=eo(e,j)|0}d=b[f+238>>1]|0;i=f+268|0;f=b[f+236>>1]|0;while(1){if((f|0)>(d|0))break;g=(c[(c[(c[i>>2]|0)+(f<<2)>>2]|0)+16>>2]|0)+216|0;h=c[g>>2]|0;if((h|0)>1)c[g>>2]=h+-1;f=f+1|0}return}function Xk(d,e,f,g){d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0;k=(c[(c[e+16>>2]|0)+212>>2]|0)+16|0;e=c[k>>2]|0;j=f+1|0;if((j|0)!=(a[e+273>>0]|0)){i=b[e+236>>1]|0;while(1){h=b[e+238>>1]|0;if((i|0)>(h<<16>>16|0))break;mi(d,c[(c[e+268>>2]|0)+(i<<2)>>2]|0);i=i+1|0;e=c[k>>2]|0}i=b[e+236>>1]|0;while(1){if((i|0)>(h<<16>>16|0))break;ni(g,c[(c[e+268>>2]|0)+(i<<2)>>2]|0,f);d=c[k>>2]|0;i=i+1|0;h=b[d+238>>1]|0;e=d}a[e+273>>0]=j}return}function Yk(b){b=b|0;var d=0,e=0,f=0,g=0,h=0;h=co(b)|0;while(1){if(!h)break;c[(c[h+16>>2]|0)+212>>2]=0;g=Pm(b,h)|0;while(1){if(!g)break;d=c[(c[g+16>>2]|0)+172>>2]|0;a:do if(d|0)do{e=d+-48|0;f=c[(c[((c[d>>2]&3|0)==2?d:e)+40>>2]|0)+16>>2]|0;if((a[f+156>>0]|0)!=1)break a;c[f+212>>2]=0;d=c[c[(c[(c[((c[d>>2]&3|0)==2?d:e)+40>>2]|0)+16>>2]|0)+180>>2]>>2]|0}while((d|0)!=0);while(0);g=Rm(b,g)|0}h=eo(b,h)|0}Zk(b);return}function Zk(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;e=b+16|0;d=1;while(1){f=c[e>>2]|0;if((d|0)>(c[f+180>>2]|0))break;Zk(c[(c[f+184>>2]|0)+(d<<2)>>2]|0);d=d+1|0}i=co(b)|0;while(1){if(!i)break;d=(c[i+16>>2]|0)+212|0;if(!(c[d>>2]|0))c[d>>2]=b;h=Pm(b,i)|0;while(1){if(!h)break;d=c[(c[h+16>>2]|0)+172>>2]|0;a:do if(d|0)do{e=c[d>>2]|0;g=d+-48|0;f=c[(c[((e&3|0)==2?d:g)+40>>2]|0)+16>>2]|0;if((a[f+156>>0]|0)!=1)break a;f=f+212|0;if(!(c[f>>2]|0)){c[f>>2]=b;e=c[d>>2]|0}d=c[c[(c[(c[((e&3|0)==2?d:g)+40>>2]|0)+16>>2]|0)+180>>2]>>2]|0}while((d|0)!=0);while(0);h=Rm(b,h)|0}i=eo(b,i)|0}return}function _k(a){a=a|0;var b=0,c=0,d=0;d=iB(a)|0;c=co(a)|0;while(1){if(!c)break;b=Pm(a,c)|0;while(1){if(!b)break;$k(b,d);b=Rm(a,b)|0}c=eo(a,c)|0}Kl(d)|0;return}function $k(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0;M=l;l=l+320|0;H=M+296|0;G=M+280|0;x=M+136|0;w=M+120|0;n=M+104|0;i=M+88|0;f=M+80|0;E=M+16|0;z=M;j=M+264|0;k=M+248|0;m=M+232|0;o=M+216|0;A=M+200|0;B=M+184|0;y=M+168|0;D=M+152|0;g=al(Im(a,80645)|0,b)|0;q=al(Im(a,80651)|0,b)|0;r=(q|0)!=0;b=(g|0)!=0;do if(b|r?(L=a+16|0,e=c[(c[L>>2]|0)+8>>2]|0,e|0):0){if((c[e+4>>2]|0)>1){K=Dn(c[((c[a>>2]&3|0)==3?a:a+48|0)+40>>2]|0)|0;L=Dn(c[((c[a>>2]&3|0)==2?a:a+-48|0)+40>>2]|0)|0;c[f>>2]=K;c[f+4>>2]=L;_l(0,80657,f)|0;break}I=c[e>>2]|0;e=c[I+4>>2]|0;p=c[a>>2]&3;s=a+-48|0;t=c[((p|0)==2?a:s)+40>>2]|0;u=a+48|0;p=c[((p|0)==3?a:u)+40>>2]|0;J=ww(48)|0;v=I+12|0;c[J+12>>2]=c[v>>2];C=I+8|0;c[J+8>>2]=c[C>>2];do if(b){h=(c[g+16>>2]|0)+16|0;g=(c[t+16>>2]|0)+16|0;c[H>>2]=c[g>>2];c[H+4>>2]=c[g+4>>2];c[H+8>>2]=c[g+8>>2];c[H+12>>2]=c[g+12>>2];if(!(bl(H,h)|0)){o=Dn(c[((c[a>>2]&3|0)==3?a:u)+40>>2]|0)|0;F=Dn(c[((c[a>>2]&3|0)==2?a:s)+40>>2]|0)|0;K=Im(a,80645)|0;c[i>>2]=o;c[i+4>>2]=F;c[i+8>>2]=K;_l(0,80698,i)|0;K=26;break}b=c[I>>2]|0;c[H>>2]=c[b>>2];c[H+4>>2]=c[b+4>>2];c[H+8>>2]=c[b+8>>2];c[H+12>>2]=c[b+12>>2];if(bl(H,h)|0){F=(c[p+16>>2]|0)+16|0;c[H>>2]=c[F>>2];c[H+4>>2]=c[F+4>>2];c[H+8>>2]=c[F+8>>2];c[H+12>>2]=c[F+12>>2];if(bl(H,h)|0){o=Dn(c[((c[a>>2]&3|0)==3?a:u)+40>>2]|0)|0;F=Dn(c[((c[a>>2]&3|0)==2?a:s)+40>>2]|0)|0;K=Im(a,80645)|0;c[n>>2]=o;c[n+4>>2]=F;c[n+8>>2]=K;_l(0,80741,n)|0;K=26;break}if(!(c[C>>2]|0))ma(80783,80794,369,80805);o=I+16|0;c[G>>2]=c[b>>2];c[G+4>>2]=c[b+4>>2];c[G+8>>2]=c[b+8>>2];c[G+12>>2]=c[b+12>>2];c[H>>2]=c[o>>2];c[H+4>>2]=c[o+4>>2];c[H+8>>2]=c[o+8>>2];c[H+12>>2]=c[o+12>>2];cl(z,G,H,h);F=(c[I>>2]|0)+48|0;c[F>>2]=c[z>>2];c[F+4>>2]=c[z+4>>2];c[F+8>>2]=c[z+8>>2];c[F+12>>2]=c[z+12>>2];F=(c[I>>2]|0)+16|0;c[G>>2]=c[z>>2];c[G+4>>2]=c[z+4>>2];c[G+8>>2]=c[z+8>>2];c[G+12>>2]=c[z+12>>2];c[H>>2]=c[o>>2];c[H+4>>2]=c[o+4>>2];c[H+8>>2]=c[o+8>>2];c[H+12>>2]=c[o+12>>2];dl(j,G,H);c[F>>2]=c[j>>2];c[F+4>>2]=c[j+4>>2];c[F+8>>2]=c[j+8>>2];c[F+12>>2]=c[j+12>>2];F=c[I>>2]|0;b=F+16|0;c[G>>2]=c[b>>2];c[G+4>>2]=c[b+4>>2];c[G+8>>2]=c[b+8>>2];c[G+12>>2]=c[b+12>>2];c[H>>2]=c[o>>2];c[H+4>>2]=c[o+4>>2];c[H+8>>2]=c[o+8>>2];c[H+12>>2]=c[o+12>>2];dl(k,G,H);c[F>>2]=c[k>>2];c[F+4>>2]=c[k+4>>2];c[F+8>>2]=c[k+8>>2];c[F+12>>2]=c[k+12>>2];F=c[I>>2]|0;b=F+32|0;F=F+16|0;c[G>>2]=c[F>>2];c[G+4>>2]=c[F+4>>2];c[G+8>>2]=c[F+8>>2];c[G+12>>2]=c[F+12>>2];c[H>>2]=c[z>>2];c[H+4>>2]=c[z+4>>2];c[H+8>>2]=c[z+8>>2];c[H+12>>2]=c[z+12>>2];dl(m,G,H);c[b>>2]=c[m>>2];c[b+4>>2]=c[m+4>>2];c[b+8>>2]=c[m+8>>2];c[b+12>>2]=c[m+12>>2];b=c[v>>2]|0;if(!b){F=3;break}F=(Nt(a,c[I>>2]|0,0,0,J,b)|0)+3|0;break}g=e+-1|0;b=0;while(1){if((b|0)>=(g|0))break;if(el((c[I>>2]|0)+(b<<4)|0,h)|0)break;b=b+3|0}e=c[v>>2]|0;f=(e|0)!=0;if((b|0)==(g|0))if(f){F=J+32|0;m=I+32|0;n=(c[I>>2]|0)+(g<<4)|0;c[G>>2]=c[m>>2];c[G+4>>2]=c[m+4>>2];c[G+8>>2]=c[m+8>>2];c[G+12>>2]=c[m+12>>2];c[H>>2]=c[n>>2];c[H+4>>2]=c[n+4>>2];c[H+8>>2]=c[n+8>>2];c[H+12>>2]=c[n+12>>2];cl(o,G,H,h);c[F>>2]=c[o>>2];c[F+4>>2]=c[o+4>>2];c[F+8>>2]=c[o+8>>2];c[F+12>>2]=c[o+12>>2];F=g;break}else ma(80822,80794,387,80805);else{if(f)b=Nt(a,c[I>>2]|0,0,b,J,e)|0;F=b+3|0;break}}else K=26;while(0);if((K|0)==26){b=e+-1|0;if(!(c[v>>2]|0))F=b;else{F=J+32|0;o=I+32|0;c[F>>2]=c[o>>2];c[F+4>>2]=c[o+4>>2];c[F+8>>2]=c[o+8>>2];c[F+12>>2]=c[o+12>>2];F=b}}do if(r){f=(c[q+16>>2]|0)+16|0;r=(c[p+16>>2]|0)+16|0;c[H>>2]=c[r>>2];c[H+4>>2]=c[r+4>>2];c[H+8>>2]=c[r+8>>2];c[H+12>>2]=c[r+12>>2];if(!(bl(H,f)|0)){G=Dn(c[((c[a>>2]&3|0)==3?a:u)+40>>2]|0)|0;H=Dn(c[((c[a>>2]&3|0)==2?a:s)+40>>2]|0)|0;K=Im(a,80651)|0;c[w>>2]=G;c[w+4>>2]=H;c[w+8>>2]=K;_l(0,80833,w)|0;K=52;break}b=(c[I>>2]|0)+(F<<4)|0;c[H>>2]=c[b>>2];c[H+4>>2]=c[b+4>>2];c[H+8>>2]=c[b+8>>2];c[H+12>>2]=c[b+12>>2];if(bl(H,f)|0){E=(c[t+16>>2]|0)+16|0;c[H>>2]=c[E>>2];c[H+4>>2]=c[E+4>>2];c[H+8>>2]=c[E+8>>2];c[H+12>>2]=c[E+12>>2];if(bl(H,f)|0){G=Dn(c[((c[a>>2]&3|0)==3?a:u)+40>>2]|0)|0;H=Dn(c[((c[a>>2]&3|0)==2?a:s)+40>>2]|0)|0;K=Im(a,80651)|0;c[x>>2]=G;c[x+4>>2]=H;c[x+8>>2]=K;_l(0,80876,x)|0;K=52;break}if(!(c[v>>2]|0))ma(80822,80794,429,80805);x=J+32|0;c[G>>2]=c[b>>2];c[G+4>>2]=c[b+4>>2];c[G+8>>2]=c[b+8>>2];c[G+12>>2]=c[b+12>>2];c[H>>2]=c[x>>2];c[H+4>>2]=c[x+4>>2];c[H+8>>2]=c[x+8>>2];c[H+12>>2]=c[x+12>>2];cl(z,G,H,f);d=F+-3|0;E=(c[I>>2]|0)+(d<<4)|0;c[E>>2]=c[z>>2];c[E+4>>2]=c[z+4>>2];c[E+8>>2]=c[z+8>>2];c[E+12>>2]=c[z+12>>2];E=F+-1|0;b=(c[I>>2]|0)+(E<<4)|0;c[G>>2]=c[z>>2];c[G+4>>2]=c[z+4>>2];c[G+8>>2]=c[z+8>>2];c[G+12>>2]=c[z+12>>2];c[H>>2]=c[x>>2];c[H+4>>2]=c[x+4>>2];c[H+8>>2]=c[x+8>>2];c[H+12>>2]=c[x+12>>2];dl(A,G,H);c[b>>2]=c[A>>2];c[b+4>>2]=c[A+4>>2];c[b+8>>2]=c[A+8>>2];c[b+12>>2]=c[A+12>>2];b=c[I>>2]|0;D=b+(F<<4)|0;b=b+(E<<4)|0;c[G>>2]=c[b>>2];c[G+4>>2]=c[b+4>>2];c[G+8>>2]=c[b+8>>2];c[G+12>>2]=c[b+12>>2];c[H>>2]=c[x>>2];c[H+4>>2]=c[x+4>>2];c[H+8>>2]=c[x+8>>2];c[H+12>>2]=c[x+12>>2];dl(B,G,H);c[D>>2]=c[B>>2];c[D+4>>2]=c[B+4>>2];c[D+8>>2]=c[B+8>>2];c[D+12>>2]=c[B+12>>2];D=c[I>>2]|0;b=D+(F+-2<<4)|0;E=D+(E<<4)|0;c[G>>2]=c[E>>2];c[G+4>>2]=c[E+4>>2];c[G+8>>2]=c[E+8>>2];c[G+12>>2]=c[E+12>>2];c[H>>2]=c[z>>2];c[H+4>>2]=c[z+4>>2];c[H+8>>2]=c[z+8>>2];c[H+12>>2]=c[z+12>>2];dl(y,G,H);c[b>>2]=c[y>>2];c[b+4>>2]=c[y+4>>2];c[b+8>>2]=c[y+8>>2];c[b+12>>2]=c[y+12>>2];b=c[C>>2]|0;if(!b)break;d=Pt(a,c[I>>2]|0,d,d,J,b)|0;break}e=F;while(1){if((e|0)>0)b=0;else break;while(1){if((b|0)==4)break;B=E+(b<<4)|0;A=(c[I>>2]|0)+(e-b<<4)|0;c[B>>2]=c[A>>2];c[B+4>>2]=c[A+4>>2];c[B+8>>2]=c[A+8>>2];c[B+12>>2]=c[A+12>>2];b=b+1|0}if(el(E,f)|0){b=0;K=43;break}e=e+-3|0}a:do if((K|0)==43)while(1){K=0;if((b|0)==4)break a;K=(c[I>>2]|0)+(e-b<<4)|0;B=E+(b<<4)|0;c[K>>2]=c[B>>2];c[K+4>>2]=c[B+4>>2];c[K+8>>2]=c[B+8>>2];c[K+12>>2]=c[B+12>>2];b=b+1|0;K=43}while(0);if(e|0){d=e+-3|0;b=c[C>>2]|0;if(!b)break;d=Pt(a,c[I>>2]|0,d,F+-3|0,J,b)|0;break}if(!(c[C>>2]|0))ma(80783,80794,452,80805);else{d=J+16|0;E=I+16|0;a=c[I>>2]|0;c[G>>2]=c[E>>2];c[G+4>>2]=c[E+4>>2];c[G+8>>2]=c[E+8>>2];c[G+12>>2]=c[E+12>>2];c[H>>2]=c[a>>2];c[H+4>>2]=c[a+4>>2];c[H+8>>2]=c[a+8>>2];c[H+12>>2]=c[a+12>>2];cl(D,G,H,f);c[d>>2]=c[D>>2];c[d+4>>2]=c[D+4>>2];c[d+8>>2]=c[D+8>>2];c[d+12>>2]=c[D+12>>2];d=0;break}}else K=52;while(0);if((K|0)==52)if(!(c[C>>2]|0))d=0;else{d=J+16|0;K=I+16|0;c[d>>2]=c[K>>2];c[d+4>>2]=c[K+4>>2];c[d+8>>2]=c[K+8>>2];c[d+12>>2]=c[K+12>>2];d=0}b=F-d+1|0;e=J+4|0;c[e>>2]=b;c[J>>2]=ww(b<<4)|0;b=0;while(1){if((b|0)>=(c[e>>2]|0))break;K=(c[J>>2]|0)+(b<<4)|0;a=(c[I>>2]|0)+(d<<4)|0;c[K>>2]=c[a>>2];c[K+4>>2]=c[a+4>>2];c[K+8>>2]=c[a+8>>2];c[K+12>>2]=c[a+12>>2];d=d+1|0;b=b+1|0}_I(c[I>>2]|0);_I(I);c[c[(c[L>>2]|0)+8>>2]>>2]=J}while(0);l=M;return}function al(b,d){b=b|0;d=d|0;var e=0,f=0;f=l;l=l+16|0;e=f;if((b|0)!=0?(a[b>>0]|0)!=0:0){d=jB(d,b)|0;if(!d){c[e>>2]=b;_l(0,80996,e)|0;d=0}}else d=0;l=f;return d|0}function bl(a,b){a=a|0;b=b|0;var c=0.0,d=0.0;d=+h[a>>3];if((+h[b>>3]<=d?d<=+h[b+16>>3]:0)?(c=+h[a+8>>3],+h[b+8>>3]<=c):0)a=c<=+h[b+24>>3]&1;else a=0;return a|0}function cl(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,g=0.0,i=0,j=0.0,k=0.0,m=0.0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0,v=0,w=0,x=0,y=0.0,z=0,A=0,B=0,C=0;C=l;l=l+464|0;n=C+48|0;B=C+32|0;u=C+16|0;v=C;w=C+364|0;x=C+264|0;z=C+164|0;A=C+64|0;q=+h[b>>3];r=+h[b+8>>3];s=+h[d>>3];t=+h[d+8>>3];c[u>>2]=c[e>>2];c[u+4>>2]=c[e+4>>2];c[u+8>>2]=c[e+8>>2];c[u+12>>2]=c[e+12>>2];e=e+16|0;c[v>>2]=c[e>>2];c[v+4>>2]=c[e+4>>2];c[v+8>>2]=c[e+8>>2];c[v+12>>2]=c[e+12>>2];k=+h[u>>3];if((s=+h[u+8>>3]):0)?f<=+h[v+8>>3]:0){o=f;p=k}else i=4;do if((i|0)==4){j=+h[v>>3];if(s>j){g=r+ +(~~((j-q)*(r-t)/(q-s))|0);f=+h[u+8>>3];if(g>=f?g<=+h[v+8>>3]:0){o=g;p=j;break}}else f=+h[u+8>>3];if(t=k)|!(m<=j))):0){o=f;p=m;break}f=+h[v+8>>3];if(t>f?(y=q+ +(~~((f-r)*(q-s)/(r-t))|0),!(!(y>=k)|!(y<=j))):0){o=f;p=y;break};c[n>>2]=c[b>>2];c[n+4>>2]=c[b+4>>2];c[n+8>>2]=c[b+8>>2];c[n+12>>2]=c[b+12>>2];w=jl(n,w)|0;c[n>>2]=c[d>>2];c[n+4>>2]=c[d+4>>2];c[n+8>>2]=c[d+8>>2];c[n+12>>2]=c[d+12>>2];x=jl(n,x)|0;c[n>>2]=c[u>>2];c[n+4>>2]=c[u+4>>2];c[n+8>>2]=c[u+8>>2];c[n+12>>2]=c[u+12>>2];z=jl(n,z)|0;c[n>>2]=c[v>>2];c[n+4>>2]=c[v+4>>2];c[n+8>>2]=c[v+8>>2];c[n+12>>2]=c[v+12>>2];A=jl(n,A)|0;c[B>>2]=w;c[B+4>>2]=x;c[B+8>>2]=z;c[B+12>>2]=A;_l(1,80918,B)|0;ma(123205,80794,78,80970)}while(0);h[a>>3]=p;h[a+8>>3]=o;l=C;return}function dl(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0;d=(+h[c+8>>3]+ +h[b+8>>3])*.5;h[a>>3]=(+h[c>>3]+ +h[b>>3])*.5;h[a+8>>3]=d;return}function el(a,b){a=a|0;b=b|0;var d=0.0,e=0,f=0.0,g=0,i=0,j=0,k=0,m=0;m=l;l=l+80|0;j=m+16|0;k=m;e=0;while(1){if((e|0)==4)break;i=j+(e<<4)|0;g=a+(e<<4)|0;c[i>>2]=c[g>>2];c[i+4>>2]=c[g+4>>2];c[i+8>>2]=c[g+8>>2];c[i+12>>2]=c[g+12>>2];e=e+1|0}e=b+8|0;i=b+24|0;d=+fl(a,0.0,1.0,+h[b>>3],+h[e>>3],+h[i>>3]);if(d>=0.0&d<2.0)PA(k,j,3,d,a,0);else d=2.0;g=b+16|0;f=+fl(a,0.0,d>1.0?1.0:d,+h[g>>3],+h[e>>3],+h[i>>3]);if(f>=0.0&f1.0?1.0:d,+h[e>>3],+h[b>>3],+h[g>>3]);if(f>=0.0&f1.0?1.0:d,+h[i>>3],+h[b>>3],+h[g>>3]);if(f>=0.0&f>3]-d))<=.005){b=+h[a+56>>3];b=!(b>=e)|!(b<=f)?-1.0:c;break a}break}default:{}}PA(i,a,3,.5,j,k);g=(c+b)*.5;b=+fl(j,b,g,d,e,f);if(!(b>=0.0))b=+fl(k,g,c,d,e,f)}while(0);l=m;return +b}function gl(a,b,c,d,e,f){a=a|0;b=+b;c=+c;d=+d;e=+e;f=+f;var g=0.0,i=0,j=0,k=0,m=0;m=l;l=l+144|0;j=m+80|0;k=m+16|0;i=m;a:do if(!(b==c)){switch(hl(a,d)|0){case 0:{b=-1.0;break a}case 1:{if(+B(+(+h[a+56>>3]-d))<=.005){b=+h[a+48>>3];b=!(b>=e)|!(b<=f)?-1.0:c;break a}break}default:{}}PA(i,a,3,.5,j,k);g=(c+b)*.5;b=+gl(j,b,g,d,e,f);if(!(b>=0.0))b=+gl(k,g,c,d,e,f)}while(0);l=m;return +b}function hl(a,b){a=a|0;b=+b;var c=0,d=0,e=0,f=0.0,g=0,i=0;f=+h[a+8>>3];e=fb&1;c=1;d=e;e=(e|0)==0&1;while(1){if((c|0)==4)break;f=+h[a+(c<<4)+8>>3];i=fb&1;g=e+((d|0)!=0&(i|0)!=(d|0)&1)|0;c=c+1|0;d=i;e=g}return e|0}function il(a,b){a=a|0;b=+b;var c=0,d=0,e=0,f=0.0,g=0,i=0;f=+h[a>>3];e=fb&1;c=1;d=e;e=(e|0)==0&1;while(1){if((c|0)==4)break;f=+h[a+(c<<4)>>3];i=fb&1;g=e+((d|0)!=0&(i|0)!=(d|0)&1)|0;c=c+1|0;d=i;e=g}return e|0}function jl(a,b){a=a|0;b=b|0;var c=0,d=0,e=0.0;c=l;l=l+16|0;d=c;e=+h[a+8>>3];h[d>>3]=+h[a>>3];h[d+8>>3]=e;pL(b,80984,d)|0;l=c;return b|0}function kl(a){a=a|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,q=0,r=0,s=0,t=0,u=0,v=0;v=l;l=l+16|0;s=v;u=4;t=ZI(40)|0;c[t>>2]=0;r=a+16|0;e=c[r>>2]|0;a:do if(((b[e+238>>1]|0)-(b[e+236>>1]|0)|0)>=2){m=1;d=e;e=c[e+196>>2]|0;b:while(1){n=m+1|0;if(!(c[e+(n<<6)>>2]|0)){q=15;break}else k=0;while(1){h=c[e+(m<<6)>>2]|0;if((k|0)>=(h|0)){m=n;continue b}j=c[(c[e+(m<<6)+4>>2]|0)+(k<<2)>>2]|0;o=0;d=_(18,j|0)|0;f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,t|0,u|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)==1){d=z;break b}if(d<<24>>24){i=k;d=h;while(1){g=i+1|0;if((g|0)>=(d|0))break;o=0;d=$(17,j|0,c[(c[e+(m<<6)+4>>2]|0)+(g<<2)>>2]|0)|0;e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,t|0,u|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){d=z;break b}if(!(d<<24>>24))break;d=c[(c[r>>2]|0)+196>>2]|0;i=g;e=d;d=c[d+(m<<6)>>2]|0}if((g-k|0)>1){o=0;ka(6,a|0,m|0,k|0,i|0,1);d=o;o=0;if((d|0)!=0&(p|0)!=0){e=SN(c[d>>2]|0,t|0,u|0)|0;if(!e)Ua(d|0,p|0);z=p}else e=-1;if((e|0)==1){d=z;break b}}}e=c[r>>2]|0;k=k+1|0;d=e;e=c[e+196>>2]|0}}c:do if((q|0)==15){while(1){if((m|0)>0)k=0;else break;while(1){e=c[d+196>>2]|0;h=c[e+(m<<6)>>2]|0;if((k|0)>=(h|0))break;j=c[(c[e+(m<<6)+4>>2]|0)+(k<<2)>>2]|0;o=0;d=_(19,j|0)|0;f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,t|0,u|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)==1){d=z;break c}if(d<<24>>24){i=k;d=h;while(1){g=i+1|0;if((g|0)>=(d|0))break;o=0;d=$(18,j|0,c[(c[e+(m<<6)+4>>2]|0)+(g<<2)>>2]|0)|0;e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,t|0,u|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){d=z;break c}if(!(d<<24>>24))break;d=c[(c[r>>2]|0)+196>>2]|0;i=g;e=d;d=c[d+(m<<6)>>2]|0}if((g-k|0)>1){o=0;ka(6,a|0,m|0,k|0,i|0,0);d=o;o=0;if((d|0)!=0&(p|0)!=0){e=SN(c[d>>2]|0,t|0,u|0)|0;if(!e)Ua(d|0,p|0);z=p}else e=-1;if((e|0)==1){d=z;break c}}}k=k+1|0;d=c[r>>2]|0}m=m+-1|0;q=15}t=RN(167760,1,t|0,u|0)|0;u=z;o=0;d=o;o=0;if((d|0)!=0&(p|0)!=0){e=SN(c[d>>2]|0,t|0,u|0)|0;if(!e)Ua(d|0,p|0);z=p}else e=-1;if((e|0)==1)d=z;else d=0}while(0);d:while(1){if(d){o=0;aa(11,3,81024,s|0)|0;d=o;o=0;if((d|0)!=0&(p|0)!=0){e=SN(c[d>>2]|0,t|0,u|0)|0;if(!e)Ua(d|0,p|0);z=p}else e=-1;if((e|0)==1){d=z;continue}else break}else f=1;while(1){d=c[r>>2]|0;if((f|0)>(c[d+180>>2]|0))break a;o=0;fa(85,c[(c[d+184>>2]|0)+(f<<2)>>2]|0);d=o;o=0;if((d|0)!=0&(p|0)!=0){e=SN(c[d>>2]|0,t|0,u|0)|0;if(!e)Ua(d|0,p|0);z=p}else e=-1;if((e|0)==1){d=z;continue d}f=f+1|0}}}while(0);_I(t|0);l=v;return}function ll(b){b=b|0;b=c[b+16>>2]|0;if(((a[b+156>>0]|0)==1?(c[b+176>>2]|0)==1:0)?(c[b+184>>2]|0)==1:0)b=(c[b+104>>2]|0)==0&1;else b=0;return b|0}function ml(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;i=l;l=l+80|0;h=i+40|0;g=i;e=c[c[(c[a+16>>2]|0)+172>>2]>>2]|0;a=c[c[(c[b+16>>2]|0)+172>>2]>>2]|0;if(((ll(b)|0)<<24>>24!=0?(c[((c[e>>2]&3|0)==3?e:e+48|0)+40>>2]|0)==(c[((c[a>>2]&3|0)==3?a:a+48|0)+40>>2]|0):0)?(sl(e,a)|0)<<24>>24!=0:0){d=(c[a+16>>2]|0)+16|0;f=g;a=(c[e+16>>2]|0)+16|0;b=f+40|0;do{c[f>>2]=c[a>>2];f=f+4|0;a=a+4|0}while((f|0)<(b|0));f=h;a=d;b=f+40|0;do{c[f>>2]=c[a>>2];f=f+4|0;a=a+4|0}while((f|0)<(b|0));a=(Wf(g,h)|0)==0&1}else a=0;l=i;return a|0}function nl(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;t=a+16|0;q=c[(c[(c[(c[t>>2]|0)+196>>2]|0)+(b<<6)+4>>2]|0)+(d<<2)>>2]|0;p=d+1|0;m=(f|0)==1;n=q+16|0;l=p;while(1){if((l|0)>(e|0)){g=e;s=p;break}o=c[(c[(c[(c[t>>2]|0)+196>>2]|0)+(b<<6)+4>>2]|0)+(l<<2)>>2]|0;k=o+16|0;a:do if(m)while(1){d=c[k>>2]|0;j=c[c[d+180>>2]>>2]|0;if(!j)break a;h=c[(c[n>>2]|0)+180>>2]|0;i=j+-48|0;f=0;while(1){d=c[h+(f<<2)>>2]|0;if(!d){r=8;break}if((c[((c[d>>2]&3|0)==2?d:d+-48|0)+40>>2]|0)==(c[((c[j>>2]&3|0)==2?j:i)+40>>2]|0))break;else f=f+1|0}if((r|0)==8){r=0;d=ah(q,c[((c[j>>2]&3|0)==2?j:i)+40>>2]|0,j)|0}while(1){f=c[c[(c[k>>2]|0)+172>>2]>>2]|0;if(!f)break;ih(f,d);Xg(f)}Xg(j)}else while(1){d=c[k>>2]|0;j=c[c[d+172>>2]>>2]|0;if(!j)break a;h=c[(c[n>>2]|0)+172>>2]|0;i=j+48|0;f=0;while(1){d=c[h+(f<<2)>>2]|0;if(!d){r=17;break}if((c[((c[d>>2]&3|0)==3?d:d+48|0)+40>>2]|0)==(c[((c[j>>2]&3|0)==3?j:i)+40>>2]|0))break;else f=f+1|0}if((r|0)==17){r=0;d=ah(c[((c[j>>2]&3|0)==3?j:i)+40>>2]|0,q,j)|0}while(1){f=c[c[(c[k>>2]|0)+180>>2]>>2]|0;if(!f)break;ih(f,d);Xg(f)}Xg(j)}while(0);if((c[d+176>>2]|0)!=(0-(c[d+184>>2]|0)|0)){r=23;break}dh(a,o);l=l+1|0}if((r|0)==23)ma(81160,81204,115,81211);while(1){g=g+1|0;d=c[(c[t>>2]|0)+196>>2]|0;f=d+(b<<6)|0;if((g|0)>=(c[f>>2]|0))break;e=c[d+(b<<6)+4>>2]|0;r=c[e+(g<<2)>>2]|0;c[e+(s<<2)>>2]=r;c[(c[r+16>>2]|0)+236>>2]=s;s=s+1|0}c[f>>2]=s;c[(c[d+(b<<6)+4>>2]|0)+(s<<2)>>2]=0;return}function ol(b){b=b|0;b=c[b+16>>2]|0;if(((a[b+156>>0]|0)==1?(c[b+184>>2]|0)==1:0)?(c[b+176>>2]|0)==1:0)b=(c[b+104>>2]|0)==0&1;else b=0;return b|0}function pl(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;i=l;l=l+80|0;h=i+40|0;g=i;e=c[c[(c[a+16>>2]|0)+180>>2]>>2]|0;a=c[c[(c[b+16>>2]|0)+180>>2]>>2]|0;if(((ol(b)|0)<<24>>24!=0?(c[((c[e>>2]&3|0)==2?e:e+-48|0)+40>>2]|0)==(c[((c[a>>2]&3|0)==2?a:a+-48|0)+40>>2]|0):0)?(sl(e,a)|0)<<24>>24!=0:0){d=(c[a+16>>2]|0)+56|0;f=g;a=(c[e+16>>2]|0)+56|0;b=f+40|0;do{c[f>>2]=c[a>>2];f=f+4|0;a=a+4|0}while((f|0)<(b|0));f=h;a=d;b=f+40|0;do{c[f>>2]=c[a>>2];f=f+4|0;a=a+4|0}while((f|0)<(b|0));a=(Wf(g,h)|0)==0&1}else a=0;l=i;return a|0}function ql(d){d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0;r=l;l=l+32|0;p=r+16|0;o=r;m=d+16|0;f=c[m>>2]|0;e=b[f+236>>1]|0;while(1){if((e|0)>(b[f+238>>1]|0))break;c[(c[f+268>>2]|0)+(e<<2)>>2]=0;e=e+1|0;f=c[m>>2]|0}ij(d);j=co(d)|0;while(1){if(!j)break;rl(d,j);i=Pm(d,j)|0;while(1){if(!i)break;else f=i;while(1){e=c[(c[f+16>>2]|0)+172>>2]|0;if(!e)break;else f=e}h=i+-48|0;while(1){e=f+-48|0;g=c[((c[f>>2]&3|0)==2?f:e)+40>>2]|0;if((c[(c[g+16>>2]|0)+232>>2]|0)>=(c[(c[(c[((c[i>>2]&3|0)==2?i:h)+40>>2]|0)+16>>2]|0)+232>>2]|0))break;rl(d,g);f=c[c[(c[(c[((c[f>>2]&3|0)==2?f:e)+40>>2]|0)+16>>2]|0)+180>>2]>>2]|0}i=Rm(d,i)|0}j=eo(d,j)|0}e=c[m>>2]|0;i=b[e+236>>1]|0;while(1){if((i|0)>(b[e+238>>1]|0)){k=1;n=e;break}e=c[(c[e+268>>2]|0)+(i<<2)>>2]|0;j=c[(c[(c[(Vf(d)|0)+16>>2]|0)+196>>2]|0)+(i<<6)+4>>2]|0;f=e+16|0;if((c[j+(c[(c[f>>2]|0)+236>>2]<<2)>>2]|0)!=(e|0)){q=17;break}h=c[(c[(c[(Vf(d)|0)+16>>2]|0)+196>>2]|0)+(i<<6)+4>>2]|0;e=c[m>>2]|0;f=c[e+196>>2]|0;c[f+(i<<6)+4>>2]=h+(c[(c[(c[(c[e+268>>2]|0)+(i<<2)>>2]|0)+16>>2]|0)+236>>2]<<2);e=-1;h=0;a:while(1){if((h|0)>=(c[f+(i<<6)>>2]|0))break;f=c[(c[f+(i<<6)+4>>2]|0)+(h<<2)>>2]|0;if(!f)break;g=c[f+16>>2]|0;b:do if(!(a[g+156>>0]|0))if(!(Bo(d,f)|0))break a;else e=h;else{f=c[c[g+172>>2]>>2]|0;while(1){if(!f)break b;g=c[(c[f+16>>2]|0)+116>>2]|0;if(!g)break;else f=g}if(Bo(d,c[((c[f>>2]&3|0)==3?f:f+48|0)+40>>2]|0)|0){j=(Bo(d,c[((c[f>>2]&3|0)==2?f:f+-48|0)+40>>2]|0)|0)==0;e=j?e:h}}while(0);h=h+1|0;f=c[(c[m>>2]|0)+196>>2]|0}if((e|0)==-1){c[p>>2]=Dn(d)|0;c[p+4>>2]=i;_l(0,81124,p)|0}j=c[m>>2]|0;c[(c[j+196>>2]|0)+(i<<6)>>2]=e+1;i=i+1|0;e=j}if((q|0)==17){p=Dn(e)|0;q=c[(c[f>>2]|0)+236>>2]|0;c[o>>2]=p;c[o+4>>2]=q;c[o+8>>2]=i;_l(1,81066,o)|0;Ua(167760,1)}while(1){if((k|0)>(c[n+180>>2]|0))break;ql(c[(c[n+184>>2]|0)+(k<<2)>>2]|0);k=k+1|0;n=c[m>>2]|0}l=r;return}function rl(a,b){a=a|0;b=b|0;var d=0,e=0;d=c[b+16>>2]|0;a=(c[(c[a+16>>2]|0)+268>>2]|0)+(c[d+232>>2]<<2)|0;e=c[a>>2]|0;if(!((e|0)!=0?(c[(c[e+16>>2]|0)+236>>2]|0)<=(c[d+236>>2]|0):0))c[a>>2]=b;return}function sl(b,d){b=b|0;d=d|0;var e=0,f=0;while(1){f=c[b+16>>2]|0;if(!(a[f+112>>0]|0))break;b=c[f+116>>2]|0}while(1){e=c[d+16>>2]|0;if(!(a[e+112>>0]|0))break;d=c[e+116>>2]|0}if((a[f+153>>0]|0)==0?(a[e+153>>0]|0)==0:0){f=c[d>>2]&3;e=c[b>>2]&3;b=(O((c[(c[(c[((e|0)==3?b:b+48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)-(c[(c[(c[((e|0)==2?b:b+-48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)|0,(c[(c[(c[((f|0)==3?d:d+48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)-(c[(c[(c[((f|0)==2?d:d+-48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)|0)|0)>0&1}else b=0;return b|0}function tl(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0;k=l;l=l+544|0;j=k+528|0;ul(j,k+512|0,k);e=(a[173894]|0)+1<<24>>24;a[173894]=e<<24>>24==0?1:e;e=c[b+16>>2]|0;c[e+220>>2]=0;c[e+232>>2]=0;e=(d|0)>0;d=co(b)|0;while(1){if(!d)break;if(e?(h=c[d+16>>2]|0,i=c[h+212>>2]|0,(i|0)!=0):0){g=c[(c[(c[i+16>>2]|0)+268>>2]|0)+(c[h+232>>2]<<2)>>2]|0;f=7}else f=6;if((f|0)==6?(f=0,(d|0)==(KA(d)|0)):0){g=d;f=7}if((f|0)==7?(0,(a[(c[g+16>>2]|0)+157>>0]|0)!=(a[173894]|0)):0){vl(b);wl(j,b,g);xl(b)}d=eo(b,d)|0}yl(j);l=k;return}function ul(a,b,d){a=a|0;b=b|0;d=d|0;c[b>>2]=d;c[b+4>>2]=d+512;c[b+12>>2]=0;c[b+8>>2]=0;c[a>>2]=b;c[a+4>>2]=b;c[a+8>>2]=d;return}function vl(a){a=a|0;c[(c[a+16>>2]|0)+192>>2]=0;c[41979]=0;return}function wl(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0;q=l;l=l+32|0;p=q;zl(b,e);k=p+8|0;m=p+16|0;n=p+24|0;a:while(1){o=Al(b)|0;if(!o)break;e=o+16|0;if((a[(c[e>>2]|0)+157>>0]|0)==(a[173894]|0))continue;Bl(d,o);h=c[e>>2]|0;g=h+180|0;j=c[g+4>>2]|0;i=p;c[i>>2]=c[g>>2];c[i+4>>2]=j;i=h+172|0;j=c[i+4>>2]|0;g=k;c[g>>2]=c[i>>2];c[g+4>>2]=j;g=h+188|0;j=c[g+4>>2]|0;i=m;c[i>>2]=c[g>>2];c[i+4>>2]=j;h=h+196|0;i=c[h+4>>2]|0;j=n;c[j>>2]=c[h>>2];c[j+4>>2]=i;j=3;while(1){if((j|0)<=-1)continue a;e=c[p+(j<<3)>>2]|0;b:do if(e|0){i=(c[p+(j<<3)+4>>2]|0)+-1|0;h=e+(i<<2)|0;while(1){if((i|0)<=-1)break b;f=c[h>>2]|0;g=c[f>>2]&3;e=c[((g|0)==2?f:f+-48|0)+40>>2]|0;if((e|0)==(o|0))e=c[((g|0)==3?f:f+48|0)+40>>2]|0;if((a[(c[e+16>>2]|0)+157>>0]|0)!=(a[173894]|0)?(e|0)==(KA(e)|0):0)zl(b,e);h=h+-4|0;i=i+-1|0}}while(0);j=j+-1|0}}l=q;return}function xl(a){a=a|0;var b=0,d=0,e=0,f=0;d=a+16|0;b=c[d>>2]|0;f=b+220|0;e=c[f>>2]|0;a=e+1|0;c[f>>2]=a;b=c[b+216>>2]|0;if(!b)a=ww(a<<2)|0;else a=yw(b,a<<2)|0;f=c[d>>2]|0;c[f+216>>2]=a;c[a+(e<<2)>>2]=c[f+192>>2];return}function yl(a){a=a|0;var b=0;a=c[(c[a>>2]|0)+12>>2]|0;while(1){if(!a)break;b=c[a+12>>2]|0;_I(c[a>>2]|0);_I(a);a=b}return}function zl(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0;k=l;l=l+16|0;h=k+8|0;g=k;j=b+8|0;f=c[j>>2]|0;i=b+4|0;b=c[i>>2]|0;if((f|0)==(c[b+4>>2]|0)){f=c[b+12>>2]|0;if(!f){f=vw(16)|0;if(!f)_l(1,83988,g)|0;c[f+8>>2]=c[i>>2];c[f+12>>2]=0;b=vw(4e6)|0;c[f>>2]=b;if(!b){_l(1,81224,h)|0;b=c[f>>2]|0}c[f+4>>2]=b+4e6;c[(c[i>>2]|0)+12>>2]=f}c[i>>2]=f;f=c[f>>2]|0;c[j>>2]=f}a[(c[e+16>>2]|0)+157>>0]=(d[173894]|0)+1;c[j>>2]=f+4;c[f>>2]=e;l=k;return}function Al(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;f=a+8|0;b=c[f>>2]|0;d=a+4|0;e=c[d>>2]|0;if((b|0)==(c[e>>2]|0))if((e|0)==(c[a>>2]|0))b=0;else{b=c[e+8>>2]|0;c[d>>2]=b;b=c[b+4>>2]|0;c[f>>2]=b;g=4}else g=4;if((g|0)==4){b=b+-4|0;c[f>>2]=b;b=c[b>>2]|0}return b|0}function Bl(b,d){b=b|0;d=d|0;var e=0,f=0,g=0;f=c[b+16>>2]|0;g=f+232|0;c[g>>2]=(c[g>>2]|0)+1;g=c[d+16>>2]|0;a[g+157>>0]=a[173894]|0;b=c[41979]|0;e=g+168|0;if(!b){c[e>>2]=0;c[f+192>>2]=d}else{c[e>>2]=b;c[(c[b+16>>2]|0)+164>>2]=d}c[41979]=d;c[g+164>>2]=0;return}function Cl(b){b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0.0,o=0.0;m=b+16|0;d=(c[m>>2]|0)+192|0;while(1){d=c[d>>2]|0;if(!d)break;g=d+16|0;d=c[g>>2]|0;e=c[d+188>>2]|0;a:do if(!e)f=0;else{f=0;while(1){e=c[e+(f<<2)>>2]|0;if(!e){f=0;break a}Dl(e);d=c[g>>2]|0;f=f+1|0;e=c[d+188>>2]|0}}while(0);while(1){if((f|0)>=(c[d+208>>2]|0))break;e=c[(c[d+204>>2]|0)+(f<<2)>>2]|0;l=c[e>>2]&3;if((c[(c[(c[((l|0)==2?e:e+-48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)==(c[(c[(c[((l|0)==3?e:e+48|0)+40>>2]|0)+16>>2]|0)+232>>2]|0)){Dl(e);d=c[g>>2]|0}f=f+1|0}d=d+164|0}l=c[m>>2]|0;d=c[l+196>>2]|0;if(!((c[d+56>>2]|0)==0?(c[l+180>>2]|0)<=0:0))i=13;b:do if((i|0)==13){i=c[d+4>>2]|0;g=0;c:while(1){d=c[i+(g<<2)>>2]|0;if(!d)break b;e=c[(c[d+16>>2]|0)+196>>2]|0;d=0;while(1){f=c[e+(d<<2)>>2]|0;if(!f)break;l=c[f+16>>2]|0;if(c[l+96>>2]|0?(a[l+113>>0]|0)==0:0)break c;d=d+1|0}g=g+1|0}El(b)}while(0);ui(b);e=0;d=(c[m>>2]|0)+192|0;while(1){d=c[d>>2]|0;if(!d)break;l=d+16|0;d=c[l>>2]|0;f=c[d+188>>2]|0;d:do if(f){k=0;while(1){g=c[f+(k<<2)>>2]|0;if(!g){k=0;break}i=c[g+16>>2]|0;j=c[i+96>>2]|0;do if(j)if(!(a[i+113>>0]|0)){Fl(g);f=c[l>>2]|0;e=1;d=f;f=c[f+188>>2]|0;break}else{h[i+136>>3]=+h[((c[(c[m>>2]|0)+116>>2]&1|0)==0?j+24|0:j+32|0)>>3];break}while(0);k=k+1|0}while(1){if((k|0)>=(c[d+208>>2]|0))break d;i=c[(c[d+204>>2]|0)+(k<<2)>>2]|0;j=c[i>>2]&3;g=c[((j|0)==3?i:i+48|0)+40>>2]|0;j=c[((j|0)==2?i:i+-48|0)+40>>2]|0;do if(!((g|0)==(j|0)?1:(c[(c[g+16>>2]|0)+232>>2]|0)!=(c[(c[j+16>>2]|0)+232>>2]|0))){f=i;do{j=c[f+16>>2]|0;f=c[j+172>>2]|0}while((f|0)!=0);f=a[j+113>>0]|0;g=c[i+16>>2]|0;a[g+113>>0]=f;g=c[g+96>>2]|0;if(g)if(!(f<<24>>24)){Fl(i);e=1;d=c[l>>2]|0;break}else{o=+h[((c[(c[m>>2]|0)+116>>2]&1|0)==0?g+24|0:g+32|0)>>3];j=j+136|0;n=+h[j>>3];h[j>>3]=o>n?o:n;break}}while(0);k=k+1|0}}while(0);d=d+164|0}if(e|0){nh(b);Bh(b)}return e|0}function Dl(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;d=c[b>>2]&3;i=c[((d|0)==3?b:b+48|0)+40>>2]|0;f=i+16|0;g=c[(c[f>>2]|0)+236>>2]|0;d=c[(c[(c[((d|0)==2?b:b+-48|0)+40>>2]|0)+16>>2]|0)+236>>2]|0;h=(g|0)<(d|0);e=h?d:g;i=c[(c[(Vf(i)|0)+16>>2]|0)+196>>2]|0;f=i+(c[(c[f>>2]|0)+232>>2]<<6)+4|0;d=h?g:d;a:while(1){d=d+1|0;if((d|0)>=(e|0))break;g=c[(c[(c[f>>2]|0)+(d<<2)>>2]|0)+16>>2]|0;switch(a[g+156>>0]|0){case 0:break a;case 1:break;default:continue a}if(c[g+104>>2]|0)break}if((d|0)==(e|0))do{i=c[b+16>>2]|0;a[i+113>>0]=1;b=c[i+172>>2]|0}while((b|0)!=0);return}function El(a){a=a|0;var d=0,e=0,f=0,g=0;g=a+16|0;a=c[g>>2]|0;if(b[a+236>>1]|0)ma(81281,81264,190,81300);d=(b[a+238>>1]|0)+3|0;a=c[a+196>>2]|0;if(!a)a=ww(d<<6)|0;else a=yw(a,d<<6)|0;d=a+64|0;a=c[g>>2]|0;c[a+196>>2]=d;a=b[a+238>>1]|0;while(1){if((a|0)<=-1)break;f=a+-1|0;e=d+(a<<6)|0;a=d+(f<<6)|0;d=e+64|0;do{c[e>>2]=c[a>>2];e=e+4|0;a=a+4|0}while((e|0)<(d|0));a=f;d=c[(c[g>>2]|0)+196>>2]|0}c[d+(a<<6)+8>>2]=0;c[d+(a<<6)>>2]=0;e=vw(8)|0;g=c[g>>2]|0;f=c[g+196>>2]|0;c[f+(a<<6)+12>>2]=e;c[f+(a<<6)+4>>2]=e;c[f+(a<<6)+56>>2]=0;h[f+(a<<6)+24>>3]=1.0;h[f+(a<<6)+16>>3]=1.0;h[f+(a<<6)+40>>3]=1.0;h[f+(a<<6)+32>>3]=1.0;g=g+236|0;b[g>>1]=(b[g>>1]|0)+-1<<16>>16;return}function Fl(b){b=b|0;var d=0,e=0,f=0.0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0.0,q=0.0,r=0.0;j=b+16|0;if(c[(c[j>>2]|0)+96>>2]|0){m=b+48|0;k=Vf(c[((c[b>>2]&3|0)==3?b:m)+40>>2]|0)|0;d=c[(c[(c[((c[b>>2]&3|0)==3?b:m)+40>>2]|0)+16>>2]|0)+232>>2]|0;l=Gl(k,b)|0;n=k+16|0;e=c[n>>2]|0;g=c[e+196>>2]|0;o=d+-1|0;i=c[c[g+(o<<6)+4>>2]>>2]|0;if(!i)f=+h[g+(d<<6)+24>>3]+ +h[(c[(c[c[g+(d<<6)+4>>2]>>2]|0)+16>>2]|0)+24>>3]+ +(c[e+252>>2]|0);else f=+h[(c[i+16>>2]|0)+24>>3]-+h[g+(o<<6)+16>>3];d=Hl(k,o,l)|0;k=c[(c[j>>2]|0)+96>>2]|0;q=+h[k+24>>3];p=+h[k+32>>3];j=(c[(c[n>>2]|0)+116>>2]&1|0)==0;r=j?p:q;g=d+16|0;e=c[g>>2]|0;h[e+80>>3]=r;l=~~(r*.5);p=(j?q:p)*.5;h[e+96>>3]=p;h[e+88>>3]=p;c[e+104>>2]=k;h[e+24>>3]=+(l+~~f|0);e=ah(d,c[((c[b>>2]&3|0)==3?b:m)+40>>2]|0,b)|0;e=c[e+16>>2]|0;h[e+16>>3]=-+h[(c[g>>2]|0)+88>>3];h[e+56>>3]=+h[(c[(c[((c[b>>2]&3|0)==3?b:m)+40>>2]|0)+16>>2]|0)+96>>3];a[e+112>>0]=4;e=b+-48|0;d=ah(d,c[((c[b>>2]&3|0)==2?b:e)+40>>2]|0,b)|0;g=c[g>>2]|0;d=c[d+16>>2]|0;h[d+16>>3]=+h[g+96>>3];h[d+56>>3]=+h[(c[(c[((c[b>>2]&3|0)==2?b:e)+40>>2]|0)+16>>2]|0)+88>>3];a[d+112>>0]=4;d=c[(c[n>>2]|0)+196>>2]|0;e=d+(o<<6)+16|0;f=+(l|0);if(+h[e>>3]>3]=f;d=d+(o<<6)+24|0;if(+h[d>>3]>3]=f;c[g+112>>2]=b}return}function Gl(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0;n=l;l=l+32|0;j=n+8|0;f=n+4|0;g=n;d=c[b>>2]&3;e=c[((d|0)==3?b:b+48|0)+40>>2]|0;k=(c[(c[e+16>>2]|0)+232>>2]|0)+-1|0;a=c[(c[a+16>>2]|0)+196>>2]|0;h=c[a+(k<<6)+4>>2]|0;a=c[a+(k<<6)>>2]|0;k=j+8|0;c[k>>2]=-1;c[j>>2]=-1;m=j+12|0;c[m>>2]=a;i=j+4|0;c[i>>2]=a;Il(e,c[((d|0)==2?b:b+-48|0)+40>>2]|0,f,g);f=c[f>>2]|0;g=c[g>>2]|0;d=0;e=a;b=-1;while(1){if((d|0)>=(e|0))break;e=e+-1|0;Jl(c[h+(d<<2)>>2]|0,j,f,g);if((d|0)!=(e|0))Jl(c[h+(e<<2)>>2]|0,j,f,g);a=c[i>>2]|0;b=c[j>>2]|0;if((a-b|0)<2)break;else d=d+1|0}if((b|0)>(a|0))a=(c[m>>2]|0)+(c[k>>2]|0)|0;else a=a+b|0;l=n;return (a+1|0)/2|0|0}function Hl(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;g=a+16|0;f=c[(c[g>>2]|0)+196>>2]|0;e=f+(b<<6)|0;f=c[f+(b<<6)+4>>2]|0;if(!f)f=ww((c[e>>2]<<2)+8|0)|0;else f=yw(f,(c[e>>2]<<2)+8|0)|0;e=c[(c[g>>2]|0)+196>>2]|0;c[e+(b<<6)+4>>2]=f;e=c[e+(b<<6)>>2]|0;while(1){if((e|0)<=(d|0))break;h=e+-1|0;i=c[f+(h<<2)>>2]|0;c[f+(e<<2)>>2]=i;i=(c[i+16>>2]|0)+236|0;c[i>>2]=(c[i>>2]|0)+1;e=h}h=fh(a)|0;i=f+(d<<2)|0;c[i>>2]=h;h=c[h+16>>2]|0;c[h+236>>2]=d;c[h+232>>2]=b;g=(c[(c[g>>2]|0)+196>>2]|0)+(b<<6)|0;h=(c[g>>2]|0)+1|0;c[g>>2]=h;c[f+(h<<2)>>2]=0;return c[i>>2]|0}function Il(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;a=c[(c[a+16>>2]|0)+236>>2]|0;b=c[(c[b+16>>2]|0)+236>>2]|0;f=(a|0)>(b|0);c[d>>2]=f?b:a;c[e>>2]=f?a:b;return}function Jl(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,m=0,n=0;m=l;l=l+16|0;h=m+4|0;g=m;b=c[b+16>>2]|0;do if((a[b+156>>0]|0)==1){k=c[b+236>>2]|0;if(c[b+176>>2]|0){i=c[b+180>>2]|0;b=0;g=0;h=0;while(1){j=c[i+(h<<2)>>2]|0;if(!j)break;n=c[(c[(c[((c[j>>2]&3|0)==2?j:j+-48|0)+40>>2]|0)+16>>2]|0)+236>>2]|0;j=(n|0)>(e|0);b=j?((n|0)<(f|0)?b:1):b;g=j?g:1;h=h+1|0}if(g<<24>>24!=0&b<<24>>24==0){c[d>>2]=k+1;break}if(!(g<<24>>24==0&b<<24>>24!=0))break;c[d+4>>2]=k+-1;break}if((c[b+184>>2]|0)!=2)ma(81244,81264,63,81271);i=c[b+180>>2]|0;n=c[i>>2]|0;i=c[i+4>>2]|0;Il(c[((c[n>>2]&3|0)==2?n:n+-48|0)+40>>2]|0,c[((c[i>>2]&3|0)==2?i:i+-48|0)+40>>2]|0,h,g);i=c[g>>2]|0;if((i|0)<=(e|0)){c[d>>2]=k;c[d+8>>2]=k;break}b=c[h>>2]|0;if((b|0)>=(f|0)){c[d+4>>2]=k;c[d+12>>2]=k;break}g=(b|0)<(e|0);h=(i|0)>(f|0);if(!(h&g)){if(!(!g?!((i|0)<(f|0)&(b|0)==(e|0)):0))c[d+8>>2]=k;if(!h?!((i|0)==(f|0)&(b|0)>(e|0)):0)break;c[d+12>>2]=k}}while(0);l=m;return}function Kl(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0;do if((a|0)!=0?(c[a+24>>2]|0)<=0:0){h=c[a+4>>2]|0;g=h+32|0;b=c[g>>2]|0;if(b){b=cb[b&31](a,2,0,h)|0;if((b|0)<0){b=-1;break}}else b=0;if(c[a+28>>2]|0)Wl(a,0)|0;f=(b|0)==0;if(f){bb[c[c[a+16>>2]>>2]&31](a,0,64)|0;if((Sl(a)|0)>0){b=-1;break}d=a+8|0;b=c[d>>2]|0;if((c[b+12>>2]|0)>0){e=a+12|0;cb[c[e>>2]&31](a,c[b+8>>2]|0,0,h)|0;b=c[d>>2]|0}else e=a+12|0;cb[c[e>>2]&31](a,b,0,h)|0}b=c[a+20>>2]|0;if(b){if(f&(b|0)==1)cb[c[a+12>>2]&31](a,a,0,h)|0}else _I(a);b=c[g>>2]|0;if(!b)b=0;else{cb[b&31](a,6,0,h)|0;b=0}}else b=-1;while(0);return b|0}function Ll(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;f=a+4|0;n=c[f>>2]|0;a:do if(n)if(b){m=c[c[a+16>>2]>>2]|0;g=a+8|0;if(c[c[g>>2]>>2]&4096|0)Rl(a,0)|0;e=c[n+32>>2]|0;if(e|0?(cb[e&31](a,3,b,n)|0)<0:0){b=0;break}c[f>>2]=b;e=c[b+28>>2]|0;c[a+12>>2]=(e|0)==0?19:e;e=c[c[g>>2]>>2]|0;if(!(e&112)){do if(!(e&2))if(!(e&3))if(!(d&1))break;else{b=n;break a}else if((d&3|0)==3){b=n;break a}else break;else if(d&2|0){b=n;break a}while(0);h=Ol(a)|0;e=c[g>>2]|0;l=c[e>>2]|0;c[e>>2]=l&-4097;c[e+4>>2]=0;c[e+16>>2]=0;b:do if(l&3|0){l=c[e+8>>2]|0;f=l+(c[e+12>>2]<<2)|0;e=l;while(1){if(e>>>0>=f>>>0)break b;c[e>>2]=0;e=e+4|0}}while(0);i=(d&2|0)==0;j=b+8|0;k=b+4|0;l=b+24|0;while(1){if(!h){b=n;break a}d=c[h>>2]|0;if(i){e=c[j>>2]|0;if((e|0)<0)e=c[h+8>>2]|0;else e=h+(0-e)|0;g=c[k>>2]|0;e=e+(c[b>>2]|0)|0;if((g|0)<0)e=c[e>>2]|0;f=c[l>>2]|0;if(!f)e=Ul(0,e,g)|0;else e=bb[f&31](a,e,b)|0;c[h+4>>2]=e}bb[m&31](a,h,32)|0;h=d}}else b=n}else b=n;else{c[f>>2]=b;n=c[b+28>>2]|0;c[a+12>>2]=(n|0)==0?19:n}while(0);return b|0}function Ml(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;a=(c|0)==0;do if(!b)if(a)a=0;else a=ZI(c)|0;else if(a){_I(b);a=0;break}else{a=aJ(b,c)|0;break}while(0);return a|0}function Nl(a){a=a|0;var b=0,d=0,e=0;e=a+8|0;b=c[e>>2]|0;d=c[b>>2]|0;a:do if(!(d&12)){if(!(d&3)){d=b+8|0;a=c[d>>2]|0;c[d>>2]=0;break}a=Ol(a)|0;d=c[e>>2]|0;b=c[d+8>>2]|0;d=b+(c[d+12>>2]<<2)|0;while(1){if(b>>>0>=d>>>0)break a;c[b>>2]=0;b=b+4|0}}else a=c[b+4>>2]|0;while(0);e=c[e>>2]|0;c[e>>2]=c[e>>2]&-4097;c[e+16>>2]=0;c[e+4>>2]=0;return a|0}function Ol(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;g=a+8|0;a=c[g>>2]|0;b=c[a>>2]|0;if(!(b&4096)){a:do if(!(b&3)){if(b&112|0){a=c[a+8>>2]|0;break}a=c[a+4>>2]|0;if(!a)a=0;else{while(1){b=a+4|0;d=c[b>>2]|0;if(!d){e=a;break}c[b>>2]=c[d>>2];c[d>>2]=a;a=d}while(1){b=c[e>>2]|0;if(!b)break a;d=c[b+4>>2]|0;if(!d){e=b;continue}while(1){c[b+4>>2]=c[d>>2];c[d>>2]=b;b=c[d+4>>2]|0;if(!b)break;else{f=d;d=b;b=f}}c[e>>2]=d;e=d}}}else{e=c[a+8>>2]|0;f=e+(c[a+12>>2]<<2)|0;b=0;a=0;while(1){if(e>>>0>=f>>>0)break a;d=c[e>>2]|0;if(d){if(!b){b=d;a=d}else c[b>>2]=d;while(1){d=c[b>>2]|0;if(!d)break;else b=d}c[e>>2]=b}e=e+4|0}}while(0);g=c[g>>2]|0;c[g+4>>2]=a;c[g>>2]=c[g>>2]|4096}else a=c[a+4>>2]|0;return a|0}function Pl(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;s=a+8|0;if(c[c[s>>2]>>2]&4096|0)Rl(a,0)|0;r=c[a+4>>2]|0;m=c[r>>2]|0;n=c[r+4>>2]|0;q=r+8|0;u=c[q>>2]|0;o=c[r+20>>2]|0;p=a+20|0;f=c[p>>2]&-32769;c[p>>2]=f;a:do if(!b){if(d&384|0){f=c[s>>2]|0;e=c[f+8>>2]|0;if(!e){e=0;break}if(d&256){e=c[e+4>>2]|0;c[f+4>>2]=e;if(!e){e=0;break}}else c[f+4>>2]=e;if((u|0)<0){e=c[e+8>>2]|0;break}else{e=e+(0-u)|0;break}}if(d&4098|0){e=c[s>>2]|0;if(c[e>>2]&144|0){e=0;break}e=c[e+8>>2]|0;if(!e){e=0;break}else{h=e;t=84;break}}if(!(d&64))e=0;else{i=r+16|0;b:do if((c[i>>2]|0)!=0|(u|0)<0){j=a+12|0;k=(u|0)<0;f=0-u|0;e=c[(c[s>>2]|0)+8>>2]|0;while(1){if(!e)break b;g=c[e>>2]|0;h=c[i>>2]|0;if(h|0){if(k)b=c[e+8>>2]|0;else b=e+f|0;ib[h&127](a,b,r)}if((c[q>>2]|0)>=0){e=g;continue}cb[c[j>>2]&31](a,e,0,r)|0;e=g}}while(0);e=c[s>>2]|0;c[e+4>>2]=0;c[e+8>>2]=0;c[(c[s>>2]|0)+16>>2]=0;e=0}}else{if(d&2049|0){g=r+12|0;e=c[g>>2]|0;h=(d&1|0)==0;if(!(h|(e|0)==0)){e=bb[e&31](a,b,r)|0;if(!e){e=0;break}else f=e}else f=b;do if((u|0)>-1)h=f+u|0;else{e=cb[c[a+12>>2]&31](a,0,12,r)|0;if(e|0){c[e+8>>2]=f;h=e;break}if(!(c[g>>2]|0)){e=0;break a}e=c[r+16>>2]|0;if(h|(e|0)==0){e=0;break a}ib[e&127](a,f,r);e=0;break a}while(0);g=c[s>>2]|0;e=c[g>>2]|0;do if(!(e&128)){if(!(e&16))if(!(e&32)){t=51;break}else{t=48;break}f=c[g+4>>2]|0;e=(f|0)!=0;if(!(d&8192)){if(!e){t=48;break}if((f|0)==(c[g+8>>2]|0)){t=48;break}r=f+4|0;a=c[r>>2]|0;c[h+4>>2]=a;c[a>>2]=h;c[h>>2]=f;c[r>>2]=h;break}else{if(!e){t=51;break}e=c[f>>2]|0;if(!e){t=51;break}c[h>>2]=e;c[e+4>>2]=h;c[h+4>>2]=f;c[f>>2]=h;break}}else if(!(d&8192))t=48;else t=51;while(0);if((t|0)==48){e=c[g+8>>2]|0;c[h>>2]=e;if(!e)e=h;else c[h+4>>2]=c[e+4>>2];c[e+4>>2]=h;c[(c[s>>2]|0)+8>>2]=h}else if((t|0)==51){f=g+8|0;e=c[f>>2]|0;if(!e){c[f>>2]=h;e=h}else{r=e+4|0;c[c[r>>2]>>2]=h;c[h+4>>2]=c[r>>2]}c[e+4>>2]=h;c[h>>2]=0}e=c[s>>2]|0;f=e+16|0;g=c[f>>2]|0;if((g|0)>-1)c[f>>2]=g+1;c[e+4>>2]=h;if((u|0)<0){e=c[h+8>>2]|0;break}else{e=h+(0-u)|0;break}}h=c[s>>2]|0;do if(!(d&512)){e=c[h+4>>2]|0;if(e|0){if((u|0)<0)g=c[e+8>>2]|0;else g=e+(0-u)|0;if((g|0)==(b|0))break}e=b+m|0;if((n|0)<0){b=c[e>>2]|0;t=68}else{b=e;t=68}}else t=68;while(0);if((t|0)==68){g=(u|0)<0;i=(n|0)<0;j=(o|0)==0;k=(n|0)<1;l=0-u|0;e=h+8|0;do{e=c[e>>2]|0;if(!e){e=0;break a}if(g)f=c[e+8>>2]|0;else f=e+l|0;f=f+m|0;if(i)f=c[f>>2]|0;do if(j)if(k){f=xJ(b,f)|0;break}else{f=dL(b,f,n)|0;break}else f=cb[o&31](a,b,f,r)|0;while(0)}while((f|0)!=0);f=c[p>>2]|0}c[p>>2]=f|32768;if(!(d&4098)){do if(!(d&8)){f=c[s>>2]|0;if(!(d&16)){c[f+4>>2]=e;break}if((e|0)==(c[f+8>>2]|0)){c[f+4>>2]=0;e=0;break a}else{e=e+4|0;t=108;break}}else{f=c[s>>2]|0;t=108}while(0);if((t|0)==108){e=c[e>>2]|0;c[f+4>>2]=e;if(!e){e=0;break}}if((u|0)<0){e=c[e+8>>2]|0;break}else{e=e+(0-u)|0;break}}else{h=e;t=84}}while(0);if((t|0)==84){e=c[h>>2]|0;if(e){c[e+4>>2]=c[h+4>>2];e=c[h>>2]|0}f=(c[s>>2]|0)+8|0;g=c[f>>2]|0;if((h|0)==(g|0)){c[f>>2]=e;e=c[(c[s>>2]|0)+8>>2]|0;if(e|0)c[e+4>>2]=c[h+4>>2]}else{f=h+4|0;c[c[f>>2]>>2]=e;e=g+4|0;if((h|0)==(c[e>>2]|0))c[e>>2]=c[f>>2]}e=c[s>>2]|0;f=e+4|0;if((h|0)==(c[f>>2]|0))g=c[h>>2]|0;else g=0;c[f>>2]=g;t=e+16|0;c[t>>2]=(c[t>>2]|0)+-1;if((u|0)<0)e=c[h+8>>2]|0;else e=h+(0-u)|0;f=c[r+16>>2]|0;if(!((d&2|0)==0|(f|0)==0))ib[f&127](a,e,r);if((c[q>>2]|0)<0)cb[c[a+12>>2]&31](a,h,0,r)|0}return e|0}function Ql(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0;j=l;l=l+16|0;g=j;a:do if((a|0)!=0&(b|0)!=0?(f=ZI(40)|0,(f|0)!=0):0){c[f>>2]=0;c[f+16>>2]=0;c[f+4>>2]=0;Ll(f,a,0)|0;d=f+20|0;i=a+32|0;c[d>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;c[d+16>>2]=0;d=c[i>>2]|0;do if(d){c[g>>2]=0;d=cb[d&31](f,1,g,a)|0;if((d|0)>=0)if(d){e=c[g>>2]|0;if(e|0)if(!(c[b+4>>2]&c[e>>2])){d=f;h=12;break}else{d=f;break}d=a+28|0;if(!(c[d>>2]|0)){d=f;h=12}else{_I(f);e=cb[c[d>>2]&31](0,0,40,a)|0;if(!e){d=0;break a}c[e>>2]=0;c[e+16>>2]=0;c[e+4>>2]=0;Ll(e,a,0)|0;c[e+20>>2]=1;c[e+24>>2]=0;c[e+32>>2]=0;c[e+28>>2]=0;d=e;f=e;h=11}}else{d=f;h=11}else{d=f;h=12}}else{d=f;h=11}while(0);if((h|0)==11){e=cb[c[d+12>>2]&31](d,0,28,a)|0;c[g>>2]=e;if(!e){d=f;h=12}else{c[e>>2]=c[b+4>>2];g=e+4|0;c[g>>2]=0;c[g+4>>2]=0;c[g+8>>2]=0;c[g+12>>2]=0;c[g+16>>2]=0;c[g+20>>2]=0}}if((h|0)==12){_I(d);d=0;break}c[d+8>>2]=e;c[d>>2]=c[b>>2];c[d+16>>2]=b;e=c[i>>2]|0;if(e)cb[e&31](d,5,f,a)|0}else d=0;while(0);l=j;return d|0}function Rl(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0;f=c[c[a+16>>2]>>2]|0;j=a+8|0;g=c[j>>2]|0;h=c[g>>2]|0;d=h&4096;if(!b)if(!d)b=-1;else{e=d;b=c[g+4>>2]|0;i=5}else if(!(c[g+16>>2]|0)){e=0;i=5}else b=-1;a:do if((i|0)==5){c[g>>2]=h&-4097;if(!(h&3)){d=g+4|0;if(!(h&12)){c[d>>2]=0;d=g+8|0}c[d>>2]=b;if(e|0){b=0;break}c[(c[j>>2]|0)+16>>2]=-1;b=0;break}c[g+4>>2]=0;if(!e){c[g+16>>2]=0;while(1){if(!b){b=0;break a}j=c[b>>2]|0;bb[f&31](a,b,32)|0;b=j}}e=c[g+8>>2]|0;a=e+(c[g+12>>2]<<2)|0;while(1){if(e>>>0>=a>>>0){b=0;break a}d=c[e>>2]|0;if(d){c[e>>2]=b;b=c[d>>2]|0;c[d>>2]=0}e=e+4|0}}while(0);return b|0}function Sl(a){a=a|0;var b=0,d=0,e=0;b=a+8|0;d=c[b>>2]|0;if(c[d>>2]&4096){Rl(a,0)|0;d=c[b>>2]|0}e=d+16|0;a=c[e>>2]|0;do if((a|0)<0){b=c[d>>2]|0;if(b&12|0){a=Tl(c[d+4>>2]|0)|0;c[e>>2]=a;break}if(b&112){a=0;b=d+8|0;while(1){b=c[b>>2]|0;if(!b)break;a=a+1|0}c[e>>2]=a}}while(0);return a|0}function Tl(a){a=a|0;var b=0;if(!a)return 0;else{b=Tl(c[a+4>>2]|0)|0;return b+1+(Tl(c[a>>2]|0)|0)|0}return 0}function Ul(b,c,e){b=b|0;c=c|0;e=e|0;var f=0,g=0,h=0;g=c;if((e|0)>=1){h=c+e+-1|0;g=(h>>>0>>0?c:h)+(1-g)&-2;f=c;while(1){if(f>>>0>=h>>>0)break;b=O(((d[f>>0]|0)<<8)+b+(d[f+1>>0]|0)|0,17109811)|0;f=f+2|0}f=c+g|0;if(f>>>0>h>>>0)c=e;else{c=e;b=O(((d[f>>0]|0)<<8)+b|0,17109811)|0}}else{while(1){f=a[c>>0]|0;if(!(f<<24>>24))break;h=a[c+1>>0]|0;e=O(((f&255)<<8)+b+(h&255)|0,17109811)|0;b=e;c=c+(h<<24>>24?2:1)|0}c=c-g|0}return O(b+c|0,17109811)|0}function Vl(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;G=l;l=l+128|0;z=G+120|0;r=G;F=a+8|0;e=c[F>>2]|0;if(c[e>>2]&4096){Rl(a,0)|0;e=c[F>>2]|0}E=c[a+4>>2]|0;A=c[E>>2]|0;B=c[E+4>>2]|0;x=E+8|0;D=c[x>>2]|0;C=c[E+20>>2]|0;t=a+20|0;c[t>>2]=c[t>>2]&-32769;h=c[e+4>>2]|0;a:do if(!b)if((d&448|0)==0|(h|0)==0)e=0;else{if(!(d&64)){b:do if(!(d&256)){e=h;while(1){f=e+4|0;g=c[f>>2]|0;if(!g)break b;c[f>>2]=c[g>>2];c[g>>2]=e;e=g}}else{e=h;while(1){f=c[e>>2]|0;if(!f)break b;a=f+4|0;c[e>>2]=c[a>>2];c[a>>2]=e;e=f}}while(0);c[(c[F>>2]|0)+4>>2]=e;if((D|0)<0){e=c[e+8>>2]|0;break}else{e=e+(0-D)|0;break}}b=E+16|0;if((c[b>>2]|0)!=0|(D|0)<0){j=a+12|0;k=(D|0)<0;i=0-D|0;e=h;do{h=e;while(1){e=h+4|0;f=c[e>>2]|0;if(!f)break;c[e>>2]=c[f>>2];c[f>>2]=h;h=f}e=c[h>>2]|0;f=c[b>>2]|0;if(f|0){if(k)g=c[h+8>>2]|0;else g=h+i|0;ib[f&127](a,g,E)}if((c[x>>2]|0)<0)cb[c[j>>2]&31](a,h,0,E)|0}while((e|0)!=0);e=c[F>>2]|0}c[e+16>>2]=0;c[e+4>>2]=0;e=0}else{y=a+16|0;u=(d&4098|0)==0;c:do if(u|(c[(c[y>>2]|0)+4>>2]|0)!=8)v=45;else{k=(B|0)<0;e=b+A|0;if(k)e=c[e>>2]|0;i=(C|0)==0;j=(B|0)<1;g=bb[c[a>>2]&31](a,b,4)|0;while(1){if(!g){v=45;break c}f=g+A|0;if(k)f=c[f>>2]|0;do if(i)if(j){f=xJ(e,f)|0;break}else{f=dL(e,f,B)|0;break}else f=cb[C&31](a,e,f,E)|0;while(0);if(f|0){v=45;break c}if((g|0)==(b|0))break;g=bb[c[a>>2]&31](a,g,8)|0}h=c[(c[F>>2]|0)+4>>2]|0;c[z>>2]=c[h+4>>2];c[z+4>>2]=c[h>>2];e=z;v=180}while(0);d:do if((v|0)==45){do if(!(d&2565)){if(d&32|0){if((D|0)<0)g=c[b+8>>2]|0;else g=b+(0-D)|0;e=g+A|0;if((B|0)<0)f=c[e>>2]|0;else f=e;if(!h){e=b;f=z;h=z;v=198;break}else{e=b;s=f;j=b;v=64;break}}if(h){if((D|0)<0)e=c[h+8>>2]|0;else e=h+(0-D)|0;if((e|0)!=(b|0)){f=b+A|0;if((B|0)<0){g=b;e=0;s=c[f>>2]|0;j=0;v=64}else{g=b;e=0;s=f;j=0;v=64}}else{e=0;g=b;f=z;k=z;j=0;v=141}}else{e=0;g=b;f=z;h=z;v=198}}else{if(!(d&512)){e=b+A|0;if((B|0)<0)f=c[e>>2]|0;else f=e}else f=b;if(!h){e=0;g=b;f=z;h=z;v=198}else{g=b;e=0;s=f;j=0;v=64}}while(0);e:do if((v|0)==64){f:do if((c[(c[y>>2]|0)+4>>2]|0)==4?(q=c[(c[F>>2]|0)+24>>2]|0,!((d&516|0)==0|(q|0)==0)):0){b=(D|0)<0;m=(B|0)<0;n=(C|0)==0;o=(B|0)<1;p=0-D|0;k=0;f=h;while(1){if((k|0)>=(q|0)){f=z;k=z;m=0;break}if(b)i=c[f+8>>2]|0;else i=f+p|0;i=i+A|0;if(m)i=c[i>>2]|0;do if(n)if(o){i=xJ(s,i)|0;break}else{i=dL(s,i,B)|0;break}else i=cb[C&31](a,s,i,E)|0;while(0);if(!i){v=80;break}c[r+(k<<2)>>2]=i;f=c[((i|0)<0?f+4|0:f)>>2]|0;if(!f){e=0;break a}else k=k+1|0}if((v|0)==80)if(b){e=c[f+8>>2]|0;break a}else{e=f+p|0;break a}while(1){if((m|0)>=(q|0))break f;do if((c[r+(m<<2)>>2]|0)<0){i=h+4|0;b=c[i>>2]|0;if((c[r+((m|1)<<2)>>2]|0)<0){c[i>>2]=c[b>>2];c[b>>2]=h;c[f+4>>2]=b;f=b;h=k;i=b+4|0;break}else{c[k>>2]=b;c[f+4>>2]=h;f=h;h=b;i=b;break}}else{i=c[h>>2]|0;if((c[r+((m|1)<<2)>>2]|0)>0){p=i+4|0;c[h>>2]=c[p>>2];c[p>>2]=h;c[k>>2]=i;h=i;break}else{c[f+4>>2]=i;c[k>>2]=h;f=i;i=i+4|0;break}}while(0);k=h;m=m+2|0;h=c[i>>2]|0}}else{f=z;k=z}while(0);n=(D|0)<0;o=(B|0)<0;p=(C|0)!=0;q=(B|0)<1;r=0-D|0;i=h;g:while(1){h=i;while(1){if(n)i=c[h+8>>2]|0;else i=h+r|0;i=i+A|0;if(o)i=c[i>>2]|0;do if(!p)if(q){i=xJ(s,i)|0;break}else{i=dL(s,i,B)|0;break}else i=cb[C&31](a,s,i,E)|0;while(0);if(!i){v=140;break g}if((i|0)>=0)break;b=h+4|0;m=c[b>>2]|0;if(!m){v=121;break g}if(n)i=c[m+8>>2]|0;else i=m+r|0;i=i+A|0;if(o)i=c[i>>2]|0;do if(!p)if(q){i=xJ(s,i)|0;break}else{i=dL(s,i,B)|0;break}else i=cb[C&31](a,s,i,E)|0;while(0);if((i|0)>=0){v=118;break}c[b>>2]=c[m>>2];c[m>>2]=h;c[f+4>>2]=m;h=c[m+4>>2]|0;if(!h){f=m;h=k;v=198;break e}else f=m}if((v|0)==118){v=0;if(!i){v=119;break}c[k>>2]=m;c[f+4>>2]=h;i=c[m>>2]|0;if(!i){f=h;h=m;v=198;break e}else{f=h;k=m;continue}}b=c[h>>2]|0;if(!b){v=139;break}if(n)i=c[b+8>>2]|0;else i=b+r|0;i=i+A|0;if(o)i=c[i>>2]|0;do if(!p)if(q){i=xJ(s,i)|0;break}else{i=dL(s,i,B)|0;break}else i=cb[C&31](a,s,i,E)|0;while(0);if((i|0)>0){i=b+4|0;c[h>>2]=c[i>>2];c[i>>2]=h;c[k>>2]=b;i=c[b>>2]|0;if(!i){h=b;v=198;break e}else{k=b;continue}}if(!i){v=137;break}c[f+4>>2]=b;c[k>>2]=h;i=c[b+4>>2]|0;if(!i){f=b;v=198;break e}else{f=b;k=h}}if((v|0)==119){c[f+4>>2]=h;f=h;h=m;v=141;break}else if((v|0)==121){c[f+4>>2]=h;f=h;h=k;v=198;break}else if((v|0)==137){c[k>>2]=h;k=h;h=b;v=141;break}else if((v|0)==139){c[k>>2]=h;v=198;break}else if((v|0)==140)if(!h){h=k;v=198;break}else{v=141;break}}while(0);do if((v|0)==141){c[t>>2]=c[t>>2]|32768;i=h+4|0;c[k>>2]=c[i>>2];c[f+4>>2]=c[h>>2];if(!(d&516)){if(d&8|0){c[i>>2]=c[z>>2];c[h>>2]=0;c[z>>2]=h;v=169;break}if(d&16|0){v=z+4|0;c[h>>2]=c[v>>2];c[i>>2]=0;c[v>>2]=h;v=175;break}if(!u){e=f;v=180;break d}if(d&2049|0){if(c[(c[y>>2]|0)+4>>2]&4|0){e=h;break}c[i>>2]=0;e=z+4|0;c[h>>2]=c[e>>2];c[e>>2]=h;e=h;v=205;break}if(!(d&32)){e=0;break a}if(!(c[(c[y>>2]|0)+4>>2]&4)){c[e+4>>2]=0;x=z+4|0;c[e>>2]=c[x>>2];c[x>>2]=j;e=(c[F>>2]|0)+16|0;c[e>>2]=(c[e>>2]|0)+1;e=h;break}e=c[E+16>>2]|0;if(e|0)ib[e&127](a,g,E);if((c[x>>2]|0)<0){cb[c[a+12>>2]&31](a,j,0,E)|0;e=h}else e=h}else e=h}else if((v|0)==198){c[f+4>>2]=0;c[h>>2]=0;if(!(d&8))if(!(d&16)){if(d&516|0){e=f;break d}if(!(d&2049)){if(!(d&32)){g=0;e=f;break d}x=(c[F>>2]|0)+16|0;c[x>>2]=(c[x>>2]|0)+1}else{e=0;v=205}}else v=175;else v=169}while(0);if((v|0)==169){h=z+4|0;e=c[h>>2]|0;if(!e){e=f;break}while(1){f=e+4|0;g=c[f>>2]|0;if(!g)break;c[f>>2]=c[g>>2];c[g>>2]=e;e=g}c[h>>2]=c[e>>2]}else if((v|0)==175){e=c[z>>2]|0;if(!e){e=f;break}while(1){f=c[e>>2]|0;if(!f)break;x=f+4|0;c[e>>2]=c[x>>2];c[x>>2]=e;e=f}c[z>>2]=c[e+4>>2]}else if((v|0)==205){i=E+12|0;h=c[i>>2]|0;j=(d&1|0)==0;if(!(j|(h|0)==0))g=bb[h&31](a,g,E)|0;do if(g){if((D|0)>-1){e=g+D|0;v=215;break}e=cb[c[a+12>>2]&31](a,0,12,E)|0;if(e|0){c[e+8>>2]=g;break}if((c[i>>2]|0)!=0?(w=c[E+16>>2]|0,!(j|(w|0)==0)):0){ib[w&127](a,g,E);v=215}else v=215}else v=215;while(0);if((v|0)==215)if(!e){e=f;break}f=(c[F>>2]|0)+16|0;g=c[f>>2]|0;if((g|0)>-1)c[f>>2]=g+1}c[e+4>>2]=c[z>>2];c[e>>2]=c[z+4>>2];h:do if(!((d&516|0)==0?1:(c[(c[y>>2]|0)+4>>2]&8|0)==0)){m=(D|0)<0;if(m)f=c[e+8>>2]|0;else f=e+(0-D)|0;n=(B|0)<0;f=f+A|0;if(n)f=c[f>>2]|0;j=(C|0)==0;k=(B|0)<1;b=0-D|0;while(1){i=e+4|0;g=c[i>>2]|0;if(!g)break h;while(1){h=c[g>>2]|0;if(!h)break;z=h+4|0;c[g>>2]=c[z>>2];c[z>>2]=g;g=h}c[i>>2]=g;if(m)h=c[g+8>>2]|0;else h=g+b|0;h=h+A|0;if(n)h=c[h>>2]|0;do if(j)if(k){h=xJ(f,h)|0;break}else{h=dL(f,h,B)|0;break}else h=cb[C&31](a,f,h,E)|0;while(0);if(h|0)break h;c[i>>2]=c[g>>2];c[g>>2]=e;e=g}}while(0);c[(c[F>>2]|0)+4>>2]=e;if((D|0)<0){e=c[e+8>>2]|0;break a}else{e=e+(0-D)|0;break a}}while(0);if((v|0)==180){if((D|0)<0)g=c[h+8>>2]|0;else g=h+(0-D)|0;f=c[E+16>>2]|0;if(!((d&2|0)==0|(f|0)==0))ib[f&127](a,g,E);if((c[x>>2]|0)<0)cb[c[a+12>>2]&31](a,h,0,E)|0;a=(c[F>>2]|0)+16|0;E=c[a>>2]|0;c[a>>2]=(E|0)<1?-1:E+-1|0}do{f=e+4|0;e=c[f>>2]|0}while((e|0)!=0);c[f>>2]=c[z>>2];c[(c[F>>2]|0)+4>>2]=c[z+4>>2];e=d&2|0?g:0}while(0);l=G;return e|0}function Wl(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;if(c[c[a+8>>2]>>2]&4096|0)Rl(a,0)|0;f=(b|0)!=0;if(f){if(c[c[b+8>>2]>>2]&4096|0)Rl(b,0)|0;if((c[b+16>>2]|0)==(c[a+16>>2]|0)){d=b;e=7}else b=0}else{d=0;e=7}a:do if((e|0)==7){while(1){if(!d)break;if((d|0)==(a|0)){b=0;break a}d=c[d+28>>2]|0;e=7}d=a+28|0;e=c[d>>2]|0;if(e|0){g=e+24|0;c[g>>2]=(c[g>>2]|0)+-1}c[a+32>>2]=0;c[d>>2]=0;if(f){c[d>>2]=b;c[a>>2]=12;g=b+24|0;c[g>>2]=(c[g>>2]|0)+1;break}else{c[a>>2]=c[c[a+16>>2]>>2];b=e;break}}while(0);return b|0}function Xl(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;a:do if(!(d&99)){if((d&516|0)==0?(e=c[(c[a+16>>2]|0)+4>>2]|0,!((d&384|0)!=0&(e&12|0)==0)):0){if(e&12|0){if(!(d&408)){e=0;break}o=(d&136|0)!=0;p=(d&272|0)!=0;l=0;f=0;e=0;n=a;while(1){if(!n)break;m=bb[c[c[n+16>>2]>>2]&31](n,b,d)|0;do if(!m)g=l;else{h=c[n+4>>2]|0;i=c[h+4>>2]|0;j=c[h+20>>2]|0;g=m+(c[h>>2]|0)|0;if((i|0)<0)k=c[g>>2]|0;else k=g;if(e|0){do if(!j)if((i|0)<1){g=xJ(k,f)|0;break}else{g=dL(k,f,i)|0;break}else g=cb[j&31](n,k,f,h)|0;while(0);if(!(o&(g|0)<0|p&(g|0)>0)){g=l;break}}g=n;f=k;e=m}while(0);l=g;n=c[n+28>>2]|0}c[a+32>>2]=l;break}if(!(d&24)){e=0;break}j=a+32|0;f=c[j>>2]|0;if(f){e=c[(c[f+4>>2]|0)+8>>2]|0;g=c[(c[f+8>>2]|0)+4>>2]|0;if((e|0)<0)e=c[g+8>>2]|0;else e=g+(0-e)|0;if((e|0)==(b|0))e=b;else{f=a;h=32}}else{f=a;h=32}do if((h|0)==32){while(1){if(!f){h=33;break}e=bb[c[c[f+16>>2]>>2]&31](f,b,4)|0;if(e|0){h=36;break}f=c[f+28>>2]|0;h=32}if((h|0)==33){c[j>>2]=0;e=0;break a}else if((h|0)==36){c[j>>2]=f;break}}while(0);i=(d<<4&128^128)+128|0;e=bb[c[c[f+16>>2]>>2]&31](f,e,d)|0;while(1){h=f+16|0;while(1){if(!e)break;else g=a;while(1){if((g|0)==(f|0))break a;if(bb[c[c[g+16>>2]>>2]&31](g,e,4)|0)break;g=c[g+28>>2]|0}e=bb[c[c[h>>2]>>2]&31](f,e,d)|0}f=c[f+28>>2]|0;c[j>>2]=f;if(!f){e=0;break a}e=bb[c[c[f+16>>2]>>2]&31](f,0,i)|0}}else f=a;while(1){if(!f){f=0;e=0;break}e=bb[c[c[f+16>>2]>>2]&31](f,b,d)|0;if(e|0)break;f=c[f+28>>2]|0}c[a+32>>2]=f}else e=bb[c[c[a+16>>2]>>2]&31](a,b,d)|0;while(0);return e|0}function Yl(a){a=a|0;var b=0;b=c[41980]|0;c[41980]=a;return b|0}function Zl(a){a=a|0;var b=0;b=c[41981]|0;c[41981]=a;return b|0}function _l(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=l;l=l+16|0;f=e;c[f>>2]=d;d=$l(a,b,f)|0;l=e;return d|0}function $l(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;g=l;l=l+16|0;e=g;f=(a|0)==3;h=f?c[41983]|0:(a|0)==2?1:a;c[41983]=h;i=c[41984]|0;c[41984]=i>>>0>h>>>0?i:h;do if(h>>>0<(c[41981]|0)>>>0){a=c[41982]|0;if(!a){a=AN()|0;c[41982]=a;if(!a){a=1;break}}if(!f){DN(a)|0;a=c[41982]|0}MK(a,b,d)|0;a=0}else{if(c[41980]|0){am(a,b,d);a=0;break}if(f)a=c[13918]|0;else{i=c[13918]|0;c[e>>2]=(a|0)==1?81312:81318;zL(i,81326,e)|0;a=i}MK(a,b,d)|0;a=0}while(0);l=g;return a|0}function am(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;if((c[41985]|0)==0?(f=ZI(c[4354]|0)|0,c[41985]=f,(f|0)==0):0)WL(81331,c[13918]|0)|0;else e=4;do if((e|0)==4){if((a|0)!=3){$a[c[41980]&31]((a|0)==1?81312:81318)|0;$a[c[41980]&31](81990)|0}while(1){a=LK(c[41985]|0,c[4354]|0,b,d)|0;e=c[4354]|0;if((a|0)>-1&(a|0)<(e|0)){e=7;break}e=e<<1;f=a+1|0;f=(e|0)>(f|0)?e:f;c[4354]=f;if(!(aJ(c[41985]|0,f)|0)){e=9;break}}if((e|0)==7){$a[c[41980]&31](c[41985]|0)|0;break}else if((e|0)==9){WL(81331,c[13918]|0)|0;break}}while(0);return}function bm(a,b){a=a|0;b=b|0;var d=0,e=0;d=l;l=l+16|0;e=d;c[e>>2]=b;$l(1,a,e)|0;l=d;return}function cm(b,d,e){b=b|0;d=d|0;e=e|0;var f=0;if(!e){e=(d|0)==0?1024:d;d=e;e=ZI(e)|0;f=1}else f=0;c[b+12>>2]=f;c[b>>2]=e;c[b+8>>2]=e+d;c[b+4>>2]=e;a[e>>0]=0;return}function dm(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;h=a+8|0;f=c[a>>2]|0;g=(c[h>>2]|0)-f|0;e=g<<1;g=g+b|0;e=g>>>0>e>>>0?g:e;g=a+4|0;b=f;f=(c[g>>2]|0)-f|0;d=a+12|0;if(!(c[d>>2]|0)){i=ZI(e)|0;TN(i|0,b|0,f|0)|0;c[d>>2]=1;b=i}else b=aJ(b,e)|0;c[a>>2]=b;c[g>>2]=b+f;c[h>>2]=b+e;return 0}function em(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;f=a+4|0;e=c[f>>2]|0;if((e+d|0)>>>0>(c[a+8>>2]|0)>>>0){dm(a,d)|0;e=c[f>>2]|0}TN(e|0,b|0,d|0)|0;c[f>>2]=(c[f>>2]|0)+d;return d|0}function fm(a,b){a=a|0;b=b|0;return em(a,b,rJ(b)|0)|0}function gm(a){a=a|0;if(c[a+12>>2]|0)_I(c[a>>2]|0);return}function hm(a){a=a|0;var b=0,e=0;b=a+4|0;e=c[b>>2]|0;if(e>>>0>(c[a>>2]|0)>>>0){c[b>>2]=e+-1;a=d[e>>0]|0}else a=-1;return a|0}function im(a,b,d){a=a|0;b=b|0;d=d|0;bp(c[41987]|0,c[b+8>>2]|0)|0;bp(c[41987]|0,c[b+12>>2]|0)|0;Zn(c[41987]|0,b);return}function jm(a,b){a=a|0;b=b|0;var c=0;c=Lo(a,81379,0)|0;if((b|0)!=0&(c|0)==0){km(a);c=Lo(a,81379,0)|0}return c|0}function km(a){a=a|0;var b=0,c=0,d=0;d=so(a)|0;wq(d,d,86,0,1)|0;c=co(d)|0;while(1){if(!c)break;mm(a,c);b=Pm(d,c)|0;while(1){if(!b)break;nm(a,b);b=Rm(d,b)|0}c=eo(d,c)|0}return}function lm(b){b=b|0;var c=0;c=b+24|0;a[c>>0]=a[c>>0]|64;sm(b);c=Lp(b)|0;pm((c|0)==0?b:c,b);return}function mm(a,b){a=a|0;b=b|0;var d=0;d=om(b)|0;if(!((d|0)!=0?(c[d+8>>2]|0)!=0:0))pm(a,b);return}function nm(a,b){a=a|0;b=b|0;var d=0;d=om(b)|0;if(!((d|0)!=0?(c[d+8>>2]|0)!=0:0))pm(a,b);return}function om(a){a=a|0;return Lo(a,81367,0)|0}function pm(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=No(b,81367,16,0)|0;f=qm(a,c[b>>2]&3)|0;e=d+8|0;a:do if(!(c[e>>2]|0)){a=so(a)|0;c[e>>2]=qm(a,c[b>>2]&3)|0;a=rm(b)|0;d=d+12|0;c[d>>2]=Yn(ro(b)|0,((a|0)>4?a:4)<<2)|0;a=bb[c[f>>2]&31](f,0,128)|0;while(1){if(!a)break a;e=ro(b)|0;e=$o(e,c[a+12>>2]|0)|0;c[(c[d>>2]|0)+(c[a+16>>2]<<2)>>2]=e;a=bb[c[f>>2]&31](f,a,8)|0}}while(0);return}function qm(a,b){a=a|0;b=b|0;var d=0,e=0;e=l;l=l+16|0;d=e;a=jm(a,0)|0;a:do if(!a)a=0;else switch(b|0){case 0:{a=c[a+16>>2]|0;break a}case 1:{a=c[a+8>>2]|0;break a}case 2:case 3:{a=c[a+12>>2]|0;break a}default:{c[d>>2]=b;_l(1,81392,d)|0;a=0;break a}}while(0);l=e;return a|0}function rm(a){a=a|0;var b=0;b=so(ro(a)|0)|0;a=qm(b,c[a>>2]&3)|0;if(!a)a=0;else a=Sl(a)|0;return a|0}function sm(a){a=a|0;var b=0,d=0,e=0,f=0;d=No(a,81379,20,0)|0;e=d+8|0;c[e>>2]=Pp(a,17420,c[4353]|0)|0;f=d+12|0;c[f>>2]=Pp(a,17420,c[4353]|0)|0;d=d+16|0;c[d>>2]=Pp(a,17420,c[4353]|0)|0;b=Lp(a)|0;if(!b){b=c[41986]|0;if(!((b|0)==0|(b|0)==(a|0))){b=jm(b,0)|0;tm(c[b+8>>2]|0,c[e>>2]|0,a,1);tm(c[b+12>>2]|0,c[f>>2]|0,a,2);tm(c[b+16>>2]|0,c[d>>2]|0,a,0)}}else{a=jm(b,0)|0;Wl(c[e>>2]|0,c[a+8>>2]|0)|0;Wl(c[f>>2]|0,c[a+12>>2]|0)|0;Wl(c[d>>2]|0,c[a+16>>2]|0)|0}return}function tm(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0;g=bb[c[b>>2]&31](b,0,128)|0;while(1){if(!g)break;h=um(e,c[g+8>>2]|0,c[g+12>>2]|0,c[g+16>>2]|0,f)|0;a[h+22>>0]=a[g+22>>0]|0;a[h+21>>0]=a[g+21>>0]|0;bb[c[d>>2]&31](d,h,1)|0;g=bb[c[b>>2]&31](b,g,8)|0}return}function um(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0;h=Yn(b,24)|0;a[h+20>>0]=g;c[h+8>>2]=$o(b,d)|0;c[h+12>>2]=$o(b,e)|0;c[h+16>>2]=f;return h|0}function vm(a,b){a=a|0;b=b|0;var d=0,e=0;d=l;l=l+32|0;e=d;c[e+8>>2]=b;b=bb[c[a>>2]&31](a,e,4)|0;l=d;return b|0}function wm(a,b){a=a|0;b=b|0;var c=0;c=Wl(a,0)|0;b=vm(a,b)|0;Wl(a,c)|0;return b|0}function xm(a,b){a=a|0;b=b|0;a=om(a)|0;if(!a)a=0;else a=vm(c[a+8>>2]|0,b)|0;return a|0}function ym(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0;h=l;l=l+16|0;g=h;if(!b){b=c[41986]|0;if(!b){a[g>>0]=a[17456]|0;a[g+1>>0]=a[17457]|0;a[g+2>>0]=a[17458]|0;a[g+3>>0]=a[17459]|0;b=gn(0,g,0)|0;c[41986]=b}}if(!f)b=Am(b,d,e)|0;else b=zm(b,d,e,f)|0;l=h;return b|0}function zm(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;i=so(a)|0;jm(a,1)|0;g=qm(a,b)|0;f=wm(g,d)|0;a:do if(!f){f=vm(g,d)|0;if(f|0){f=um(a,d,e,c[f+16>>2]|0,b)|0;bb[c[g>>2]&31](g,f,1)|0;h=16;break}g=qm(i,b)|0;f=um(a,d,e,Sl(g)|0,b)|0;bb[c[g>>2]&31](g,f,1)|0;switch(b|0){case 0:{wq(i,i,52,f,1)|0;h=16;break a}case 1:{d=co(i)|0;while(1){if(!d){h=16;break a}Bm(a,d,f);d=eo(i,d)|0}}case 2:case 3:{g=co(i)|0;while(1){if(!g){h=16;break a}d=Pm(i,g)|0;while(1){if(!d)break;Bm(a,d,f);d=Rm(i,d)|0}g=eo(i,g)|0}}default:break a}}else{h=f+12|0;bp(a,c[h>>2]|0)|0;c[h>>2]=$o(a,e)|0;h=16}while(0);if((h|0)==16)if((b|0)==0&(f|0)!=0)Cm(a,f,e)|0;vo(a,a,f);return f|0}function Am(a,b,c){a=a|0;b=b|0;c=c|0;a=qm(a,b)|0;if(!a)a=0;else a=vm(a,c)|0;return a|0}function Bm(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;b=om(b)|0;f=d+16|0;e=c[f>>2]|0;if((e|0)>3){g=c[a+64>>2]|0;b=b+12|0;e=e<<2;c[b>>2]=cb[c[(c[g>>2]|0)+8>>2]&31](c[g+12>>2]|0,c[b>>2]|0,e,e+4|0)|0}else b=b+12|0;g=$o(a,c[d+12>>2]|0)|0;c[(c[b>>2]|0)+(c[f>>2]<<2)>>2]=g;return}function Cm(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;h=ro(a)|0;g=(om(a)|0)+12|0;i=b+16|0;bp(h,c[(c[g>>2]|0)+(c[i>>2]<<2)>>2]|0)|0;f=$o(h,d)|0;c[(c[g>>2]|0)+(c[i>>2]<<2)>>2]=f;do if(!(c[a>>2]&3)){e=c[(jm(h,0)|0)+16>>2]|0;f=b+8|0;g=wm(e,c[f>>2]|0)|0;if(!g){i=um(h,c[f>>2]|0,d,c[i>>2]|0,c[a>>2]&3)|0;bb[c[e>>2]&31](e,i,1)|0;break}else{i=g+12|0;bp(h,c[i>>2]|0)|0;c[i>>2]=$o(h,d)|0;break}}while(0);vo(h,a,b);return 0}function Dm(a,b,d){a=a|0;b=b|0;d=d|0;a=qm(a,b)|0;do if(a){b=c[a>>2]|0;if(!d){a=bb[b&31](a,0,128)|0;break}else{a=bb[b&31](a,d,8)|0;break}}else a=0;while(0);return a|0}function Em(a){a=a|0;var b=0;c[41987]=a;b=om(a)|0;if(b|0){Fm(a,b);Po(a,c[b>>2]|0)|0}b=jm(a,0)|0;if(b)if(((Rp(a,c[b+8>>2]|0)|0)==0?(Rp(a,c[b+12>>2]|0)|0)==0:0)?(Rp(a,c[b+16>>2]|0)|0)==0:0){Po(a,c[b>>2]|0)|0;b=0}else b=1;else b=0;return b|0}function Fm(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;f=ro(a)|0;e=rm(a)|0;b=b+12|0;a=0;while(1){d=c[b>>2]|0;if((a|0)>=(e|0))break;bp(f,c[d+(a<<2)>>2]|0)|0;a=a+1|0}Zn(f,d);return}function Gm(a){a=a|0;var b=0;b=om(a)|0;if(b|0){Fm(a,b);Po(a,81367)|0}return}function Hm(a){a=a|0;var b=0;b=om(a)|0;if(b|0){Fm(a,b);Po(a,81367)|0}return}function Im(a,b){a=a|0;b=b|0;b=xm(a,b)|0;if(!b)b=0;else{a=c[(om(a)|0)+12>>2]|0;b=c[a+(c[b+16>>2]<<2)>>2]|0}return b|0}function Jm(a,b){a=a|0;b=b|0;a=c[(om(a)|0)+12>>2]|0;return c[a+(c[b+16>>2]<<2)>>2]|0}function Km(a,b,c){a=a|0;b=b|0;c=c|0;b=xm(a,b)|0;if(!b)b=-1;else{Cm(a,b,c)|0;b=0}return b|0}function Lm(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=ro(a)|0;f=ym(f,c[a>>2]&3,b,0)|0;if(!f){f=ro(a)|0;f=ym(f,c[a>>2]&3,b,e)|0}Cm(a,f,d)|0;return 0}function Mm(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;g=ro(a)|0;f=c[a>>2]|0;a:do if(!((c[b>>2]^f)&3)){d=1;e=0;while(1){e=Dm(g,f&3,e)|0;if(!e)break a;d=xm(b,c[e+8>>2]|0)|0;if(!d){d=1;break a}f=Jm(a,e)|0;Cm(b,d,f)|0;if(cp(f)|0)dp(Jm(b,d)|0);d=0;f=c[a>>2]|0}}else d=1;while(0);return d|0}function Nm(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;a=c[b+40>>2]|0;f=c[d+40>>2]|0;if((a|0)==(f|0)){e=(c[b>>2]|0)>>>4;a=(c[d>>2]|0)>>>4;if(e>>>0>=a>>>0)if(e>>>0>a>>>0)a=1;else g=6;else a=-1}else{e=(c[a>>2]|0)>>>4;a=(c[f>>2]|0)>>>4;if(e>>>0>=a>>>0)if(e>>>0>a>>>0)a=1;else g=6;else a=-1}if((g|0)==6)a=0;return a|0}function Om(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;a=(c[b+40>>2]|0)+8|0;g=c[a>>2]|0;a=c[a+4>>2]|0;f=(c[d+40>>2]|0)+8|0;e=c[f>>2]|0;f=c[f+4>>2]|0;do if(!(a>>>0>>0|(a|0)==(f|0)&g>>>0>>0))if(a>>>0>f>>>0|(a|0)==(f|0)&g>>>0>e>>>0)a=1;else{e=b+8|0;a=c[e>>2]|0;e=c[e+4>>2]|0;if(!((a|0)==0&(e|0)==0)?(i=d+8|0,h=c[i>>2]|0,i=c[i+4>>2]|0,!((h|0)==0&(i|0)==0)):0){if(e>>>0>>0|(e|0)==(i|0)&a>>>0>>0){a=-1;break}if(e>>>0>i>>>0|(e|0)==(i|0)&a>>>0>h>>>0){a=1;break}}a=0}else a=-1;while(0);return a|0}function Pm(a,b){a=a|0;b=b|0;var d=0;b=Qm(a,b)|0;if(!b)b=0;else{d=a+44|0;a=b+32|0;Rl(c[d>>2]|0,c[a>>2]|0)|0;b=c[d>>2]|0;b=bb[c[b>>2]&31](b,0,128)|0;c[a>>2]=Nl(c[d>>2]|0)|0}return b|0}function Qm(a,b){a=a|0;b=b|0;var d=0,e=0;e=l;l=l+48|0;d=e;if((c[b+24>>2]|0)==(a|0))a=b+28|0;else{c[d+16>>2]=b;a=c[a+40>>2]|0;a=bb[c[a>>2]&31](a,d,4)|0}l=e;return a|0}function Rm(a,b){a=a|0;b=b|0;var d=0,e=0;d=Qm(a,c[((c[b>>2]&3|0)==3?b:b+48|0)+40>>2]|0)|0;if(!d)a=0;else{e=a+44|0;d=d+32|0;Rl(c[e>>2]|0,c[d>>2]|0)|0;a=c[e>>2]|0;a=bb[c[a>>2]&31](a,b,8)|0;c[d>>2]=Nl(c[e>>2]|0)|0}return a|0}function Sm(a,b){a=a|0;b=b|0;var d=0;b=Qm(a,b)|0;if(!b)b=0;else{d=a+44|0;a=b+28|0;Rl(c[d>>2]|0,c[a>>2]|0)|0;b=c[d>>2]|0;b=bb[c[b>>2]&31](b,0,128)|0;c[a>>2]=Nl(c[d>>2]|0)|0}return b|0}function Tm(a,b){a=a|0;b=b|0;var d=0,e=0;d=Qm(a,c[((c[b>>2]&3|0)==2?b:b+-48|0)+40>>2]|0)|0;if(!d)a=0;else{e=a+44|0;d=d+28|0;Rl(c[e>>2]|0,c[d>>2]|0)|0;a=c[e>>2]|0;a=bb[c[a>>2]&31](a,b,8)|0;c[d>>2]=Nl(c[e>>2]|0)|0}return a|0}function Um(a,b){a=a|0;b=b|0;var c=0;c=Pm(a,b)|0;if(!c)c=Sm(a,b)|0;return c|0}function Vm(a,b,d){a=a|0;b=b|0;d=d|0;a:do if((c[b>>2]&3|0)==2){b=Rm(a,b)|0;if(!b){b=0;do{if(!b)b=Sm(a,d)|0;else b=Tm(a,b)|0;if(!b){b=0;break a}}while((c[b+40>>2]|0)==(d|0))}}else do{b=Tm(a,b)|0;if(!b){b=0;break a}}while((c[b+40>>2]|0)==(d|0));while(0);return b|0}function Wm(a,b,e){a=a|0;b=b|0;e=e|0;var f=0,g=0,h=0;h=l;l=l+32|0;f=h+16|0;g=h;if((sn(a)|0)!=0?(c[g>>2]=0,c[g+4>>2]=0,c[g+8>>2]=0,c[g+12>>2]=0,c[f>>2]=c[g>>2],c[f+4>>2]=c[g+4>>2],c[f+8>>2]=c[g+8>>2],c[f+12>>2]=c[g+12>>2],(_m(a,b,e,f)|0)!=0):0)f=0;else f=((d[a+24>>0]|0)>>>2&1^1)&255|(b|0)!=(e|0);l=h;return f|0}function Xm(a,b){a=a|0;b=b|0;Zm(a,b);return}function Ym(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0;io(b,d,1)|0;io(b,e,1)|0;h=Yn(b,96)|0;i=h+48|0;l=kn(b,2)|0;j=c[i>>2]|0;k=c[h>>2]|0;m=h+8|0;c[m>>2]=f;c[m+4>>2]=g;m=h+56|0;c[m>>2]=f;c[m+4>>2]=g;g=l<<4;c[h>>2]=k&12|g|2;c[i>>2]=j&12|g|3;c[h+88>>2]=d;c[h+40>>2]=e;Zm(b,h);if(a[b+24>>0]&64){No(h,81367,16,0)|0;nm(b,h)}to(b,h);return h|0}function Zm(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0;i=l;l=l+16|0;d=i;h=c[b>>2]&3;g=(h|0)==2?b:b+-48|0;h=(h|0)==3?b:b+48|0;e=c[h+40>>2]|0;f=c[g+40>>2]|0;while(1){if(!a)break;c[d>>2]=c[b>>2];c[d+4>>2]=c[b+4>>2];c[d+8>>2]=c[b+8>>2];c[d+12>>2]=c[b+12>>2];if(_m(a,e,f,d)|0)break;j=Qm(a,e)|0;m=a+44|0;$m(c[m>>2]|0,j+32|0,g);k=a+48|0;$m(c[k>>2]|0,j+24|0,g);j=Qm(a,f)|0;$m(c[m>>2]|0,j+28|0,h);$m(c[k>>2]|0,j+20|0,h);a=Lp(a)|0}l=i;return}function _m(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;h=l;l=l+48|0;f=h;if(!((b|0)==0|(d|0)==0)?(c[f>>2]=c[e>>2],c[f+4>>2]=c[e+4>>2],c[f+8>>2]=c[e+8>>2],c[f+12>>2]=c[e+12>>2],c[f+40>>2]=b,g=Qm(a,d)|0,(g|0)!=0):0){e=a+48|0;g=g+20|0;Rl(c[e>>2]|0,c[g>>2]|0)|0;a=c[e>>2]|0;a=bb[c[a>>2]&31](a,f,4)|0;c[g>>2]=Nl(c[e>>2]|0)|0}else a=0;l=h;return a|0}function $m(a,b,d){a=a|0;b=b|0;d=d|0;Rl(a,c[b>>2]|0)|0;bb[c[a>>2]&31](a,d,1)|0;c[b>>2]=Nl(a)|0;return}function an(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0;n=l;l=l+48|0;i=n+24|0;k=n+16|0;j=n;do if(!(An(a,2,e,k,0)|0))if(!e){if(f|0?(sn(a)|0)==0:0){m=18;break};c[j>>2]=0;c[j+4>>2]=0;c[j+8>>2]=0;c[j+12>>2]=0;m=7}else m=17;else{o=j;c[o>>2]=0;c[o+4>>2]=0;o=k;g=c[o+4>>2]|0;m=j+8|0;c[m>>2]=c[o>>2];c[m+4>>2]=g;c[j>>2]=2;m=7}while(0);a:do if((m|0)==7){c[i>>2]=c[j>>2];c[i+4>>2]=c[j+4>>2];c[i+8>>2]=c[j+8>>2];c[i+12>>2]=c[j+12>>2];g=_m(a,b,d,i)|0;b:do if(!g){if(rn(a)|0?(c[i>>2]=c[j>>2],c[i+4>>2]=c[j+4>>2],c[i+8>>2]=c[j+8>>2],c[i+12>>2]=c[j+12>>2],h=_m(a,d,b,i)|0,h|0):0){g=h;break}do if(f|0){g=so(a)|0;c[i>>2]=c[j>>2];c[i+4>>2]=c[j+4>>2];c[i+8>>2]=c[j+8>>2];c[i+12>>2]=c[j+12>>2];g=_m(g,b,d,i)|0;if(!g){if(!(rn(a)|0))break;g=so(a)|0;c[i>>2]=c[j>>2];c[i+4>>2]=c[j+4>>2];c[i+8>>2]=c[j+8>>2];c[i+12>>2]=c[j+12>>2];g=_m(g,d,b,i)|0;if(!g)break}Xm(a,g);break b}while(0);m=17;break a}while(0)}while(0);if((m|0)==17)if(!f)g=0;else m=18;if((m|0)==18)if((Wm(a,b,d)|0)!=0?(An(a,2,e,k,1)|0)!=0:0){g=k;g=Ym(a,b,d,c[g>>2]|0,c[g+4>>2]|0)|0;En(a,2,g)}else g=0;l=n;return g|0}function bn(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0;d=(c[b>>2]&3|0)==3;g=d?b+-48|0:b;d=d?b:b+48|0;b=c[g+40>>2]|0;h=Qm(a,c[d+40>>2]|0)|0;f=a+44|0;cn(c[f>>2]|0,h+32|0,g);e=a+48|0;cn(c[e>>2]|0,h+24|0,g);b=Qm(a,b)|0;cn(c[f>>2]|0,b+28|0,d);cn(c[e>>2]|0,b+20|0,d);return}function cn(a,b,d){a=a|0;b=b|0;d=d|0;Rl(a,c[b>>2]|0)|0;bb[c[a>>2]&31](a,d,2)|0;c[b>>2]=Nl(a)|0;return}function dn(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0;e=l;l=l+16|0;f=e;d=(c[d>>2]&3|0)==2?d:d+-48|0;g=c[d>>2]&3;h=c[((g|0)==3?d:d+48|0)+40>>2]|0;g=c[((g|0)==2?d:d+-48|0)+40>>2]|0;c[f>>2]=c[d>>2];c[f+4>>2]=c[d+4>>2];c[f+8>>2]=c[d+8>>2];c[f+12>>2]=c[d+12>>2];if(_m(b,h,g,f)|0){if((so(b)|0)==(b|0)){if(a[b+24>>0]&64)Hm(d);xo(b,d);Vo(d);h=d+8|0;Cn(b,2,c[h>>2]|0,c[h+4>>2]|0)}if(!(wq(b,d,53,0,0)|0))if((so(b)|0)==(b|0)){Zn(b,d);d=0}else d=0;else d=-1}else d=-1;l=e;return d|0}function en(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0;h=l;l=l+16|0;e=h;f=io(a,c[((c[b>>2]&3|0)==3?b:b+48|0)+40>>2]|0,d)|0;g=io(a,c[((c[b>>2]&3|0)==2?b:b+-48|0)+40>>2]|0,d)|0;do if((f|0)!=0&(g|0)!=0){c[e>>2]=c[b>>2];c[e+4>>2]=c[b+4>>2];c[e+8>>2]=c[b+8>>2];c[e+12>>2]=c[b+12>>2];e=_m(a,f,g,e)|0;f=(e|0)==0;if(!((d|0)!=0&f)){if(f)break}else{Zm(a,b);e=b}d=c[e>>2]&3;l=h;return ((d|0)==(c[b>>2]&3|0)?e:e+(((d|0)==3?-1:1)*48|0)|0)|0}while(0);l=h;return 0}function fn(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;b=b+8|0;e=d+8|0;e=IN(c[b>>2]|0,c[b+4>>2]|0,c[e>>2]|0,c[e+4>>2]|0)|0;return ((e|0)==0?0:e>>31|1)|0}function gn(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0;h=l;l=l+16|0;g=h;j=hn(e)|0;f=ab[c[(c[j>>2]|0)+4>>2]&63](c[j+12>>2]|0,72)|0;c[f>>2]=c[f>>2]&-4;i=f+64|0;c[i>>2]=j;k=f+24|0;d=c[d>>2]|0;c[k>>2]=d;a[k>>0]=d&255|8;c[f+60>>2]=f;e=ab[c[c[j+4>>2]>>2]&63](f,e)|0;c[(c[i>>2]|0)+16>>2]=e;if(An(f,0,b,g,1)|0){i=g;j=c[i+4>>2]|0;k=f+8|0;c[k>>2]=c[i>>2];c[k+4>>2]=j}k=jn(f)|0;En(k,0,f);l=h;return k|0}function hn(b){b=b|0;var d=0,e=0,f=0,g=0;d=(b|0)!=0;if(d){e=c[b>>2]|0;e=(e|0)==0?17792:e}else e=17792;g=$a[c[e>>2]&31](b)|0;f=ab[c[e+4>>2]&63](g,80)|0;c[f>>2]=e;c[f+12>>2]=g;if(d){g=c[b+4>>2]|0;c[f+4>>2]=(g|0)==0?17668:g;b=c[b+8>>2]|0;b=(b|0)==0?17768:b}else{c[f+4>>2]=17668;b=17768}c[f+8>>2]=b;a[f+52>>0]=1;return f|0}function jn(b){b=b|0;var d=0,e=0;c[b+36>>2]=Pp(b,17848,c[4353]|0)|0;c[b+40>>2]=Pp(b,17812,c[4353]|0)|0;d=(so(b)|0)==(b|0);c[b+44>>2]=Pp(b,d?17460:17496,c[4353]|0)|0;d=(so(b)|0)==(b|0);c[b+48>>2]=Pp(b,d?17532:17568,c[4353]|0)|0;c[b+52>>2]=Pp(b,17604,c[4353]|0)|0;d=Lp(b)|0;if(!((d|0)!=0?(e=kn(d,0)|0,c[b>>2]=c[b>>2]&15|e<<4,e=c[d+52>>2]|0,bb[c[e>>2]&31](e,b,1)|0,!(a[d+24>>0]&64)):0))lm(b);to(b,b);return b|0}function kn(a,b){a=a|0;b=b|0;var d=0;d=(c[a+64>>2]|0)+24+(b<<3)|0;b=d;b=HN(c[b>>2]|0,c[b+4>>2]|0,1,0)|0;a=z;c[d>>2]=b;c[d+4>>2]=a;z=a;return b|0}function ln(b){b=b|0;var d=0,e=0,f=0,g=0;f=Lp(b)|0;g=(f|0)==0;if(g?(d=b+64|0,(c[(c[c[d>>2]>>2]|0)+16>>2]|0)!=0):0){xo(b,b);g=b+8|0;Cn(b,0,c[g>>2]|0,c[g+4>>2]|0);d=c[d>>2]|0;gb[c[(c[d>>2]|0)+16>>2]&127](c[d+12>>2]|0);d=0}else e=4;do if((e|0)==4){d=Jp(b)|0;while(1){if(!d)break;e=Kp(d)|0;ln(d)|0;d=e}d=co(b)|0;while(1){if(!d)break;e=eo(b,d)|0;po(b,d)|0;d=e}Nn(b);xo(b,b);if(((((Rp(b,c[b+40>>2]|0)|0)==0?(Rp(b,c[b+36>>2]|0)|0)==0:0)?(Rp(b,c[b+48>>2]|0)|0)==0:0)?(Rp(b,c[b+44>>2]|0)|0)==0:0)?(Rp(b,c[b+52>>2]|0)|0)==0:0){if(a[b+24>>0]&64?Em(b)|0:0){d=-1;break}Vo(b);e=b+8|0;Cn(b,0,c[e>>2]|0,c[e+4>>2]|0);if(!g){Mp(f,b)|0;Zn(f,b);d=0;break}d=b+64|0;while(1){e=c[d>>2]|0;f=c[e+48>>2]|0;if(!f)break;Ao(b,c[f>>2]|0)|0}gb[c[(c[e+4>>2]|0)+20>>2]&127](c[e+16>>2]|0);if(!(Wo(b)|0)){d=c[d>>2]|0;g=c[d+12>>2]|0;f=(c[d>>2]|0)+12|0;hb[c[f>>2]&31](g,b);hb[c[f>>2]&31](g,d);d=0}else d=-1}else d=-1}while(0);return d|0}function mn(a){a=a|0;return Sl(c[a+40>>2]|0)|0}function nn(a){a=a|0;var b=0,c=0,d=0;b=0;c=co(a)|0;while(1){if(!c)break;d=(on(a,c,0,1)|0)+b|0;b=d;c=eo(a,c)|0}return b|0}function on(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=Qm(a,b)|0;if(f){if(!e)b=0;else b=pn(c[a+44>>2]|0,f+32|0)|0;if(d)b=(pn(c[a+44>>2]|0,f+28|0)|0)+b|0}else b=0;return b|0}function pn(a,b){a=a|0;b=b|0;var d=0;Rl(a,c[b>>2]|0)|0;d=Sl(a)|0;c[b>>2]=Nl(a)|0;return d|0}function qn(b){b=b|0;return a[b+24>>0]&1|0}function rn(a){a=a|0;return (qn(a)|0)==0|0}function sn(a){a=a|0;return (d[a+24>>0]|0)>>>1&1|0}function tn(a,b){a=a|0;b=b|0;return a|0}function un(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;if(!d){f=1328;d=c[f>>2]|0;f=c[f+4>>2]|0;c[e>>2]=d;c[e+4>>2]=f;f=HN(d|0,f|0,2,0)|0;e=1328;c[e>>2]=f;c[e+4>>2]=z}else{if(!f)a=Yo(a,d)|0;else a=$o(a,d)|0;c[e>>2]=a;c[e+4>>2]=0}return 1}function vn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return 0}function wn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;if((c&1|0)==0&0==0)bp(a,c)|0;return}function xn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ((c&1|0)==0&0==0?c:0)|0}function yn(a){a=a|0;return}function zn(a,b,c){a=a|0;b=b|0;c=c|0;return}function An(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0;i=(e|0)!=0;do if(i){if((a[e>>0]|0)!=37?(h=c[b+64>>2]|0,h=db[c[(c[h+4>>2]|0)+4>>2]&3](c[h+16>>2]|0,d,e,f,g)|0,h|0):0)break;h=Fn(b,d,e,f)|0;if(!h)j=5}else j=5;while(0);if((j|0)==5)if(g){h=c[b+64>>2]|0;h=db[c[(c[h+4>>2]|0)+4>>2]&3](c[h+16>>2]|0,d,0,f,g)|0;if(i&(h|0)!=0){j=f;Gn(b,d,e,c[j>>2]|0,c[j+4>>2]|0)}}else h=0;return h|0}function Bn(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;a=c[a+64>>2]|0;return cb[c[(c[a+4>>2]|0)+8>>2]&31](c[a+16>>2]|0,b,d,e)|0}function Cn(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;Ln(a,b,d,e)|0;a=c[a+64>>2]|0;kb[c[(c[a+4>>2]|0)+12>>2]&31](c[a+16>>2]|0,b,d,e);return}function Dn(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0;h=l;l=l+16|0;g=h;d=ro(a)|0;f=a+8|0;b=f;b=Jn(d,c[a>>2]&3,c[b>>2]|0,c[b+4>>2]|0)|0;do if(!b){b=c[d+64>>2]|0;d=c[(c[b+4>>2]|0)+16>>2]|0;if(d|0?(e=f,e=cb[d&31](c[b+16>>2]|0,c[a>>2]&3,c[e>>2]|0,c[e+4>>2]|0)|0,e|0):0){b=e;break}if((c[a>>2]&3|0)==2)b=0;else{e=c[f>>2]|0;f=c[f+4>>2]|0;c[g>>2]=37;b=g+8|0;c[b>>2]=e;c[b+4>>2]=f;pL(173895,81419,g)|0;b=173895}}while(0);l=h;return b|0}function En(a,b,d){a=a|0;b=b|0;d=d|0;a=c[a+64>>2]|0;ib[c[(c[a+4>>2]|0)+24>>2]&127](c[a+16>>2]|0,b,d);return}function Fn(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;i=l;l=l+32|0;h=i;b=c[(c[a+64>>2]|0)+56+(((b|0)==3?2:b)<<2)>>2]|0;if(((b|0)!=0?(f=Yo(a,d)|0,(f|0)!=0):0)?(c[h+24>>2]=f,g=bb[c[b>>2]&31](b,h,4)|0,(g|0)!=0):0){d=g+16|0;h=c[d+4>>2]|0;b=e;c[b>>2]=c[d>>2];c[b+4>>2]=h;b=1}else b=0;l=i;return b|0}function Gn(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0;h=Yn(a,32)|0;g=h+16|0;c[g>>2]=e;c[g+4>>2]=f;c[h+24>>2]=$o(a,d)|0;e=(b|0)==3?2:b;g=a+64|0;d=c[g>>2]|0;b=c[d+56+(e<<2)>>2]|0;if(!b){f=Pp(a,17696,c[4353]|0)|0;c[(c[g>>2]|0)+56+(e<<2)>>2]=f;b=c[g>>2]|0}else{f=b;b=d}b=c[b+68+(e<<2)>>2]|0;if(!b){b=Pp(a,17732,c[4353]|0)|0;c[(c[g>>2]|0)+68+(e<<2)>>2]=b}bb[c[f>>2]&31](f,h,1)|0;bb[c[b>>2]&31](b,h,1)|0;return}function Hn(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;a=b+16|0;b=c[a>>2]|0;a=c[a+4>>2]|0;d=d+16|0;e=c[d>>2]|0;d=c[d+4>>2]|0;return (a>>>0>d>>>0|(a|0)==(d|0)&b>>>0>e>>>0?1:(a>>>0>>0|(a|0)==(d|0)&b>>>0>>0)<<31>>31)|0}function In(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;b=c[b+24>>2]|0;e=c[d+24>>2]|0;return (b>>>0>e>>>0?1:(b>>>0>>0)<<31>>31)|0}function Jn(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;a=Kn(a,b,d,e)|0;if(!a)a=0;else a=c[a+24>>2]|0;return a|0}function Kn(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;g=l;l=l+32|0;f=g;a=c[(c[a+64>>2]|0)+68+(((b|0)==3?2:b)<<2)>>2]|0;if(!a)a=0;else{b=f+16|0;c[b>>2]=d;c[b+4>>2]=e;a=bb[c[a>>2]&31](a,f,4)|0}l=g;return a|0}function Ln(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=(b|0)==3?2:b;b=Kn(a,f,d,e)|0;if(!b)b=0;else{e=a+64|0;d=c[(c[e>>2]|0)+56+(f<<2)>>2]|0;bb[c[d>>2]&31](d,b,2)|0;e=c[(c[e>>2]|0)+68+(f<<2)>>2]|0;bb[c[e>>2]&31](e,b,2)|0;bp(a,c[b+24>>2]|0)|0;Zn(a,b);b=1}return b|0}function Mn(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;c[41987]=b;g=c[b+64>>2]|0;f=0;while(1){if((f|0)==3)break;h=g+56+(f<<2)|0;d=c[h>>2]|0;a:do if(d|0){d=bb[c[d>>2]&31](d,0,128)|0;while(1){if(!d)break a;e=c[h>>2]|0;e=bb[c[e>>2]&31](e,d,8)|0;if((a[c[d+24>>2]>>0]|0)!=37){d=e;continue}i=d+16|0;Ln(b,f,c[i>>2]|0,c[i+4>>2]|0)|0;d=e}}while(0);f=f+1|0}return}function Nn(a){a=a|0;c[41987]=a;a=a+64|0;On((c[a>>2]|0)+56|0);On((c[a>>2]|0)+68|0);return}function On(a){a=a|0;var b=0,d=0,e=0;b=0;while(1){if((b|0)==3)break;d=a+(b<<2)|0;e=c[d>>2]|0;if(e|0){Kl(e)|0;c[d>>2]=0}b=b+1|0}return}function Pn(a,b,c){a=a|0;b=b|0;c=c|0;if(!(gL(b,c,a)|0))a=0;else a=rJ(b)|0;return a|0}function Qn(a,b){a=a|0;b=b|0;return WL(b,a)|0}function Rn(a){a=a|0;return PL(a)|0}function Sn(a){a=a|0;var b=0,d=0,e=0;b=l;l=l+32|0;e=b+12|0;d=b;c[4446]=c[4443];c[4447]=c[4444];c[e>>2]=a;c[e+4>>2]=rJ(a)|0;c[e+8>>2]=0;c[d>>2]=17792;c[d+4>>2]=17668;c[d+8>>2]=17780;a=er(e,d)|0;fp(0);l=b;return a|0}function Tn(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;if((e|0)!=0?(h=b+8|0,f=c[h>>2]|0,(f|0)<(c[b+4>>2]|0)):0){i=(c[b>>2]|0)+f|0;b=0;g=a[i>>0]|0;f=d;d=i;while(1){d=d+1|0;a[f>>0]=g;b=b+1|0;if(!(g<<24>>24!=10&(b|0)<(e|0)))break;g=a[d>>0]|0;if(!(g<<24>>24))break;else f=f+1|0}c[h>>2]=(c[h>>2]|0)+b}else b=0;return b|0}function Un(a){a=a|0;return 0}function Vn(a,b){a=a|0;b=b|0;a=ZI(b)|0;VN(a|0,0,b|0)|0;return a|0}function Wn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;a=aJ(b,d)|0;if(d>>>0>c>>>0)VN(a+c|0,0,d-c|0)|0;return a|0}function Xn(a,b){a=a|0;b=b|0;_I(b);return}function Yn(a,b){a=a|0;b=b|0;var d=0;d=l;l=l+16|0;a=c[a+64>>2]|0;a=ab[c[(c[a>>2]|0)+4>>2]&63](c[a+12>>2]|0,b)|0;if(!a)_l(1,81425,d)|0;l=d;return a|0}function Zn(a,b){a=a|0;b=b|0;if(b|0){a=c[a+64>>2]|0;hb[c[(c[a>>2]|0)+12>>2]&31](c[a+12>>2]|0,b)}return}function _n(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;a=(c[b+16>>2]|0)+8|0;b=c[a>>2]|0;a=c[a+4>>2]|0;d=(c[d+16>>2]|0)+8|0;e=c[d>>2]|0;d=c[d+4>>2]|0;return (a>>>0>>0|(a|0)==(d|0)&b>>>0>>0?-1:(a>>>0>d>>>0|(a|0)==(d|0)&b>>>0>e>>>0)&1)|0}function $n(a,b,d){a=a|0;b=b|0;d=d|0;a=c[b+16>>2]|0;if((a+28|0)!=(b|0))Zn(c[a+24>>2]|0,b);return}function ao(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;b=(c[c[b+16>>2]>>2]|0)>>>4;e=(c[c[d+16>>2]>>2]|0)>>>4;return (b>>>0>>0?-1:b>>>0>e>>>0&1)|0}function bo(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=167040;c[e>>2]=b;c[e+4>>2]=d;c[41992]=167032;a=c[a+40>>2]|0;a=bb[c[a>>2]&31](a,167952,4)|0;if(!a)a=0;else a=c[a+16>>2]|0;return a|0}function co(a){a=a|0;a=c[a+36>>2]|0;a=bb[c[a>>2]&31](a,0,128)|0;if(!a)a=0;else a=c[a+16>>2]|0;return a|0}function eo(a,b){a=a|0;b=b|0;var d=0;b=Qm(a,b)|0;if((b|0)!=0?(d=c[a+36>>2]|0,d=bb[c[d>>2]&31](d,b,8)|0,(d|0)!=0):0)b=c[d+16>>2]|0;else b=0;return b|0}function fo(a){a=a|0;a=c[a+36>>2]|0;a=bb[c[a>>2]&31](a,0,256)|0;if(!a)a=0;else a=c[a+16>>2]|0;return a|0}function go(a,b){a=a|0;b=b|0;var d=0;b=Qm(a,b)|0;if((b|0)!=0?(d=c[a+36>>2]|0,d=bb[c[d>>2]&31](d,b,16)|0,(d|0)!=0):0)b=c[d+16>>2]|0;else b=0;return b|0}function ho(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;e=bo(a,b,c)|0;do if((d|0)!=0&(e|0)==0){e=so(a)|0;if((e|0)!=(a|0)?(f=bo(e,b,c)|0,f|0):0){io(a,f,1)|0;e=f;break}if(!(Bn(a,1,b,c)|0))e=0;else{e=kn(a,1)|0;e=jo(a,b,c,e,z)|0;ko(a,e);lo(a,e)}}while(0);return e|0}function io(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=so(a)|0;if((e|0)==(c[b+24>>2]|0)){e=b+8|0;e=bo(a,c[e>>2]|0,c[e+4>>2]|0)|0;if((d|0)!=0&(e|0)==0){e=Lp(a)|0;if(!e)e=0;else{d=io(e,b,d)|0;mo(a,d);return d|0}}}else e=0;return e|0}function jo(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0;g=Yn(b,64)|0;h=c[g>>2]|0;i=g+8|0;c[i>>2]=d;c[i+4>>2]=e;c[g>>2]=h&12|f<<4|1;c[g+24>>2]=so(b)|0;if(a[(so(b)|0)+24>>0]&64)No(g,81367,16,0)|0;return g|0}function ko(a,b){a=a|0;b=b|0;do{mo(a,b);a=Lp(a)|0}while((a|0)!=0);return}function lo(b,c){b=b|0;c=c|0;if(a[(so(b)|0)+24>>0]&64)mm(b,c);to(b,c);return}function mo(a,b){a=a|0;b=b|0;var d=0,e=0;e=a+40|0;Sl(c[e>>2]|0)|0;if((so(a)|0)==(a|0))d=b+28|0;else d=Yn(a,36)|0;c[d+16>>2]=b;e=c[e>>2]|0;bb[c[e>>2]&31](e,d,1)|0;e=c[a+36>>2]|0;bb[c[e>>2]&31](e,d,1)|0;return}function no(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;j=l;l=l+16|0;g=j;h=so(a)|0;if(An(a,1,b,g,0)|0){e=g;e=bo(a,c[e>>2]|0,c[e+4>>2]|0)|0;if(!e)if(!((d|0)==0|(h|0)==(a|0))?(f=g,f=bo(h,c[f>>2]|0,c[f+4>>2]|0)|0,(f|0)!=0):0)e=io(a,f,1)|0;else i=6}else i=6;if((i|0)==6)if((d|0)!=0?(An(a,1,b,g,1)|0)!=0:0){i=g;h=c[i>>2]|0;i=c[i+4>>2]|0;e=kn(a,1)|0;e=jo(a,h,i,e,z)|0;ko(a,e);lo(a,e);En(a,1,e)}else e=0;l=j;return e|0}function oo(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;c[42001]=b;d=Um(a,b)|0;while(1){if(!d)break;e=Vm(a,d,b)|0;bn(a,d,0);d=e}e=c[a+40>>2]|0;bb[c[e>>2]&31](e,167988,2)|0;e=c[a+36>>2]|0;bb[c[e>>2]&31](e,167988,2)|0;return}function po(b,d){b=b|0;d=d|0;var e=0,f=0,g=0;f=d+8|0;e=f;if(bo(b,c[e>>2]|0,c[e+4>>2]|0)|0){if((so(b)|0)==(b|0)){e=Um(b,d)|0;while(1){if(!e)break;g=Vm(b,e,d)|0;dn(b,e)|0;e=g}if(a[b+24>>0]&64)Gm(d);xo(b,d);Vo(d);g=f;Cn(b,1,c[g>>2]|0,c[g+4>>2]|0)}if(!(wq(b,d,54,0,0)|0))if((so(b)|0)==(b|0)){Zn(b,d);e=0}else e=0;else e=-1}else e=-1;return e|0}function qo(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;h=l;l=l+16|0;e=h;d=c[b>>2]|0;do if(!(d&3))if((Lp(b)|0)==(a|0)){d=c[b>>2]|0;g=5;break}else{_l(1,81451,e)|0;f=-1;break}else g=5;while(0);a:do if((g|0)==5)switch(d&3){case 1:{f=po(a,b)|0;break a}case 2:case 3:{f=dn(a,b)|0;break a}case 0:{f=ln(b)|0;break a}default:{}}while(0);l=h;return f|0}function ro(a){a=a|0;var b=0;switch(c[a>>2]&3){case 2:case 3:{b=c[(c[a+40>>2]|0)+24>>2]|0;break}case 1:{b=c[a+24>>2]|0;break}case 0:{b=a;break}default:{}}return b|0}function so(a){a=a|0;var b=0;switch(c[a>>2]&3){case 2:case 3:{b=(c[a+40>>2]|0)+24|0;break}case 1:{b=a+24|0;break}case 0:{b=a+60|0;break}default:{}}return c[b>>2]|0}function to(b,d){b=b|0;d=d|0;var e=0;e=c[b+64>>2]|0;if(!(a[e+52>>0]|0))Do(b,d,100,0);else uo(b,d,c[e+48>>2]|0);return}function uo(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;a:do if(d|0){uo(a,b,c[d+8>>2]|0);switch(c[b>>2]&3){case 0:{e=c[d>>2]|0;break}case 1:{e=(c[d>>2]|0)+12|0;break}case 2:{e=(c[d>>2]|0)+24|0;break}default:break a}e=c[e>>2]|0;if(e|0)ib[e&127](a,b,c[d+4>>2]|0)}while(0);return}function vo(b,d,e){b=b|0;d=d|0;e=e|0;var f=0;f=c[b+64>>2]|0;if(!(a[f+52>>0]|0))Do(b,d,101,e);else wo(b,d,e,c[f+48>>2]|0);return}function wo(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;a:do if(e|0){wo(a,b,d,c[e+8>>2]|0);switch(c[b>>2]&3){case 0:{f=(c[e>>2]|0)+4|0;break}case 1:{f=(c[e>>2]|0)+16|0;break}case 2:{f=(c[e>>2]|0)+28|0;break}default:break a}f=c[f>>2]|0;if(f|0)kb[f&31](a,b,c[e+4>>2]|0,d)}while(0);return}function xo(b,d){b=b|0;d=d|0;var e=0;e=c[b+64>>2]|0;if(!(a[e+52>>0]|0))Do(b,d,102,0);else yo(b,d,c[e+48>>2]|0);return}function yo(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;a:do if(d|0){yo(a,b,c[d+8>>2]|0);switch(c[b>>2]&3){case 0:{e=(c[d>>2]|0)+8|0;break}case 1:{e=(c[d>>2]|0)+20|0;break}case 2:{e=(c[d>>2]|0)+32|0;break}default:break a}e=c[e>>2]|0;if(e|0)ib[e&127](a,b,c[d+4>>2]|0)}while(0);return}function zo(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=Yn(a,12)|0;c[e>>2]=b;c[e+4>>2]=d;d=(c[a+64>>2]|0)+48|0;c[e+8>>2]=c[d>>2];c[d>>2]=e;return}function Ao(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;e=(c[a+64>>2]|0)+48|0;d=c[e>>2]|0;a:do if(!d)d=-1;else{if((c[d>>2]|0)!=(b|0)){while(1){if(!d){d=-1;break a}e=d+8|0;f=c[e>>2]|0;if((c[f>>2]|0)==(b|0))break;else d=f}if(f)c[e>>2]=c[f+8>>2]}else c[e>>2]=c[d+8>>2];Zn(a,d);d=0}while(0);return d|0}function Bo(a,b){a=a|0;b=b|0;var d=0;d=so(a)|0;a:do if((d|0)==(so(b)|0))switch(c[b>>2]&3){case 0:{while(1){if((b|0)==(a|0)){b=1;break a}b=Lp(b)|0;if(!b){b=0;break}}break}case 1:{b=b+8|0;b=(ho(a,c[b>>2]|0,c[b+4>>2]|0,0)|0)!=0;break a}default:{b=(en(a,b,0)|0)!=0;break a}}else b=0;while(0);return b&1|0}function Co(a){a=a|0;return c[a>>2]&3|0}function Do(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0;h=l;l=l+16|0;g=h;f=No(a,81475,44,0)|0;switch(c|0){case 100:{e=Eo(f,b,100)|0;if(!(Fo(e,b)|0))Go(e,a,b,d)|0;break}case 101:{if(((Fo(Eo(f,b,100)|0,b)|0)==0?(Fo(Eo(f,b,102)|0,b)|0)==0:0)?(e=Eo(f,b,101)|0,(Fo(e,b)|0)==0):0)Go(e,a,b,d)|0;break}case 102:{Ho(Eo(f,b,100)|0,b);Ho(Eo(f,b,101)|0,b);e=Eo(f,b,102)|0;if(!(Fo(e,b)|0))Go(e,a,b,d)|0;break}default:_l(1,81487,g)|0}l=h;return}function Eo(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;g=l;l=l+16|0;e=g;a:do switch(c[b>>2]&3){case 0:switch(d|0){case 100:{d=a+8|0;break a}case 101:{d=a+20|0;break a}case 102:{d=a+32|0;break a}default:{f=14;break a}}case 1:switch(d|0){case 100:{d=a+12|0;break a}case 101:{d=a+24|0;break a}case 102:{d=a+36|0;break a}default:{f=14;break a}}case 2:switch(d|0){case 100:{d=a+16|0;break a}case 101:{d=a+28|0;break a}case 102:{d=a+40|0;break a}default:{f=14;break a}}default:f=14}while(0);if((f|0)==14){_l(1,81521,e)|0;d=0}a=c[d>>2]|0;if(!a){a=ro(b)|0;a=Pp(a,17884,c[4353]|0)|0;c[d>>2]=a}l=g;return a|0}function Fo(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=l;l=l+32|0;e=d;f=Io(b)|0;b=e+8|0;c[b>>2]=f;c[b+4>>2]=z;b=bb[c[a>>2]&31](a,e,4)|0;l=d;return b|0}function Go(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;f=Yn(ro(d)|0,32)|0;c[f+20>>2]=d;g=Io(d)|0;d=f+8|0;c[d>>2]=g;c[d+4>>2]=z;c[f+16>>2]=b;if(e|0){g=Yn(b,8)|0;c[f+24>>2]=g;c[g>>2]=e}bb[c[a>>2]&31](a,f,1)|0;return f|0}function Ho(a,b){a=a|0;b=b|0;b=Fo(a,b)|0;if(b|0)bb[c[a>>2]&31](a,b,2)|0;return}function Io(a){a=a|0;a=a+8|0;z=c[a+4>>2]|0;return c[a>>2]|0}function Jo(a,b,d){a=a|0;b=b|0;d=d|0;Ko(b);Zn(c[b+16>>2]|0,b);return}function Ko(a){a=a|0;var b=0,d=0;b=a+16|0;a=c[a+24>>2]|0;while(1){if(!a)break;d=c[a+4>>2]|0;Zn(c[b>>2]|0,a);a=d}return}function Lo(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0;k=l;l=l+16|0;i=k;h=c[b+16>>2]|0;f=h;while(1){if(!f){f=0;break}g=c[f>>2]|0;if((g|0)==(d|0)){j=7;break}if((a[d>>0]|0)==(a[g>>0]|0)?(xJ(d,g)|0)==0:0){j=7;break}f=c[f+4>>2]|0;if((f|0)==(h|0)){f=0;break}}do if((j|0)==7){if(!(c[b>>2]&4)){if((f|0)==(h|0)&(e|0)==0){f=h;break}Mo(b,f,e);break}if(e)if((h|0)==(f|0))f=h;else _l(1,81546,i)|0}while(0);l=k;return f|0}function Mo(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;c[a+16>>2]=b;e=c[a>>2]|0;d=d<<2&4;c[a>>2]=e&-5|d;if(e&2|0){e=(e&3|0)==3?-1:1;c[a+(e*48|0)+16>>2]=b;e=a+(e*48|0)|0;c[e>>2]=c[e>>2]&-5|d}return}function No(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;h=ro(a)|0;f=Lo(a,b,0)|0;a:do if((d|0)!=0&(f|0)==0){d=Yn(h,d)|0;c[d>>2]=$o(h,b)|0;switch(c[a>>2]&3){case 0:{Oo(a,d);g=d;break a}case 1:{Oo(a,d);g=d;break a}case 2:case 3:{Oo(a,d);g=d;break a}default:{}}}else g=f;while(0);if(e|0)Lo(a,b,1)|0;return g|0}function Oo(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=c[a+16>>2]|0;do if(d){e=d+4|0;f=c[e>>2]|0;if((f|0)==(d|0)){c[e>>2]=b;e=d;d=b;break}else{c[b+4>>2]=f;e=b;break}}else{e=b;d=b}while(0);c[d+4>>2]=e;if(!(c[a>>2]&4))Mo(a,b,0);return}function Po(a,b){a=a|0;b=b|0;var d=0,e=0;e=ro(a)|0;d=Lo(a,b,0)|0;if(!d)b=-1;else{Qo(a,d);if(!(c[a>>2]&3)){Ro(e,a,d);b=d}else{wq(so(e)|0,a,55,d,0)|0;b=d}bp(e,c[d>>2]|0)|0;Zn(e,b);b=0}return b|0}function Qo(a,b){a=a|0;b=b|0;var d=0;a=c[a+16>>2]|0;do{d=a+4|0;a=c[d>>2]|0}while((a|0)!=(b|0));c[d>>2]=c[b+4>>2];return}function Ro(a,b,d){a=a|0;b=b|0;d=d|0;if((c[b+16>>2]|0)==(d|0)){a=c[d+4>>2]|0;Mo(b,(a|0)==(d|0)?0:a,0)}return}function So(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0;f=(d|0)>-1;g=f?d:0-d|0;a:do switch(b|0){case 0:{No(a,c,g,e)|0;if(!f){b=Jp(a)|0;while(1){if(!b)break a;So(b,0,c,d,e);b=Kp(b)|0}}break}case 3:case 2:case 1:{d=(b|0)==1;b=co(a)|0;while(1){if(!b)break a;b:do if(d)No(b,c,g,e)|0;else{f=Pm(a,b)|0;while(1){if(!f)break b;No(f,c,g,e)|0;f=Rm(a,f)|0}}while(0);b=eo(a,b)|0}}default:{}}while(0);return}function To(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;a:do switch(b|0){case 0:{wq(a,a,56,c,1)|0;break}case 3:case 2:case 1:{e=(b|0)==1;d=co(a)|0;while(1){if(!d)break a;b:do if(e)Po(d,c)|0;else{b=Pm(a,d)|0;while(1){if(!b)break b;Po(b,c)|0;b=Rm(a,b)|0}}while(0);d=eo(a,d)|0}}default:{}}while(0);return}function Uo(a,b,c){a=a|0;b=b|0;c=c|0;Po(b,c)|0;return}function Vo(a){a=a|0;var b=0,d=0,e=0;d=ro(a)|0;b=a+16|0;a=c[b>>2]|0;if(a|0)do{e=a;a=c[a+4>>2]|0;bp(d,c[e>>2]|0)|0;Zn(d,e)}while((a|0)!=(c[b>>2]|0));c[b>>2]=0;return}function Wo(a){a=a|0;return Rp(a,Xo(a)|0)|0}function Xo(a){a=a|0;var b=0,d=0;if(!a)d=168024;else d=(c[a+64>>2]|0)+20|0;b=c[d>>2]|0;if(!b){b=Pp(a,17920,c[4353]|0)|0;c[d>>2]=b;a=167096;c[a>>2]=-2147483648;c[a+4>>2]=0;a=167104;c[a>>2]=2147483647;c[a+4>>2]=-1}return b|0}function Yo(a,b){a=a|0;b=b|0;return Zo(Xo(a)|0,b)|0}function Zo(a,b){a=a|0;b=b|0;a=_o(a,b)|0;if(!a)a=0;else a=c[a+16>>2]|0;return a|0}function _o(a,b){a=a|0;b=b|0;var d=0,e=0;d=l;l=l+32|0;e=d;c[e+16>>2]=b;b=bb[c[a>>2]&31](a,e,4)|0;l=d;return b|0}function $o(a,b){a=a|0;b=b|0;var d=0,e=0;if(!b)d=0;else{e=Xo(a)|0;d=_o(e,b)|0;if(!d){d=(rJ(b)|0)+24|0;if(!a)d=ZI(d)|0;else d=Yn(a,d)|0;a=d+8|0;c[a>>2]=1;c[a+4>>2]=0;a=d+20|0;xK(a,b)|0;c[d+16>>2]=a;bb[c[e>>2]&31](e,d,1)|0}else{e=d+8|0;b=e;b=HN(c[b>>2]|0,c[b+4>>2]|0,1,0)|0;c[e>>2]=b;c[e+4>>2]=z}d=c[d+16>>2]|0}return d|0}function ap(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;if(!b)d=0;else{e=Xo(a)|0;d=_o(e,b)|0;if(!d){d=(rJ(b)|0)+24|0;if(!a)d=ZI(d)|0;else d=Yn(a,d)|0;g=167096;f=c[g+4>>2]|0;a=d+8|0;c[a>>2]=c[g>>2]|1;c[a+4>>2]=f;a=d+20|0;xK(a,b)|0;c[d+16>>2]=a;bb[c[e>>2]&31](e,d,1)|0}else{g=d+8|0;f=g;f=HN(c[f>>2]|0,c[f+4>>2]|0,1,0)|0;c[g>>2]=f;c[g+4>>2]=z}d=c[d+16>>2]|0}return d|0}function bp(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;if((b|0)!=0?(d=Xo(a)|0,e=_o(d,b)|0,(e|0)!=0):0)if((c[e+16>>2]|0)==(b|0)?(b=e+8|0,g=b,g=HN(c[g>>2]|0,c[g+4>>2]|0,-1,-1)|0,f=z,b,c[b>>2]=g,c[b+4>>2]=f,b=167104,(g|0)==0&(f|0)==0|(c[b>>2]|0)==0&(c[b+4>>2]|0)==0):0){Qp(a,d,e)|0;a=0}else a=0;else a=-1;return a|0}function cp(a){a=a|0;var b=0;if(!a)a=0;else{a=a+-12|0;b=167096;a=c[b>>2]&c[a>>2]}return a|0}function dp(a){a=a|0;var b=0,d=0,e=0;if(a|0){d=167096;a=a+-12|0;e=a;b=c[e+4>>2]|c[d+4>>2];c[a>>2]=c[e>>2]|c[d>>2];c[a+4>>2]=b}return}function ep(a){a=a|0;c[4489]=a;return}function fp(a){a=a|0;c[42011]=a;c[4489]=1;return}function gp(a,b){a=a|0;b=b|0;c[42012]=a;c[42013]=b;c[42014]=0;return}function hp(){var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;if(!(c[42015]|0)){c[42015]=1;if(!(c[42016]|0))c[42016]=1;if(!(c[42007]|0))c[42007]=c[13853];if(!(c[42008]|0))c[42008]=c[13885];k=c[42017]|0;if(!((k|0)!=0?(c[k>>2]|0)!=0:0)){ip();k=jp(c[42007]|0,16384)|0;c[c[42017]>>2]=k}kp()}a:while(1){j=c[42018]|0;a[j>>0]=a[173927]|0;e=(c[(c[c[42017]>>2]|0)+28>>2]|0)+(c[42016]|0)|0;f=j;b:while(1){h=f;while(1){f=c[17960+(d[h>>0]<<2)>>2]|0;if(b[56680+(e<<1)>>1]|0){c[42019]=e;c[42020]=h}c:while(1){g=f&255;do{f=g+(b[56866+(e<<1)>>1]|0)|0;if((e|0)==(b[57076+(f<<1)>>1]|0))break c;k=b[57612+(e<<1)>>1]|0;e=k<<16>>16}while(k<<16>>16<=92);f=c[18984+(g<<2)>>2]|0}e=b[57822+(f<<1)>>1]|0;f=h+1|0;if((b[56866+(e<<1)>>1]|0)==219)break;else h=f}d:while(1){k=j;e:while(1){e=b[56680+(e<<1)>>1]|0;if(!(e<<16>>16)){e=b[56680+(c[42019]<<1)>>1]|0;f=c[42020]|0}else e=e<<16>>16;c[42009]=j;i=f;c[42010]=i-k;a[173927]=a[f>>0]|0;a[f>>0]=0;c[42018]=f;f:while(1){switch(e|0){case 1:{m=27;break a}case 12:{m=53;break a}case 13:{m=55;break a}case 14:{m=57;break a}case 15:{m=61;break a}case 16:{m=65;break a}case 17:{m=67;break a}case 18:{m=69;break a}case 19:{m=72;break a}case 20:{m=75;break a}case 21:{m=78;break a}case 23:{m=86;break a}case 33:{m=118;break a}case 39:case 38:case 37:case 36:{l=0;break a}case 2:{m=29;break b}case 3:{m=32;break b}case 4:{m=35;break b}case 5:{m=37;break b}case 6:{m=39;break b}case 7:{m=42;break b}case 8:{m=44;break b}case 9:{m=47;break b}case 10:{m=49;break b}case 11:{m=51;break b}case 22:{m=83;break b}case 24:{m=89;break b}case 25:{m=92;break b}case 26:{m=95;break b}case 27:{m=98;break b}case 28:{m=101;break b}case 29:{m=104;break b}case 30:{m=109;break b}case 31:{m=112;break b}case 32:{m=115;break b}case 34:{m=121;break b}case 0:break f;case 35:break;default:{m=134;break a}}h=c[42009]|0;a[f>>0]=a[173927]|0;e=c[42017]|0;g=c[e>>2]|0;if(!(c[g+44>>2]|0)){n=c[g+16>>2]|0;c[42022]=n;c[g>>2]=c[42007];g=c[e>>2]|0;c[g+44>>2]=1;e=n}else e=c[42022]|0;if((c[42018]|0)>>>0<=((c[g+4>>2]|0)+e|0)>>>0){m=128;break e}switch(tp()|0){case 0:{m=132;break d}case 2:{m=133;break e}case 1:break;default:continue a}c[42018]=c[42009];e=(((c[42016]|0)+-1|0)/2|0)+36|0}a[f>>0]=a[173927]|0;f=c[42020]|0;e=c[42019]|0}if((m|0)==128){m=0;g=i-h|0;h=c[42009]|0;f=h+(g+-1)|0;c[42018]=f;e=rp()|0;i=sp(e)|0;j=c[42009]|0;if(!i)continue;else{m=129;break}}else if((m|0)==133){m=0;f=(c[(c[c[42017]>>2]|0)+4>>2]|0)+(c[42022]|0)|0;c[42018]=f;e=rp()|0;j=c[42009]|0;continue}}if((m|0)==129){m=0;f=h+g|0;c[42018]=f;e=i;continue}else if((m|0)==132){m=0;f=(c[42009]|0)+(i-h+-1)|0;c[42018]=f;e=rp()|0;j=c[42009]|0;continue}}switch(m|0){case 29:{m=0;e=c[42010]|0;if(e|0)c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;c[4489]=(c[4489]|0)+1;continue a}case 32:{m=0;e=c[42010]|0;if(e|0)c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;c[42016]=3;continue a}case 35:{m=0;e=c[42010]|0;if(!e)continue a;c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;continue a}case 37:{m=0;e=c[42010]|0;if(!e)continue a;c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;continue a}case 39:{m=0;e=c[42010]|0;if(e|0)c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;c[42016]=1;continue a}case 42:{m=0;e=c[42010]|0;if(!e)continue a;c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;continue a}case 44:{m=0;e=c[42010]|0;if(e|0)c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;lp();continue a}case 47:{m=0;e=c[42010]|0;if(!e)continue a;c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;continue a}case 49:{m=0;e=c[42010]|0;if(!e)continue a;c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;continue a}case 51:{m=0;e=c[42010]|0;if(!e)continue a;c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;continue a}case 83:{m=0;e=c[42010]|0;if(e|0)c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;c[42016]=5;np();continue a}case 89:{m=0;e=c[42010]|0;if(e|0)c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;pp(83714);continue a}case 92:{m=0;e=c[42010]|0;if(e|0)c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;pp(81579);continue a}case 95:{m=0;e=c[42010]|0;if(e|0)c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;c[4489]=(c[4489]|0)+1;continue a}case 98:{m=0;f=c[42010]|0;e=c[42009]|0;if(f|0)c[(c[c[42017]>>2]|0)+28>>2]=(a[e+(f+-1)>>0]|0)==10&1;pp(e);continue a}case 101:{m=0;e=c[42010]|0;if(e|0)c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;c[42016]=7;c[42021]=1;np();continue a}case 104:{m=0;e=c[42010]|0;if(e|0)c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;n=(c[42021]|0)+-1|0;c[42021]=n;if(!n){m=108;break a}pp(c[42009]|0);continue a}case 109:{m=0;f=c[42010]|0;e=c[42009]|0;if(f|0)c[(c[c[42017]>>2]|0)+28>>2]=(a[e+(f+-1)>>0]|0)==10&1;c[42021]=(c[42021]|0)+1;pp(e);continue a}case 112:{m=0;f=c[42010]|0;e=c[42009]|0;if(f|0)c[(c[c[42017]>>2]|0)+28>>2]=(a[e+(f+-1)>>0]|0)==10&1;pp(e);c[4489]=(c[4489]|0)+1;continue a}case 115:{m=0;f=c[42010]|0;e=c[42009]|0;if(f|0)c[(c[c[42017]>>2]|0)+28>>2]=(a[e+(f+-1)>>0]|0)==10&1;pp(e);continue a}case 121:{m=0;f=c[42010]|0;e=c[42009]|0;if(f|0)c[(c[c[42017]>>2]|0)+28>>2]=(a[e+(f+-1)>>0]|0)==10&1;XL(e,f,1,c[42008]|0)|0;continue a}}}switch(m|0){case 27:{e=c[42010]|0;if(!e)l=-1;else{c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;l=-1}break}case 53:{e=c[42010]|0;if(!e)l=259;else{c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;l=259}break}case 55:{e=c[42010]|0;if(!e)l=260;else{c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;l=260}break}case 57:{e=c[42010]|0;if(e|0)c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;if(!(c[42014]|0)){c[42014]=258;l=258}else l=258;break}case 61:{e=c[42010]|0;if(e|0)c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;if(!(c[42014]|0)){c[42014]=261;l=261}else l=261;break}case 65:{e=c[42010]|0;if(!e)l=263;else{c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;l=263}break}case 67:{e=c[42010]|0;if(!e)l=262;else{c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;l=262}break}case 69:{e=c[42010]|0;if(e|0)c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;l=(c[42014]|0)==261?264:45;break}case 72:{e=c[42010]|0;if(e|0)c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;l=(c[42014]|0)==258?264:45;break}case 75:{f=c[42010]|0;e=c[42009]|0;if(f|0)c[(c[c[42017]>>2]|0)+28>>2]=(a[e+(f+-1)>>0]|0)==10&1;c[42037]=$o(c[41987]|0,e)|0;l=267;break}case 78:{e=c[42010]|0;if(e|0)c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;if(mp()|0){m=(c[42010]|0)+-1|0;a[f>>0]=a[173927]|0;n=j+m|0;c[42018]=n;c[42009]=j;c[42010]=m;a[173927]=a[n>>0]|0;a[n>>0]=0;c[42018]=n}c[42037]=$o(c[41987]|0,c[42009]|0)|0;l=267;break}case 86:{e=c[42010]|0;if(e|0)c[(c[c[42017]>>2]|0)+28>>2]=(a[(c[42009]|0)+(e+-1)>>0]|0)==10&1;c[42016]=1;op();l=268;break}case 108:{c[42016]=1;qp();l=268;break}case 118:{f=c[42010]|0;e=c[42009]|0;if(f|0)c[(c[c[42017]>>2]|0)+28>>2]=(a[e+(f+-1)>>0]|0)==10&1;l=a[e>>0]|0;break}case 134:{up(81582);break}}return l|0}function ip(){var a=0,b=0,d=0;b=c[42017]|0;do if(!b){a=Bp(4)|0;c[42017]=a;if(!a)up(81940);else{c[a>>2]=0;a=1;d=9;break}}else{a=c[42028]|0;if(0>=(a+-1|0)>>>0){a=a+8|0;b=vp(b,a<<2)|0;c[42017]=b;if(!b)up(81940);else{d=b+(c[42028]<<2)|0;c[d>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;c[d+16>>2]=0;c[d+20>>2]=0;c[d+24>>2]=0;c[d+28>>2]=0;d=9;break}}}while(0);if((d|0)==9)c[42028]=a;return}function jp(a,b){a=a|0;b=b|0;var d=0;d=Bp(48)|0;if(!d)up(81895);c[d+12>>2]=b;b=Bp(b+2|0)|0;c[d+4>>2]=b;if(!b)up(81895);else{c[d+20>>2]=1;xp(d,a);return d|0}return 0}function kp(){var b=0,d=0;d=c[42017]|0;b=c[d>>2]|0;c[42022]=c[b+16>>2];b=c[b+8>>2]|0;c[42018]=b;c[42009]=b;c[42007]=c[c[d>>2]>>2];a[173927]=a[b>>0]|0;return}function lp(){var b=0,d=0,e=0,f=0,g=0,h=0,i=0;g=l;l=l+32|0;f=g;d=g+16|0;e=g+12|0;h=c[42009]|0;b=h+1|0;i=(VJ(b,81879,4)|0)==0;b=i?h+5|0:b;c[f>>2]=e;c[f+4>>2]=g+20;c[f+8>>2]=d;f=cM(b,81884,f)|0;if((f|0)>0?(c[4489]=(c[e>>2]|0)+-1,(f|0)!=1):0){d=b+(c[d>>2]|0)|0;b=d;a:while(1){e=a[b>>0]|0;switch(e<<24>>24){case 0:case 34:break a;default:{}}b=b+1|0}if((b|0)!=(d|0)&e<<24>>24==34){a[b>>0]=0;Ap(d,b-d|0)}}l=g;return}function mp(){var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;j=l;l=l+2080|0;i=j+8|0;f=j;b=j+1056|0;d=j+32|0;h=j+16|0;k=a[(c[42009]|0)+((c[42010]|0)+-1)>>0]|0;e=k<<24>>24==46;if(e|((k&255)+-48|0)>>>0<10)if(e?(zp()|0)!=0:0)g=4;else b=0;else g=4;if((g|0)==4){k=c[42011]|0;cm(h,1024,b);fm(h,81790)|0;fm(h,c[42009]|0)|0;c[f>>2]=c[4489];pL(d,81834,f)|0;fm(h,d)|0;fm(h,(k|0)==0?81784:k)|0;fm(h,81851)|0;d=h+4|0;b=c[d>>2]|0;if(b>>>0>=(c[h+8>>2]|0)>>>0){dm(h,1)|0;b=c[d>>2]|0}a[b>>0]=0;b=c[h>>2]|0;c[d>>2]=b;c[i>>2]=b;_l(0,81876,i)|0;gm(h);b=1}l=j;return b|0}function np(){var b=0;b=c[42023]|0;if(!b){b=ZI(1024)|0;c[42023]=b;c[42025]=b+1024}c[42024]=b;a[b>>0]=0;return}function op(){c[42037]=$o(c[41987]|0,c[42023]|0)|0;a[c[42023]>>0]=0;return}function pp(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;e=c[42024]|0;d=c[42023]|0;if(e>>>0>d>>>0){e=e+-1|0;f=3}a:while(1){if((f|0)==3)c[42024]=e;f=c[42025]|0;g=f;do{h=b;b=b+1|0;h=a[h>>0]|0;i=e;e=e+1|0;a[i>>0]=h;if(!(h<<24>>24))break a}while(e>>>0>>0);c[42024]=e;f=d;i=g-f<<1;d=aJ(d,i)|0;c[42023]=d;c[42025]=d+i;e=d+(e-f)|0;f=3}c[42024]=e;return}function qp(){c[42037]=ap(c[41987]|0,c[42023]|0)|0;a[c[42023]>>0]=0;return}function rp(){var d=0,e=0,f=0,g=0,h=0;h=c[42018]|0;g=c[42009]|0;e=(c[(c[c[42017]>>2]|0)+28>>2]|0)+(c[42016]|0)|0;while(1){if(g>>>0>=h>>>0)break;d=a[g>>0]|0;if(!(d<<24>>24))d=1;else d=c[17960+((d&255)<<2)>>2]|0;if(b[56680+(e<<1)>>1]|0){c[42019]=e;c[42020]=g}a:while(1){f=d&255;do{d=f+(b[56866+(e<<1)>>1]|0)|0;if((e|0)==(b[57076+(d<<1)>>1]|0))break a;d=b[57612+(e<<1)>>1]|0;e=d<<16>>16}while(d<<16>>16<=92);d=c[18984+(f<<2)>>2]|0}g=g+1|0;e=b[57822+(d<<1)>>1]|0}return e|0}function sp(a){a=a|0;var d=0;if(b[56680+(a<<1)>>1]|0){d=c[42018]|0;c[42019]=a;c[42020]=d}while(1){d=(b[56866+(a<<1)>>1]|0)+1|0;if((a|0)==(b[57076+(d<<1)>>1]|0))break;a=b[57612+(a<<1)>>1]|0}d=b[57822+(d<<1)>>1]|0;return (d<<16>>16==92?0:d<<16>>16)|0}function tp(){var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;j=c[42017]|0;g=c[j>>2]|0;i=c[g+4>>2]|0;f=c[42009]|0;l=c[42018]|0;k=l;if(l>>>0>(i+((c[42022]|0)+1)|0)>>>0)up(81637);h=k-f|0;if(!(c[g+40>>2]|0))b=(h|0)==1?1:2;else{l=h+-1|0;h=i;g=0;while(1){if((g|0)>=(l|0))break;a[h>>0]=a[f>>0]|0;h=h+1|0;f=f+1|0;g=g+1|0}f=c[j>>2]|0;do if((c[f+44>>2]|0)==2){c[42022]=0;c[f+16>>2]=0;e=f;m=17}else{while(1){i=f+12|0;h=c[i>>2]|0;g=h-l+-1|0;if(g|0){m=16;break}g=f+4|0;j=c[g>>2]|0;if(!(c[f+20>>2]|0)){m=12;break}f=h<<1;f=(f|0)==0?(h>>>3)+h|0:f;c[i>>2]=f;f=vp(j,f+2|0)|0;c[g>>2]=f;if(!f)break;j=f+(k-j)|0;c[42018]=j;f=c[c[42017]>>2]|0;k=j}if((m|0)==12)c[g>>2]=0;else if((m|0)==16){d=bb[c[c[(c[42012]|0)+8>>2]>>2]&31](c[42013]|0,(c[f+4>>2]|0)+l|0,g>>>0<8192?g:8192)|0;e=c[c[42017]>>2]|0;c[42022]=d;c[e+16>>2]=d;if(!d){m=17;break}else{b=0;break}}up(81693)}while(0);do if((m|0)==17)if(!l){wp(c[42007]|0);b=1;d=c[42022]|0;e=c[c[42017]>>2]|0;break}else{c[e+44>>2]=2;b=2;d=0;break}while(0);f=d+l|0;do if(f>>>0>(c[e+12>>2]|0)>>>0){m=vp(c[e+4>>2]|0,f+(d>>>1)|0)|0;d=c[42017]|0;c[(c[d>>2]|0)+4>>2]=m;d=c[(c[d>>2]|0)+4>>2]|0;if(!d)up(81737);else{n=c[42022]|0;o=d;break}}else{n=d;o=c[e+4>>2]|0}while(0);n=n+l|0;c[42022]=n;a[o+n>>0]=0;o=c[42017]|0;a[(c[(c[o>>2]|0)+4>>2]|0)+((c[42022]|0)+1)>>0]=0;c[42009]=c[(c[o>>2]|0)+4>>2]}return b|0}function up(a){a=a|0;var b=0,d=0;b=l;l=l+16|0;d=c[13918]|0;c[b>>2]=a;zL(d,81633,b)|0;Ma(2)}function vp(a,b){a=a|0;b=b|0;return aJ(a,b)|0}function wp(a){a=a|0;var b=0,d=0,e=0;d=c[42017]|0;if((d|0)!=0?(b=c[d>>2]|0,(b|0)!=0):0)e=4;else{ip();b=jp(c[42007]|0,16384)|0;d=c[42017]|0;c[d>>2]=b;if(!d)b=0;else e=4}xp(b,a);kp();return}function xp(a,b){a=a|0;b=b|0;var d=0;d=c[(jJ()|0)>>2]|0;yp(a);c[a>>2]=b;c[a+40>>2]=1;b=c[42017]|0;if(!b)b=0;else b=c[b>>2]|0;if((b|0)!=(a|0)){c[a+32>>2]=1;c[a+36>>2]=0}c[a+24>>2]=0;c[(jJ()|0)>>2]=d;return}function yp(b){b=b|0;var d=0;if(b|0){c[b+16>>2]=0;d=b+4|0;a[c[d>>2]>>0]=0;a[(c[d>>2]|0)+1>>0]=0;c[b+8>>2]=c[d>>2];c[b+28>>2]=1;c[b+44>>2]=0;d=c[42017]|0;if(!d)d=0;else d=c[d>>2]|0;if((d|0)==(b|0))kp()}return}function zp(){var b=0,d=0;d=c[42009]|0;b=(c[42010]|0)+-2|0;while(1){if((b|0)<=-1){b=0;break}if((a[d+b>>0]|0)==46){b=1;break}else b=b+-1|0}return b|0}function Ap(a,b){a=a|0;b=b|0;var d=0;d=c[42026]|0;if((d|0)<(b|0)){if(!d)d=ZI(b+1|0)|0;else d=aJ(c[42027]|0,b+1|0)|0;c[42027]=d;c[42026]=b}else d=c[42027]|0;xK(d,a)|0;c[42011]=c[42027];return}function Bp(a){a=a|0;return ZI(a)|0}function Cp(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0;m=l;l=l+2112|0;k=m+32|0;i=m+24|0;h=m+16|0;g=m+8|0;f=m;d=m+56|0;j=m+40|0;cm(j,1024,m+1080|0);e=c[42011]|0;if(e|0){fm(j,e)|0;fm(j,81990)|0}fm(j,b)|0;c[f>>2]=c[4489];pL(d,81993,f)|0;fm(j,d)|0;a:do if(!(a[c[42009]>>0]|0))switch(((c[42016]|0)+-1|0)/2|0|0){case 2:{c[g>>2]=16384;pL(d,82013,g)|0;fm(j,d)|0;b=c[42023]|0;if(!(a[b>>0]|0))break a;i=rJ(b)|0;fm(j,82075)|0;b=c[42023]|0;if((i|0)>80)a[b+80>>0]=0;fm(j,b)|0;break a}case 3:{c[h>>2]=16384;pL(d,82094,h)|0;fm(j,d)|0;b=c[42023]|0;if(!(a[b>>0]|0))break a;i=rJ(b)|0;fm(j,82162)|0;b=c[42023]|0;if((i|0)>80)a[b+80>>0]=0;fm(j,b)|0;break a}case 1:{c[i>>2]=16384;pL(d,82181,i)|0;fm(j,d)|0;break a}default:break a}else{fm(j,82005)|0;fm(j,c[42009]|0)|0;d=j+4|0;b=c[d>>2]|0;if(b>>>0>=(c[j+8>>2]|0)>>>0){dm(j,1)|0;b=c[d>>2]|0}c[d>>2]=b+1;a[b>>0]=39}while(0);e=j+4|0;b=c[e>>2]|0;d=j+8|0;if(b>>>0>=(c[d>>2]|0)>>>0){dm(j,1)|0;b=c[e>>2]|0}c[e>>2]=b+1;a[b>>0]=10;b=c[e>>2]|0;if(b>>>0>=(c[d>>2]|0)>>>0){dm(j,1)|0;b=c[e>>2]|0}a[b>>0]=0;i=c[j>>2]|0;c[e>>2]=i;c[k>>2]=i;_l(1,81876,k)|0;gm(j);l=m;return}function Dp(){Ep(c[42009]|0);return}function Ep(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;j=c[42018]|0;a[j>>0]=a[173927]|0;i=c[42017]|0;e=c[i>>2]|0;d=c[e+4>>2]|0;if(j>>>0<(d+2|0)>>>0){f=d+((c[42022]|0)+2)|0;g=d+((c[e+12>>2]|0)+2)|0;k=d;h=e;while(1){if(f>>>0<=k>>>0)break;e=f+-1|0;k=g+-1|0;a[k>>0]=a[e>>0]|0;h=c[i>>2]|0;f=e;g=k;k=c[h+4>>2]|0}e=g-f|0;d=j+e|0;j=c[h+12>>2]|0;c[42022]=j;c[h+16>>2]=j;if(d>>>0<(k+2|0)>>>0)up(82240);else{l=b+e|0;m=d}}else{l=b;m=j}b=m+-1|0;a[b>>0]=64;c[42009]=l;a[173927]=a[b>>0]|0;c[42018]=b;return}function Fp(){var a=0;a=c[42017]|0;if(!a)a=0;else a=c[a>>2]|0;yp(a);return}function Gp(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;e=l;l=l+80|0;f=e;g=a+52|0;Sp(a,c[g>>2]|0,17604);a=f+8|0;c[a>>2]=b;c[a+4>>2]=d;d=c[g>>2]|0;d=bb[c[d>>2]&31](d,f,4)|0;l=e;return d|0}function Hp(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;f=Gp(b,d,e)|0;if(!f){f=Yn(b,72)|0;c[f+64>>2]=c[b+64>>2];g=f+24|0;h=c[b+24>>2]|0;c[g>>2]=h;a[g>>0]=h&255&-9;c[f+56>>2]=b;c[f+60>>2]=c[b+60>>2];b=f+8|0;c[b>>2]=d;c[b+4>>2]=e;jn(f)|0}return f|0}function Ip(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;g=l;l=l+16|0;f=g;if(!(((b|0)!=0?(An(a,0,b,f,0)|0)!=0:0)?(e=f,e=Gp(a,c[e>>2]|0,c[e+4>>2]|0)|0,(e|0)!=0):0))if((d|0)!=0?(An(a,0,b,f,1)|0)!=0:0){e=f;e=Hp(a,c[e>>2]|0,c[e+4>>2]|0)|0;En(a,0,e)}else e=0;l=g;return e|0}function Jp(a){a=a|0;a=c[a+52>>2]|0;return bb[c[a>>2]&31](a,0,128)|0}function Kp(a){a=a|0;var b=0;b=Lp(a)|0;if(!b)a=0;else{b=c[b+52>>2]|0;a=bb[c[b>>2]&31](b,a,8)|0}return a|0}function Lp(a){a=a|0;return c[a+56>>2]|0}function Mp(a,b){a=a|0;b=b|0;a=c[a+52>>2]|0;return bb[c[a>>2]&31](a,b,2)|0}function Np(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;a=c[42029]|0;e=(b|0)!=0;do if(!a)if(e){_I(b);a=0;break}else{a=ZI(d)|0;break}else if(e){Zn(a,b);a=0;break}else{a=Yn(a,d)|0;break}while(0);return a|0}function Op(a,b,d){a=a|0;b=b|0;d=d|0;a=c[42029]|0;if(!a)_I(b);else Zn(a,b);return}function Pp(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=b+28|0;f=c[e>>2]|0;c[e>>2]=2;c[42029]=a;d=Ql(b,d)|0;c[e>>2]=f;c[42029]=0;return d|0}function Qp(a,b,d){a=a|0;b=b|0;d=d|0;c[42029]=a;return bb[c[b>>2]&31](b,d,2)|0}function Rp(a,b){a=a|0;b=b|0;var d=0,e=0;d=(Ll(b,0,0)|0)+28|0;e=c[d>>2]|0;c[d>>2]=2;c[42029]=a;if(!(Kl(b)|0)){c[d>>2]=e;c[42029]=0;a=0}else a=1;return a|0}function Sp(a,b,c){a=a|0;b=b|0;c=c|0;if(c|0?(Ll(b,0,0)|0)!=(c|0):0)Ll(b,c,0)|0;return}function Tp(a,b){a=a|0;b=b|0;if(!(cp(a)|0))b=Vp(a,b)|0;else Up(a,b)|0;return b|0}function Up(b,c){b=b|0;c=c|0;var d=0,e=0,f=0;a[c>>0]=60;e=c;while(1){d=e+1|0;f=a[b>>0]|0;if(!(f<<24>>24))break;a[d>>0]=f;b=b+1|0;e=d}a[d>>0]=62;a[e+2>>0]=0;return c|0}function Vp(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;a:do if((b|0)!=0?(a[b>>0]|0)!=0:0){a[d>>0]=34;l=a[b>>0]|0;q=0;g=((l+-45&255)<2|((l&255)+-48|0)>>>0<10)&1;h=0;i=0;j=0;e=d+1|0;f=b+1|0;b:while(1){k=e;while(1){if(!(l<<24>>24))break b;e=l&255;c:do if(l<<24>>24==34){a[k>>0]=92;m=g;n=1;k=k+1|0}else{if(!g){n=l<<24>>24>-1&(l<<24>>24!=95&(gK(e)|0)==0);m=0;n=n?1:h;break}switch(l<<24>>24){case 45:{n=(j|0)==0;m=n?g:0;n=n?h:1;break c}case 46:{n=(i|0)==0;m=n?g:0;n=n?h:1;i=i+1|0;break c}default:{n=(e+-48|0)>>>0<10;m=n?g:0;n=n?h:1;break c}}}while(0);e=k+1|0;a[k>>0]=l;p=f+1|0;o=a[f>>0]|0;j=j+1|0;f=c[4795]|0;if(!f){g=m;h=n;k=e;f=p;l=o;continue}g=o&255;h=o<<24>>24!=0;if((q&h?!(l<<24>>24==92|l<<24>>24>-1&((l+-45&255)>1&(gK(l<<24>>24)|0)==0)^1):0)?!(o<<24>>24>-1&((o+-45&255)>1&(gK(g)|0)==0)):0)break;if((j|0)<(f|0)|h^1){g=m;h=n;k=e;f=p;l=o;continue}if(l<<24>>24==92|l<<24>>24>-1&((gK(l<<24>>24)|0)==0&(l+-45&255)>1)^1){q=1;g=m;h=n;l=o;f=p;continue b}if(o<<24>>24>-1&((o+-45&255)>1&(gK(g)|0)==0)){q=1;g=m;h=n;l=o;f=p;continue b}a[e>>0]=92;a[k+2>>0]=10;g=m;h=1;j=0;k=k+3|0;f=p;l=o}a[e>>0]=92;a[k+2>>0]=10;q=0;g=m;h=1;j=0;l=o;e=k+3|0;f=p}a[k>>0]=34;a[k+1>>0]=0;if(!h){if((j|0)==1?((a[b>>0]|0)+-45&255)<2:0){b=d;break}else e=19184;while(1){f=c[e>>2]|0;if(!f)break a;if(!(iK(f,b)|0)){b=d;break}else e=e+4|0}}else b=d}else b=82272;while(0);return b|0}function Wp(a){a=a|0;return Tp(a,Xp(a)|0)|0}function Xp(a){a=a|0;var b=0;b=((rJ(a)|0)<<1)+2|0;b=b>>>0>1024?b:1024;a=c[42031]|0;if(b>>>0>(c[42030]|0)>>>0){if(!a)a=ZI(b)|0;else a=aJ(a,b)|0;c[42031]=a;c[42030]=b}return a|0}function Yp(a,b){a=a|0;b=b|0;a=Jp(a)|0;while(1){if(!a){a=0;break}if((Zp(a)|0)==0?io(a,b,0)|0:0){a=1;break}a=Kp(a)|0}return a|0}function Zp(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;h=Dn(b)|0;if((h|0)!=0?(a[h>>0]|0)!=37:0)d=0;else e=3;a:do if((e|0)==3){d=om(b)|0;b:do if(d|0?(f=om(Lp(b)|0)|0,f|0):0){h=Sl(c[(om(so(b)|0)|0)+8>>2]|0)|0;g=d+12|0;e=f+12|0;d=0;while(1){if((d|0)>=(h|0))break b;f=c[(c[g>>2]|0)+(d<<2)>>2]|0;if((f|0?(i=c[(c[e>>2]|0)+(d<<2)>>2]|0,i|0):0)?xJ(f,i)|0:0){d=0;break a}d=d+1|0}}while(0);d=jm(b,0)|0;if(d)if((Sl(c[d+8>>2]|0)|0)>0)d=0;else return (Sl(c[d+12>>2]|0)|0)<1|0;else d=1}while(0);return d|0}function _p(b,d){b=b|0;d=d|0;var e=0,f=0;c[42032]=0;e=Im(b,82282)|0;if((e|0?((a[e>>0]|0)+-48|0)>>>0<10:0)?(f=BL(e,0,10)|0,(f|0)==0|(f|0)>59):0)c[4795]=f;$p(b,1);if(((aq(b,d,1)|0)!=-1?(bq(b,d)|0)!=-1:0)?(cq(b,d)|0)!=-1:0){c[4795]=128;b=$a[c[(c[(c[b+64>>2]|0)+8>>2]|0)+8>>2]&31](d)|0}else b=-1;return b|0}function $p(a,b){a=a|0;b=b|0;var d=0;c[a>>2]=c[a>>2]&-9;d=Jp(a)|0;while(1){if(!d)break;$p(d,0);d=Kp(d)|0}a:do if(b|0){b=co(a)|0;while(1){if(!b)break a;c[b>>2]=c[b>>2]&-9;d=Pm(a,b)|0;while(1){if(!d)break;c[d>>2]=c[d>>2]&-9;d=Rm(a,d)|0}b=eo(a,b)|0}}while(0);return}function aq(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0;if((e|0)==0?(Lp(b)|0)!=0:0){i=0;g=174181;k=94336}else{k=(a[b+24>>0]&1)==0?174181:82326;g=(sn(b)|0)==0;c[42033]=ym(b,2,96242,0)|0;c[42034]=ym(b,2,96251,0)|0;i=1;g=g?174181:82329}f=Dn(b)|0;if((f|0)!=0?(a[f>>0]|0)!=37:0){h=1;j=87638}else{h=0;j=174181;f=174181}do if((dq(b,d)|0)!=-1?(eq(b,d,g)|0)!=-1:0){g=(h|0)==0;if(h|i|0){if((eq(b,d,k)|0)==-1){f=-1;break}if((eq(b,d,87631)|0)==-1){f=-1;break}}if(!g?(pq(b,d,f)|0)==-1:0){f=-1;break}if(((eq(b,d,j)|0)!=-1?(eq(b,d,82337)|0)!=-1:0)?(c[42032]=(c[42032]|0)+1,(uq(b,d,e)|0)!=-1):0){c[b>>2]=c[b>>2]|8;f=0}else f=-1}else f=-1;while(0);return f|0}function bq(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;a:do if((fq(a,b)|0)==-1)d=-1;else{k=jm(so(a)|0,0)|0;i=(k|0)==0;j=k+12|0;k=k+8|0;h=co(a)|0;while(1){if(!h){d=0;break a}if(gq(a,h,(c[h>>2]|0)>>>4,0)|0){if(i)d=0;else d=c[k>>2]|0;if((hq(h,b,d)|0)==-1){d=-1;break a}}g=Pm(a,h)|0;d=h;while(1){if(!g)break;f=g+-48|0;e=c[((c[g>>2]&3|0)==2?g:f)+40>>2]|0;if((d|0)!=(e|0)?(gq(a,e,(c[h>>2]|0)>>>4,0)|0)!=0:0){if(i)d=0;else d=c[k>>2]|0;if((hq(c[((c[g>>2]&3|0)==2?g:f)+40>>2]|0,b,d)|0)==-1){d=-1;break a}d=c[((c[g>>2]&3|0)==2?g:f)+40>>2]|0}if(iq(a,g)|0){if(i)e=0;else e=c[j>>2]|0;if((jq(g,b,e)|0)==-1){d=-1;break a}}g=Rm(a,g)|0}h=eo(a,h)|0}}while(0);return d|0}function cq(a,b){a=a|0;b=b|0;c[42032]=(c[42032]|0)+-1;if((dq(a,b)|0)==-1)a=-1;else a=((eq(a,b,95830)|0)==-1)<<31>>31;return a|0}function dq(a,b){a=a|0;b=b|0;var d=0;d=c[42032]|0;while(1){if((d|0)<=0){d=0;break}if((eq(a,b,134899)|0)==-1){d=-1;break}else d=d+-1|0}return d|0}function eq(a,b,d){a=a|0;b=b|0;d=d|0;return ab[c[(c[(c[a+64>>2]|0)+8>>2]|0)+4>>2]&63](b,d)|0}function fq(a,b){a=a|0;b=b|0;a=Jp(a)|0;while(1){if(!a){a=0;break}if(!(Zp(a)|0)){if((aq(a,b,0)|0)==-1){a=-1;break}if((bq(a,b)|0)==-1){a=-1;break}if((cq(a,b)|0)==-1){a=-1;break}}else fq(a,b)|0;a=Kp(a)|0}return a|0}function gq(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;if((Yp(a,b)|0)==0?(rq(a,b,c,d)|0)!=0:0)if((sq(a,b)|0)==0?(tq(b)|0)==0:0)e=5;else a=1;else e=5;if((e|0)==5)a=0;return a|0}function hq(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=ro(a)|0;do if((dq(d,b)|0)!=-1?(kq(a,b)|0)!=-1:0){if((mq(a)|0)==0?(nq(a,b,c)|0)==-1:0){a=-1;break}a=eq(d,b,82293)|0}else a=-1;while(0);return a|0}function iq(a,b){a=a|0;b=b|0;a=Jp(a)|0;while(1){if(!a){a=1;break}if((Zp(a)|0)==0?en(a,b,0)|0:0){a=0;break}a=Kp(a)|0}return a|0}function jq(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;e=c[a>>2]&3;g=c[((e|0)==3?a:a+48|0)+40>>2]|0;e=c[((e|0)==2?a:a+-48|0)+40>>2]|0;f=ro(g)|0;do if((((((dq(f,b)|0)!=-1?(kq(g,b)|0)!=-1:0)?(lq(a,b,c[42033]|0)|0)!=-1:0)?(g=(qn(ro(g)|0)|0)!=0,(eq(f,b,g?85095:85100)|0)!=-1):0)?(kq(e,b)|0)!=-1:0)?(lq(a,b,c[42034]|0)|0)!=-1:0){if(!(mq(a)|0)){if((nq(a,b,d)|0)==-1){a=-1;break}}else if((oq(a,b,1)|0)==-1){a=-1;break}a=eq(f,b,82293)|0}else a=-1;while(0);return a|0}function kq(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0;i=l;l=l+32|0;g=i;d=i+8|0;e=Dn(a)|0;f=ro(a)|0;if(!e){j=a+8|0;a=c[j+4>>2]|0;e=g;c[e>>2]=c[j>>2];c[e+4>>2]=a;pL(d,82313,g)|0;if((eq(f,b,d)|0)==-1)a=-1;else h=4}else if((pq(f,b,e)|0)==-1)a=-1;else h=4;if((h|0)==4)a=0;l=i;return a|0}function lq(b,c,d){b=b|0;c=c|0;d=d|0;var e=0,f=0;a:do if((d|0)!=0?(e=ro(b)|0,f=Jm(b,d)|0,(a[f>>0]|0)!=0):0)if((eq(e,c,93017)|0)==-1)b=-1;else{do if(cp(f)|0){if((pq(e,c,f)|0)==-1){b=-1;break a}}else{b=WJ(f,58)|0;if(!b)if((qq(e,c,f,0)|0)==-1){b=-1;break a}else break;a[b>>0]=0;if((qq(e,c,f,0)|0)==-1){b=-1;break a}if((eq(e,c,93017)|0)==-1){b=-1;break a}if((qq(e,c,b+1|0,0)|0)==-1){b=-1;break a}a[b>>0]=58}while(0);b=0}else b=0;while(0);return b|0}function mq(a){a=a|0;return (c[a>>2]|0)>>>3&1|0}function nq(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0;a:do if(!(c[a>>2]&2)){e=0;k=4}else{switch(oq(a,b,0)|0){case -1:{e=-1;break a}case 0:{e=0;k=4;break a}default:{}}e=1;k=4}while(0);b:do if((k|0)==4){f=om(a)|0;j=ro(a)|0;c:do if(f){i=f+12|0;h=bb[c[d>>2]&31](d,0,128)|0;while(1){if(!h)break c;do if(c[a>>2]&2){g=c[42033]|0;if(g|0?(c[h+16>>2]|0)==(c[g+16>>2]|0):0)break;g=c[42034]|0;if(!((g|0)!=0?(c[h+16>>2]|0)==(c[g+16>>2]|0):0))k=12}else k=12;while(0);if((k|0)==12){k=0;f=h+16|0;if((c[(c[i>>2]|0)+(c[f>>2]<<2)>>2]|0)!=(c[h+12>>2]|0)){g=e+1|0;if(e){if((eq(j,b,82308)|0)==-1){e=-1;break b}if((dq(j,b)|0)==-1){e=-1;break b}}else{if((dq(j,b)|0)==-1){e=-1;break b}if((eq(j,b,82305)|0)==-1){e=-1;break b}c[42032]=(c[42032]|0)+1}if((pq(j,b,c[h+8>>2]|0)|0)==-1){e=-1;break b}if((eq(j,b,82311)|0)==-1){e=-1;break b}if((pq(j,b,c[(c[i>>2]|0)+(c[f>>2]<<2)>>2]|0)|0)==-1){e=-1;break b}else e=g}}h=bb[c[d>>2]&31](d,h,8)|0}}while(0);if((e|0)>0){if((eq(j,b,82303)|0)==-1){e=-1;break}c[42032]=(c[42032]|0)+-1}c[a>>2]=c[a>>2]|8;e=0}while(0);return e|0}function oq(b,c,d){b=b|0;c=c|0;d=d|0;var e=0,f=0;e=Dn(b)|0;b=ro(b)|0;if((e|0)!=0?(a[e>>0]|0)!=0:0)if((eq(b,c,82296)|0)!=-1?(pq(b,c,e)|0)!=-1:0)if((d|0)!=0?(eq(b,c,82303)|0)==-1:0)b=-1;else{b=1;f=7}else b=-1;else{b=0;f=7}return b|0}function pq(a,b,c){a=a|0;b=b|0;c=c|0;return qq(a,b,c,1)|0}function qq(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;if(!d)c=Vp(c,Xp(c)|0)|0;else c=Wp(c)|0;return eq(a,b,c)|0}function rq(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;a:do if(0>>0|(0==(e|0)?(c[b>>2]|0)>>>4>>>0>>0:0))b=0;else{b=Sm(a,b)|0;while(1){if(!b){b=1;break a}if(0>>0|(0==(e|0)?(c[c[b+40>>2]>>2]|0)>>>4>>>0>>0:0)){b=0;break a}b=Tm(a,b)|0}}while(0);return b|0}function sq(a,b){a=a|0;b=b|0;if(!(Sm(a,b)|0))a=(Pm(a,b)|0)==0&1;else a=0;return a|0}function tq(a){a=a|0;var b=0,d=0,e=0;a=om(a)|0;a:do if(!a)a=0;else{d=a+8|0;e=c[d>>2]|0;b=a+12|0;a=bb[c[e>>2]&31](e,0,128)|0;while(1){if(!a){a=0;break a}if((c[(c[b>>2]|0)+(c[a+16>>2]<<2)>>2]|0)!=(c[a+12>>2]|0)){a=1;break a}e=c[d>>2]|0;a=bb[c[e>>2]&31](e,a,8)|0}}while(0);return a|0}function uq(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=jm(a,0)|0;if(e)if(((vq(a,b,96286,c[e+16>>2]|0,d)|0)!=-1?(vq(a,b,96273,c[e+8>>2]|0,d)|0)!=-1:0)?(vq(a,b,96237,c[e+12>>2]|0,d)|0)!=-1:0)f=5;else a=-1;else f=5;if((f|0)==5)a=0;return a|0}function vq(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;m=(g|0)!=0;if(m)l=0;else l=Wl(f,0)|0;k=(l|0)==0;j=bb[c[f>>2]&31](f,0,128)|0;g=0;while(1){if(!j){n=23;break}i=j+12|0;n=c[i>>2]|0;if((n|0)!=0?(a[n>>0]|0)!=0:0)n=12;else n=7;do if((n|0)==7){n=0;if(!(a[j+22>>0]|0)){if(!k){h=bb[c[l>>2]&31](l,j,4)|0;o=c[h+12>>2]|0;if(o|0?a[o>>0]|0:0){n=12;break}if(!(a[h+22>>0]|0))n=12}}else n=12}while(0);if((n|0)==12){n=0;h=g+1|0;if(g){if((eq(b,d,82308)|0)==-1){g=-1;break}if((dq(b,d)|0)==-1){g=-1;break}}else{if((dq(b,d)|0)==-1){g=-1;break}if((eq(b,d,e)|0)==-1){g=-1;break}if((eq(b,d,82305)|0)==-1){g=-1;break}c[42032]=(c[42032]|0)+1}if((pq(b,d,c[j+8>>2]|0)|0)==-1){g=-1;break}if((eq(b,d,82311)|0)==-1){g=-1;break}if((pq(b,d,c[i>>2]|0)|0)==-1){g=-1;break}else g=h}j=bb[c[f>>2]&31](f,j,8)|0}do if((n|0)==23){if((g|0)>0){c[42032]=(c[42032]|0)+-1;if((g|0)!=1){if((eq(b,d,134901)|0)==-1){g=-1;break}if((dq(b,d)|0)==-1){g=-1;break}}g=(eq(b,d,82340)|0)==-1;if(m|g){g=g<<31>>31;break}}else if(m){g=0;break}Wl(f,l)|0;g=0}while(0);return g|0}function wq(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0;switch(c[b>>2]&3){case 0:{g=19;break}case 1:{g=20;break}case 3:case 2:{g=21;break}default:{}}b=ab[g&63](a,b)|0;if(!b)b=-1;else{Aq(a,b,d,e,g,f);b=0}return b|0}function xq(a,b){a=a|0;b=b|0;if((ro(b)|0)!=(a|0))b=en(a,b,0)|0;return b|0}function yq(a,b){a=a|0;b=b|0;if((ro(b)|0)!=(a|0))b=io(a,b,0)|0;return b|0}function zq(a,b){a=a|0;b=b|0;return a|0}function Aq(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0;h=(f|0)!=0;if(h)ib[c&127](a,b,d);g=Jp(a)|0;while(1){if(!g)break;i=ab[e&63](g,b)|0;if(i|0)Aq(g,i,c,d,e,f);g=Kp(g)|0}if(!h)ib[c&127](a,b,d);return}function Bq(){var e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;t=l;l=l+1200|0;r=t+800|0;g=t;c[42035]=0;c[42036]=-2;f=r;i=200;n=g;p=0;q=0;o=r;a:while(1){b[o>>1]=p;if((f+(i<<1)+-2|0)>>>0>o>>>0)k=i;else{m=o-f>>1;e=m+1|0;if(i>>>0>9999){s=75;break}k=i<<1;k=k>>>0<1e4?k:1e4;h=ZI(k*6|3)|0;if(h){TN(h|0,f|0,e<<1|0)|0;i=h+(k>>>1<<2)|0;TN(i|0,n|0,e<<2|0)|0;if((f|0)==(r|0)){e=0;f=h}else{_I(f);e=0;f=h}}else{e=4;i=n}j=(e|0)==0;h=f+(m<<1)|0;switch((j?((f+(k<<1)+-2|0)>>>0>h>>>0?0:9):e)&15){case 9:{e=1;s=76;break a}case 4:{s=75;break a}case 0:{g=j?i+(m<<2)|0:g;n=i;o=j?h:o;break}default:{e=0;break a}}}if((p|0)==6){e=0;s=76;break}e=a[82344+p>>0]|0;j=e<<24>>24;do if(e<<24>>24!=-18){h=c[42036]|0;if((h|0)==-2){h=hp()|0;c[42036]=h}if((h|0)>=1)if(h>>>0<269)i=d[82424+h>>0]|0;else i=2;else{c[42036]=0;i=0}h=i+j|0;if(h>>>0<=59?(i|0)==(d[82693+h>>0]|0):0){p=a[82753+h>>0]|0;e=p<<24>>24;if(p<<24>>24<1){h=0-e|0;s=23;break}else{c[42036]=-2;g=g+4|0;c[g>>2]=c[42037];j=(q|0)==0?0:q+-1|0;h=o;break}}else s=22}else s=22;while(0);if((s|0)==22){s=0;p=a[82813+p>>0]|0;h=p&255;if(!(p<<24>>24)){h=c[42036]|0;b:do switch(q|0){case 0:{c[42035]=(c[42035]|0)+1;Cp(125369);h=o;break}case 3:if((h|0)<1)if(!h){e=1;s=76;break a}else{h=o;break b}else{c[42036]=-2;h=o;break b}default:h=o}while(0);while(1){if(e<<24>>24==18)break;if((h|0)==(f|0)){e=1;s=76;break a}e=h+-2|0;g=g+-4|0;h=e;e=a[82344+(b[e>>1]|0)>>0]|0}g=g+4|0;c[g>>2]=c[42037];e=1;j=3}else s=23}do if((s|0)==23){s=0;i=d[82893+h>>0]|0;e=c[g+(1-i<<2)>>2]|0;c:do switch(h|0){case 2:{Cq();Dq();break}case 3:{if(c[42038]|0){Cq();Dq();ln(c[42038]|0)|0;c[41987]=0;c[42038]=0}break}case 6:{Eq(c[g>>2]|0,c[g+-4>>2]|0,c[g+-8>>2]|0);break}case 7:{e=c[g>>2]|0;break}case 8:{e=0;break}case 9:{e=1;break}case 10:{e=0;break}case 11:{e=0;break}case 12:{e=1;break}case 21:if(!(c[g+-4>>2]|0)){Gq();break c}else{Fq();break c}case 24:{Hq();break}case 25:{Hq();break}case 26:{e=1;break}case 27:{e=0;break}case 30:{Iq(c[g>>2]|0,0,0);break}case 31:{Iq(c[g+-8>>2]|0,c[g>>2]|0,0);break}case 32:{Iq(c[g+-16>>2]|0,c[g+-8>>2]|0,c[g>>2]|0);break}case 33:{Jq(c[g+-8>>2]|0,c[g+-4>>2]|0);break}case 34:{Jq(258,0);break}case 35:{e=258;break}case 36:{e=259;break}case 37:{e=260;break}case 38:{e=c[g+-4>>2]|0;break}case 39:{e=0;break}case 48:{Kq(c[g+-8>>2]|0,c[g>>2]|0);break}case 49:{Kq(c[g>>2]|0,0);break}case 51:{Lq(c[g>>2]|0);break}case 52:{Mq();break}case 53:{e=c[g>>2]|0;break}case 54:{e=0;break}case 55:{e=0;break}case 59:{e=c[g>>2]|0;break}case 60:{e=c[g>>2]|0;break}case 61:{e=c[g>>2]|0;break}case 62:{e=Nq(c[g+-8>>2]|0,c[g>>2]|0)|0;break}default:{}}while(0);i=0-i|0;p=g+(i<<2)|0;i=o+(i<<1)|0;g=p+4|0;c[p+4>>2]=e;e=(d[82956+h>>0]|0)+-24|0;p=b[i>>1]|0;h=p+(a[83019+e>>0]|0)|0;if(h>>>0<60?(d[82693+h>>0]|0)==(p|0):0){e=a[82753+h>>0]|0;j=q;h=i;break}e=a[83054+e>>0]|0;j=q;h=i}while(0);i=k;p=e;q=j;o=h+2|0}if((s|0)==75){Cp(125382);e=2;s=76}if((s|0)==76)if((f|0)!=(r|0))_I(f);l=t;return e|0}function Cq(){var a=0,b=0;a=c[42039]|0;while(1){if(!a)break;Vq(a+8|0);Vq((c[42039]|0)+24|0);Vq((c[42039]|0)+16|0);b=Oq(c[42039]|0)|0;c[42039]=b;a=b}return}function Dq(){Dp();Mn(c[42038]|0);return}function Eq(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;h=l;l=l+16|0;g=h;f=c[42038]|0;if(!f){a[168160]=d&1|(e&255)<<1&2|a[168160]&-12|8;f=c[42041]|0;a[g>>0]=a[168160]|0;a[g+1>>0]=a[168161]|0;a[g+2>>0]=a[168162]|0;a[g+3>>0]=a[168163]|0;f=gn(b,g,f)|0;c[42038]=f}c[41987]=f;c[42039]=Pq(c[42039]|0,f)|0;bp(0,b)|0;l=h;return}function Fq(){var b=0,d=0,e=0,f=0,g=0,h=0;Uq(2);e=c[42039]|0;f=a[83089]|0;h=0;b=e+24|0;while(1){d=c[b>>2]|0;if(!d)break;if(((c[d>>2]|0)==267?(g=c[d+4>>2]|0,(a[g>>0]|0)==f<<24>>24):0)?(xJ(g,83089)|0)==0:0)b=c[d+8>>2]|0;else b=h;h=b;b=d+12|0}b=e+16|0;a:while(1){e=c[b>>2]|0;b=e+12|0;if(!(c[b>>2]|0))break;d=e+4|0;if((c[e>>2]|0)==262){e=c[d>>2]|0;d=co(e)|0;while(1){if(!d)continue a;g=io(c[c[42039]>>2]|0,d,0)|0;ar(g,0,c[b>>2]|0,h);d=eo(e,d)|0}}else while(1){d=c[d>>2]|0;if(!d)continue a;ar(c[d+4>>2]|0,c[d+8>>2]|0,c[b>>2]|0,h);d=d+12|0}}Vq((c[42039]|0)+8|0);Vq((c[42039]|0)+16|0);Vq((c[42039]|0)+24|0);c[(c[42039]|0)+4>>2]=0;return}function Gq(){var a=0;Uq(1);a=(c[42039]|0)+8|0;while(1){a=c[a>>2]|0;if(!a)break;$q(c[a+4>>2]|0);a=a+12|0}Vq((c[42039]|0)+8|0);Vq((c[42039]|0)+24|0);Vq((c[42039]|0)+16|0);c[(c[42039]|0)+4>>2]=0;return}function Hq(){var a=0,b=0;a=c[42039]|0;b=c[a+8>>2]|0;if(!b){b=c[a+4>>2]|0;if(!b)b=0;else{b=_q(b)|0;a=c[42039]|0}c[a+4>>2]=0}else{b=Zq(b)|0;a=c[42039]|0;c[a+12>>2]=0;c[a+8>>2]=0}if(b|0)Rq(a+16|0,b);return}function Iq(a,b,d){a=a|0;b=b|0;d=d|0;if(d)b=Xq(b,d)|0;d=Yq(no(c[c[42039]>>2]|0,a,1)|0,b)|0;Rq((c[42039]|0)+8|0,d);bp(c[42038]|0,a)|0;return}function Jq(b,d){b=b|0;d=d|0;var e=0,f=0,g=0;if(d|0)Tq();d=(c[42039]|0)+24|0;while(1){d=c[d>>2]|0;if(!d)break;if(!(c[d+8>>2]|0))Tq();d=d+12|0}g=(b|0)==260?2:(b|0)==259&1;Uq(g);b=c[42039]|0;d=b+24|0;while(1){f=c[d>>2]|0;if(!f)break;do if((c[f>>2]|0)!=267){d=c[f+4>>2]|0;e=c[b>>2]|0;if(!((a[d+21>>0]|0)!=0&(e|0)==(c[42038]|0))){d=ym(e,g,c[d+8>>2]|0,c[f+8>>2]|0)|0;b=c[42039]|0;if((c[b>>2]|0)!=(c[42038]|0))break}a[d+22>>0]=1}while(0);d=f+12|0}Vq(b+24|0);return}function Kq(a,b){a=a|0;b=b|0;b=Qq(a,b)|0;Rq((c[42039]|0)+24|0,b);return}function Lq(a){a=a|0;var b=0;b=c[42039]|0;c[42039]=Pq(b,Ip(c[b>>2]|0,a,1)|0)|0;bp(c[42038]|0,a)|0;return}function Mq(){var a=0,b=0;a=c[42039]|0;b=c[a>>2]|0;a=Oq(a)|0;c[42039]=a;c[a+4>>2]=b;return}function Nq(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;g=l;l=l+1024|0;f=g;d=rJ(a)|0;d=d+1+(rJ(b)|0)|0;if(d>>>0<1025)d=f;else d=ZI(d)|0;xK(d,a)|0;IL(d,b)|0;e=$o(c[42038]|0,d)|0;bp(c[42038]|0,a)|0;bp(c[42038]|0,b)|0;if((d|0)!=(f|0))_I(d);l=g;return e|0}function Oq(a){a=a|0;var b=0;b=c[(c[42039]|0)+32>>2]|0;Zn(c[42038]|0,a);return b|0}function Pq(a,b){a=a|0;b=b|0;var d=0;d=Yn(c[42038]|0,36)|0;c[d+32>>2]=a;c[d>>2]=b;return d|0}function Qq(a,b){a=a|0;b=b|0;return Sq(267,a,b)|0}function Rq(a,b){a=a|0;b=b|0;var d=0,e=0;d=a+4|0;e=c[d>>2]|0;if(e|0)c[e+12>>2]=b;c[d>>2]=b;if(!(c[a>>2]|0))c[a>>2]=b;return}function Sq(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=Yn(c[42038]|0,16)|0;c[e>>2]=a;c[e+4>>2]=b;c[e+8>>2]=d;return e|0}function Tq(){var a=0;a=l;l=l+16|0;_l(0,83093,a)|0;l=a;return} +function DI(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,i=0.0,j=0,k=0,m=0,n=0,q=0,r=0,s=0,u=0,v=0,w=0,x=0,y=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0.0;H=l;l=l+112|0;E=H+80|0;D=H+64|0;C=H+48|0;G=4;F=ZI(40)|0;c[F>>2]=0;w=H+32|0;x=H+16|0;y=H;A=H+96|0;G=RN(169980,1,F|0,G|0)|0;F=z;o=0;e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,G|0,F|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1)e=z;else e=0;a:while(1){if(e|0){e=-2;break}g=a+4|0;o=0;fa(94,c[g>>2]|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,G|0,F|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){e=z;continue}c[42534]=0;c[42535]=0;o=0;fa(95,c[g>>2]<<1|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,G|0,F|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){e=z;continue}m=(c[42537]|0)/2|0;c[42538]=m;c[42539]=m+-1;m=c[g>>2]|0;g=c[a>>2]|0;e=0;f=-1;i=t;while(1){if((e|0)>=(m|0))break;I=+h[g+(e<<4)>>3];v=i>I;u=v?e:f;e=e+1|0;f=u;i=v?I:i}v=g+(f<<4)|0;c[x>>2]=c[v>>2];c[x+4>>2]=c[v+4>>2];c[x+8>>2]=c[v+8>>2];c[x+12>>2]=c[v+12>>2];v=g+(((f|0)==0?m:f)+-1<<4)|0;c[w>>2]=c[v>>2];c[w+4>>2]=c[v+4>>2];c[w+8>>2]=c[v+8>>2];c[w+12>>2]=c[v+12>>2];v=g+(((f|0)==(m+-1|0)?0:f+1|0)<<4)|0;c[y>>2]=c[v>>2];c[y+4>>2]=c[v+4>>2];c[y+8>>2]=c[v+8>>2];c[y+12>>2]=c[v+12>>2];I=+h[x>>3];if((+h[w>>3]==I?I==+h[y>>3]:0)?+h[y+8>>3]>+h[x+8>>3]:0)v=15;else v=12;b:do if((v|0)==12){v=0;o=0;e=aa(17,w|0,x|0,y|0)|0;f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,G|0,F|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)==1){e=z;continue a}if((e|0)==1){g=c[42541]|0;e=c[42542]|0;f=0;while(1){if((f|0)>=(m|0))break b;j=c[a>>2]|0;if(!(((f|0)>0?(B=f+-1|0,+h[j+(f<<4)>>3]==+h[j+(B<<4)>>3]):0)?+h[j+(f<<4)+8>>3]==+h[j+(B<<4)+8>>3]:0)){u=c[42534]|0;c[g+(u<<3)>>2]=j+(f<<4);c[g+(u<<3)+4>>2]=g+(((u|0)%(m|0)|0)<<3);c[e+(u<<2)>>2]=g+(u<<3);c[42534]=u+1}f=f+1|0}}else v=15}while(0);c:do if((v|0)==15){v=0;j=c[42541]|0;e=c[42542]|0;g=m;while(1){f=g+-1|0;if((g|0)<=0)break c;k=c[a>>2]|0;if(((g|0)<(m|0)?+h[k+(f<<4)>>3]==+h[k+(g<<4)>>3]:0)?+h[k+(f<<4)+8>>3]==+h[k+(g<<4)+8>>3]:0){g=f;continue}g=c[42534]|0;c[j+(g<<3)>>2]=k+(f<<4);c[j+(g<<3)+4>>2]=j+(((g|0)%(m|0)|0)<<3);c[e+(g<<2)>>2]=j+(g<<3);c[42534]=g+1;g=f}}while(0);o=0;ga(27,e|0,c[42534]|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,G|0,F|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){e=z;continue}j=0;e=c[42535]|0;d:while(1){if((j|0)>=(e|0)){s=0;break}k=j+1|0;g=k;while(1){if((g|0)>=(e|0)){j=k;continue d}o=0;ga(28,j|0,g|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,G|0,F|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){e=z;continue a}g=g+1|0;e=c[42535]|0}}while(1){if((s|0)>=(e|0))break;o=0;f=$(39,s|0,b|0)|0;g=o;o=0;if((g|0)!=0&(p|0)!=0){j=SN(c[g>>2]|0,G|0,F|0)|0;if(!j)Ua(g|0,p|0);z=p}else j=-1;if((j|0)==1){e=z;continue a}if(f|0)break;s=s+1|0}if((s|0)==(e|0)){e=c[13918]|0;o=0;c[C>>2]=125503;c[C+4>>2]=192;c[C+8>>2]=125514;aa(13,e|0,125484,C|0)|0;e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,G|0,F|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){e=z;continue}else{v=41;break}}u=b+16|0;k=0;while(1){if((k|0)>=(e|0))break;o=0;f=$(39,k|0,u|0)|0;g=o;o=0;if((g|0)!=0&(p|0)!=0){j=SN(c[g>>2]|0,G|0,F|0)|0;if(!j)Ua(g|0,p|0);z=p}else j=-1;if((j|0)==1){e=z;continue a}if(f|0)break;k=k+1|0}if((k|0)==(e|0)){e=c[13918]|0;o=0;c[D>>2]=125503;c[D+4>>2]=200;c[D+8>>2]=125547;aa(13,e|0,125484,D|0)|0;e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,G|0,F|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){e=z;continue}else{v=48;break}}o=0;e=$(40,s|0,k|0)|0;f=o;o=0;if((f|0)!=0&(p|0)!=0){g=SN(c[f>>2]|0,G|0,F|0)|0;if(!g)Ua(f|0,p|0);z=p}else g=-1;if((g|0)==1){e=z;continue}if(!e){e=c[13918]|0;o=0;c[E>>2]=125503;c[E+4>>2]=207;c[E+8>>2]=125585;aa(13,e|0,125484,E|0)|0;e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,G|0,F|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){e=z;continue}o=0;fa(96,2);e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,G|0,F|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){e=z;continue}else{v=53;break}}if((s|0)==(k|0)){o=0;fa(96,2);e=o;o=0;if((e|0)!=0&(p|0)!=0){f=SN(c[e>>2]|0,G|0,F|0)|0;if(!f)Ua(e|0,p|0);z=p}else f=-1;if((f|0)==1){e=z;continue}else{v=56;break}}c[A>>2]=b;c[A+4>>2]=0;f=A+8|0;c[f>>2]=u;c[A+12>>2]=0;o=0;ga(29,1,A|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){g=SN(c[e>>2]|0,G|0,F|0)|0;if(!g)Ua(e|0,p|0);z=p}else g=-1;if((g|0)==1){e=z;continue}c[42540]=c[42538];q=s;e:while(1){if((q|0)==-1){g=f;e=0;break}r=c[42544]|0;c[r+(q*52|0)>>2]=2;e=0;while(1){if((e|0)>=3){v=65;break}v=c[r+(q*52|0)+4+(e<<4)+12>>2]|0;if(v|0?(c[v>>2]|0)==1:0){v=68;break}e=e+1|0}if((v|0)==65){v=0;if((e|0)==3){e=c[42536]|0;k=c[e+(c[42539]<<2)>>2]|0;o=0;e=aa(17,u|0,c[c[e+(c[42538]<<2)>>2]>>2]|0,c[k>>2]|0)|0;g=o;o=0;if((g|0)!=0&(p|0)!=0){j=SN(c[g>>2]|0,G|0,F|0)|0;if(!j)Ua(g|0,p|0);z=p}else j=-1;if((j|0)==1){e=z;continue a}j=(e|0)==1;n=j?f:k;j=j?k:f}else v=68}if((v|0)==68){v=0;k=c[r+(q*52|0)+4+(e<<4)>>2]|0;m=c[r+(q*52|0)+4+(e<<4)+4>>2]|0;o=0;e=aa(17,c[k>>2]|0,c[c[r+(q*52|0)+4+(((e+1|0)%3|0)<<4)+4>>2]>>2]|0,c[m>>2]|0)|0;g=o;o=0;if((g|0)!=0&(p|0)!=0){j=SN(c[g>>2]|0,G|0,F|0)|0;if(!j)Ua(g|0,p|0);z=p}else j=-1;if((j|0)==1){e=z;continue a}j=(e|0)==1;n=j?k:m;j=j?m:k}do if((q|0)==(s|0)){o=0;ga(29,2,j|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){g=SN(c[e>>2]|0,G|0,F|0)|0;if(!g)Ua(e|0,p|0);z=p}else g=-1;if((g|0)==1){e=z;continue a}o=0;ga(29,1,n|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){g=SN(c[e>>2]|0,G|0,F|0)|0;if(!g)Ua(e|0,p|0);z=p}else g=-1;if((g|0)==1){e=z;continue a}e=0}else{m=c[42536]|0;if((c[m+(c[42538]<<2)>>2]|0)!=(n|0)?(c[m+(c[42539]<<2)>>2]|0)!=(n|0):0){o=0;j=_(29,n|0)|0;e=o;o=0;if((e|0)!=0&(p|0)!=0){g=SN(c[e>>2]|0,G|0,F|0)|0;if(!g)Ua(e|0,p|0);z=p}else g=-1;if((g|0)==1){e=z;continue a}o=0;ga(30,2,j|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){g=SN(c[e>>2]|0,G|0,F|0)|0;if(!g)Ua(e|0,p|0);z=p}else g=-1;if((g|0)==1){e=z;continue a}o=0;ga(29,1,n|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){g=SN(c[e>>2]|0,G|0,F|0)|0;if(!g)Ua(e|0,p|0);z=p}else g=-1;if((g|0)==1){e=z;continue a}if((j|0)<=(c[42540]|0)){e=0;break}c[42540]=j;e=0;break}o=0;k=_(29,j|0)|0;e=o;o=0;if((e|0)!=0&(p|0)!=0){g=SN(c[e>>2]|0,G|0,F|0)|0;if(!g)Ua(e|0,p|0);z=p}else g=-1;if((g|0)==1){e=z;continue a}o=0;ga(30,1,k|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){g=SN(c[e>>2]|0,G|0,F|0)|0;if(!g)Ua(e|0,p|0);z=p}else g=-1;if((g|0)==1){e=z;continue a}o=0;ga(29,2,j|0);e=o;o=0;if((e|0)!=0&(p|0)!=0){g=SN(c[e>>2]|0,G|0,F|0)|0;if(!g)Ua(e|0,p|0);z=p}else g=-1;if((g|0)==1){e=z;continue a}if((k|0)>=(c[42540]|0)){e=0;break}c[42540]=k;e=0}while(0);while(1){if((e|0)>=3){q=-1;continue e}g=c[r+(q*52|0)+4+(e<<4)+12>>2]|0;if(g|0?(c[g>>2]|0)==1:0)break;e=e+1|0}q=(g-(c[42544]|0)|0)/52|0}while(1){if(!g)break;g=c[g+4>>2]|0;e=e+1|0}o=0;fa(96,e|0);g=o;o=0;if((g|0)!=0&(p|0)!=0){j=SN(c[g>>2]|0,G|0,F|0)|0;if(!j)Ua(g|0,p|0);z=p}else j=-1;if((j|0)==1)e=z;else{v=94;break}}if((v|0)==41)e=-1;else if((v|0)==48)e=-1;else if((v|0)==53){c[d+4>>2]=2;e=c[42543]|0;c[e>>2]=c[b>>2];c[e+4>>2]=c[b+4>>2];c[e+8>>2]=c[b+8>>2];c[e+12>>2]=c[b+12>>2];F=e+16|0;c[F>>2]=c[u>>2];c[F+4>>2]=c[u+4>>2];c[F+8>>2]=c[u+8>>2];c[F+12>>2]=c[u+12>>2];c[d>>2]=e;e=0}else if((v|0)==56){c[d+4>>2]=2;e=c[42543]|0;c[e>>2]=c[b>>2];c[e+4>>2]=c[b+4>>2];c[e+8>>2]=c[b+8>>2];c[e+12>>2]=c[b+12>>2];F=e+16|0;c[F>>2]=c[u>>2];c[F+4>>2]=c[u+4>>2];c[F+8>>2]=c[u+8>>2];c[F+12>>2]=c[u+12>>2];c[d>>2]=e;e=0}else if((v|0)==94){c[d+4>>2]=e;g=c[42543]|0;while(1){e=e+-1|0;if(!f)break;F=g+(e<<4)|0;E=c[f>>2]|0;c[F>>2]=c[E>>2];c[F+4>>2]=c[E+4>>2];c[F+8>>2]=c[E+8>>2];c[F+12>>2]=c[E+12>>2];f=c[f+4>>2]|0}c[d>>2]=g;e=0}_I(G|0);l=H;return e|0}function EI(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0;h=l;l=l+64|0;e=h+48|0;g=h+32|0;f=h+16|0;d=h;if((c[42547]|0)<(a|0)){b=c[42541]|0;if(!b){g=ZI(a<<3)|0;c[42541]=g;if(!g){g=c[13918]|0;c[d>>2]=125503;c[d+4>>2]=523;c[d+8>>2]=125753;zL(g,125484,d)|0;Ua(169980,1)}g=ZI(a<<2)|0;c[42542]=g;if(!g){g=c[13918]|0;c[f>>2]=125503;c[f+4>>2]=527;c[f+8>>2]=125772;zL(g,125484,f)|0;Ua(169980,1)}}else{f=aJ(b,a<<3)|0;c[42541]=f;if(!f){f=c[13918]|0;c[g>>2]=125503;c[g+4>>2]=533;c[g+8>>2]=125792;zL(f,125484,g)|0;Ua(169980,1)}g=aJ(c[42542]|0,a<<2)|0;c[42542]=g;if(!g){g=c[13918]|0;c[e>>2]=125503;c[e+4>>2]=539;c[e+8>>2]=125812;zL(g,125484,e)|0;Ua(169980,1)}}c[42547]=a}l=h;return}function FI(a){a=a|0;var b=0,d=0,e=0,f=0;f=l;l=l+32|0;e=f+16|0;d=f;if((c[42537]|0)<(a|0)){b=c[42536]|0;if(!b){e=ZI(a<<2)|0;c[42536]=e;if(!e){e=c[13918]|0;c[d>>2]=125503;c[d+4>>2]=573;c[d+8>>2]=125708;zL(e,125484,d)|0;Ua(169980,1)}}else{d=aJ(b,a<<2)|0;c[42536]=d;if(!d){d=c[13918]|0;c[e>>2]=125503;c[e+4>>2]=580;c[e+8>>2]=125730;zL(d,125484,e)|0;Ua(169980,1)}}c[42537]=a}l=f;return}function GI(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0,e=0.0;d=+h[b+8>>3];e=+h[b>>3];d=(+h[c>>3]-e)*(+h[a+8>>3]-d)-(+h[a>>3]-e)*(+h[c+8>>3]-d);return (d>0.0?1:d<0.0?2:3)|0}function HI(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;i=l;l=l+16|0;h=i;a:while(1){if((b|0)>3)e=0;else{b=9;break}while(1){if((e|0)>=(b|0)){b=8;break a}f=e+1|0;d=(f|0)%(b|0)|0;g=(e+2|0)%(b|0)|0;if(!(PI(e,g,a,b)|0))e=f;else break}QI(c[a+(e<<2)>>2]|0,c[a+(d<<2)>>2]|0,c[a+(g<<2)>>2]|0);b=b+-1|0;while(1){if((d|0)>=(b|0))continue a;g=d+1|0;c[a+(d<<2)>>2]=c[a+(g<<2)>>2];d=g}}if((b|0)==8){a=c[13918]|0;c[h>>2]=125503;c[h+4>>2]=324;c[h+8>>2]=125648;zL(a,125484,h)|0}else if((b|0)==9)QI(c[a>>2]|0,c[a+4>>2]|0,c[a+8>>2]|0);l=i;return}function II(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;i=c[42544]|0;j=i+(a*52|0)|0;k=i+(b*52|0)|0;g=0;while(1){if((g|0)==3)break;l=i+(a*52|0)+4+(g<<4)|0;m=i+(a*52|0)+4+(g<<4)+4|0;n=i+(a*52|0)+4+(g<<4)+12|0;f=0;while(1){if((f|0)==3)break;o=c[c[l>>2]>>2]|0;h=c[c[i+(b*52|0)+4+(f<<4)>>2]>>2]|0;if((o|0)==(h|0)){d=c[c[i+(b*52|0)+4+(f<<4)+4>>2]>>2]|0;if((c[c[m>>2]>>2]|0)==(d|0))e=10;else e=8}else{d=c[c[i+(b*52|0)+4+(f<<4)+4>>2]>>2]|0;e=8}if(((e|0)==8?(e=0,(o|0)==(d|0)):0)?(c[c[m>>2]>>2]|0)==(h|0):0)e=10;if((e|0)==10){c[n>>2]=k;c[i+(b*52|0)+4+(f<<4)+12>>2]=j}f=f+1|0}g=g+1|0}return}function JI(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;f=c[42544]|0;d=0;e=0;while(1){if((e|0)==3)break;d=d+((GI(c[c[f+(a*52|0)+4+(e<<4)>>2]>>2]|0,c[c[f+(a*52|0)+4+(e<<4)+4>>2]>>2]|0,b)|0)!=2&1)|0;e=e+1|0}return ((d|0)==3|(d|0)==0)&1|0}function KI(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=c[42544]|0;e=d+(a*52|0)|0;a:do if(!(c[e>>2]|0)){c[e>>2]=1;if((a|0)==(b|0))d=1;else{f=0;while(1){if((f|0)>=3)break;e=c[d+(a*52|0)+4+(f<<4)+12>>2]|0;if(e){if(KI((e-d|0)/52|0,b)|0){d=1;break a}d=c[42544]|0}f=f+1|0}c[d+(a*52|0)>>2]=0;d=0}}else d=0;while(0);return d|0}function LI(a){a=a|0;var b=0,d=0,e=0,f=0;f=l;l=l+32|0;e=f+16|0;d=f;if((c[42545]|0)<(a|0)){b=c[42543]|0;if(!b){e=ZI(a<<4)|0;c[42543]=e;if(!e){e=c[13918]|0;c[d>>2]=125503;c[d+4>>2]=593;c[d+8>>2]=125611;zL(e,125484,d)|0;Ua(169980,1)}}else{d=aJ(b,a<<4)|0;c[42543]=d;if(!d){d=c[13918]|0;c[e>>2]=125503;c[e+4>>2]=599;c[e+8>>2]=125629;zL(d,125484,e)|0;Ua(169980,1)}}c[42545]=a}l=f;return}function MI(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=c[42539]|0;e=c[42538]|0;f=(d|0)>=(e|0);if((a|0)==1)if(f){c[b+4>>2]=c[(c[42536]|0)+(e<<2)>>2];a=170152;d=-1}else{a=170152;d=-1}else if(f){c[b+4>>2]=c[(c[42536]|0)+(d<<2)>>2];a=170156;d=1}else{a=170156;d=1}f=(c[a>>2]|0)+d|0;c[a>>2]=f;c[(c[42536]|0)+(f<<2)>>2]=b;return}function NI(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;f=c[42540]|0;g=c[42536]|0;b=c[42538]|0;while(1){if((b|0)>=(f|0)){e=4;break}d=b+1|0;if((GI(c[c[g+(d<<2)>>2]>>2]|0,c[c[g+(b<<2)>>2]>>2]|0,c[a>>2]|0)|0)==1)break;else b=d}a:do if((e|0)==4){b=c[42539]|0;while(1){if((b|0)<=(f|0)){b=f;break a}d=b+-1|0;if((GI(c[c[g+(d<<2)>>2]>>2]|0,c[c[g+(b<<2)>>2]>>2]|0,c[a>>2]|0)|0)==2)break;else b=d}}while(0);return b|0}function OI(a,b){a=a|0;b=b|0;c[((a|0)==1?170156:170152)>>2]=b;return}function PI(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0;f=c[c[d+(((a+-1+e|0)%(e|0)|0)<<2)>>2]>>2]|0;i=c[c[d+(a<<2)>>2]>>2]|0;g=c[c[d+(((a+1|0)%(e|0)|0)<<2)>>2]>>2]|0;k=(GI(f,i,g)|0)==1;j=c[c[d+(b<<2)>>2]>>2]|0;if(k)if((GI(i,j,f)|0)==1){f=GI(j,i,g)|0;g=1;h=5}else f=0;else{f=GI(i,j,g)|0;g=2;h=5}a:do if((h|0)==5)if((f|0)==(g|0)){f=0;while(1){if((f|0)>=(e|0)){f=1;break a}g=f;f=f+1|0;h=(f|0)%(e|0)|0;if((h|0)==(b|0)|((g|0)==(b|0)|((g|0)==(a|0)|(h|0)==(a|0))))continue;if(SI(i,j,c[c[d+(g<<2)>>2]>>2]|0,c[c[d+(h<<2)>>2]>>2]|0)|0){f=0;break}}}else f=0;while(0);return f|0}function QI(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0;e=c[42535]|0;f=c[42546]|0;if((e|0)<(f|0))h=e;else{RI(f+20|0);h=c[42535]|0}g=c[42544]|0;c[42535]=h+1;f=g+(h*52|0)|0;c[f>>2]=0;c[g+(h*52|0)+4>>2]=a;c[g+(h*52|0)+8>>2]=b;c[g+(h*52|0)+16>>2]=0;c[g+(h*52|0)+20>>2]=b;c[g+(h*52|0)+24>>2]=d;c[g+(h*52|0)+32>>2]=0;c[g+(h*52|0)+36>>2]=d;c[g+(h*52|0)+40>>2]=a;c[g+(h*52|0)+48>>2]=0;e=0;while(1){if((e|0)==3)break;c[g+(h*52|0)+4+(e<<4)+8>>2]=f;e=e+1|0}return}function RI(a){a=a|0;var b=0,d=0,e=0,f=0;f=l;l=l+32|0;e=f+16|0;d=f;if((c[42546]|0)<(a|0)){b=c[42544]|0;if(!b){e=ZI(a*52|0)|0;c[42544]=e;if(!e){e=c[13918]|0;c[d>>2]=125503;c[d+4>>2]=552;c[d+8>>2]=125669;zL(e,125484,d)|0;Ua(169980,1)}}else{d=aJ(b,a*52|0)|0;c[42544]=d;if(!d){d=c[13918]|0;c[e>>2]=125503;c[e+4>>2]=558;c[e+8>>2]=125688;zL(d,125484,e)|0;Ua(169980,1)}}c[42546]=a}l=f;return}function SI(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0;f=GI(a,b,c)|0;if((((f|0)!=3?(g=GI(a,b,d)|0,(g|0)!=3):0)?(h=GI(c,d,a)|0,(h|0)!=3):0)?(e=GI(c,d,b)|0,(e|0)!=3):0)return ((f|0)==1^(g|0)==1)&((h|0)==1^(e|0)==1)&1|0;if(((TI(a,b,c)|0)==0?(TI(a,b,d)|0)==0:0)?(TI(c,d,a)|0)==0:0)return (TI(c,d,b)|0)!=0|0;return 1}function TI(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0,g=0.0;e=+h[a>>3];g=+h[b>>3]-e;f=+h[a+8>>3];d=+h[b+8>>3]-f;e=+h[c>>3]-e;f=+h[c+8>>3]-f;if((GI(a,b,c)|0)==3?f*d+e*g>=0.0:0)a=f*f+e*e<=d*d+g*g&1;else a=0;return a|0}function UI(a,b){a=a|0;b=b|0;var c=0,d=0.0,e=0.0,f=0.0,g=0.0,i=0.0,j=0;d=+h[a+24>>3];a:do if(d<1.0e-07&d>-1.0e-07)a=VI(a,b)|0;else{g=+h[a+16>>3]/(d*3.0);f=+h[a+8>>3]/d;e=g*g;d=g*2.0*e-g*f+ +h[a>>3]/d;e=f*.3333333333333333-e;e=e*e*4.0*e;f=d*d+e;if(!(f<0.0)){i=(+C(+f)-d)*.5;e=+JJ(i);d=+JJ(-d-i)+e;h[b>>3]=d;if(f>0.0)a=1;else{d=d*-.5;h[b+16>>3]=d;a=1;c=7}}else{i=+K(+(+C(+-f)),+-d);d=+JJ(+C(+-e)*.5)*2.0;h[b>>3]=d*+E(+(i*.3333333333333333));h[b+8>>3]=+E(+((i+6.283185307179586)*.3333333333333333))*d;d=+E(+((i+-6.283185307179586)*.3333333333333333))*d;a=2;c=7}if((c|0)==7){h[b+(a<<3)>>3]=d;a=3}c=0;while(1){if((c|0)>=(a|0))break a;j=b+(c<<3)|0;h[j>>3]=+h[j>>3]-g;c=c+1|0}}while(0);return a|0}function VI(a,b){a=a|0;b=b|0;var c=0.0,d=0.0;c=+h[a+16>>3];do if(!(c<1.0e-07&c>-1.0e-07)){d=+h[a+8>>3]/(c*2.0);c=d*d-+h[a>>3]/c;if(!(c<0.0))if(c==0.0){h[b>>3]=-d;a=1;break}else{c=+C(+c)-d;h[b>>3]=c;h[b+8>>3]=d*-2.0-c;a=2;break}else a=0}else a=WI(a,b)|0;while(0);return a|0}function WI(a,b){a=a|0;b=b|0;var c=0.0,d=0.0;d=+h[a+8>>3];c=+h[a>>3];if(d<1.0e-07&d>-1.0e-07)a=c<1.0e-07&c>-1.0e-07?4:0;else{h[b>>3]=-c/d;a=1}return a|0}function XI(a){a=a|0;_I(c[a>>2]|0);_I(a);return}function YI(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;e=c[a+4>>2]|0;i=(e*3|0)+-2|0;d=c[42549]|0;if((i|0)>(c[42548]|0)){if(!d)d=ZI(i<<4)|0;else d=aJ(d,i<<4)|0;c[42549]=d;c[42548]=i;h=d;g=d}else{h=d;g=d}f=c[a>>2]|0;c[h>>2]=c[f>>2];c[h+4>>2]=c[f+4>>2];c[h+8>>2]=c[f+8>>2];c[h+12>>2]=c[f+12>>2];UN(h+16|0,f|0,16)|0;e=e+-1|0;d=1;a=2;while(1){if((d|0)>=(e|0))break;j=h+(a+2<<4)|0;k=h+(a+1<<4)|0;m=h+(a<<4)|0;l=f+(d<<4)|0;c[m>>2]=c[l>>2];c[m+4>>2]=c[l+4>>2];c[m+8>>2]=c[l+8>>2];c[m+12>>2]=c[l+12>>2];UN(k|0,l|0,16)|0;c[j>>2]=c[k>>2];c[j+4>>2]=c[k+4>>2];c[j+8>>2]=c[k+8>>2];c[j+12>>2]=c[k+12>>2];d=d+1|0;a=a+3|0}l=h+(a<<4)|0;m=f+(d<<4)|0;c[l>>2]=c[m>>2];c[l+4>>2]=c[m+4>>2];c[l+8>>2]=c[m+8>>2];c[l+12>>2]=c[m+12>>2];UN(h+(a+1<<4)|0,m|0,16)|0;c[b+4>>2]=i;c[b>>2]=g;return}function ZI(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0;x=l;l=l+16|0;p=x;do if(a>>>0<245){m=a>>>0<11?16:a+11&-8;a=m>>>3;o=c[42550]|0;d=o>>>a;if(d&3|0){b=(d&1^1)+a|0;a=170240+(b<<1<<2)|0;d=a+8|0;e=c[d>>2]|0;f=e+8|0;g=c[f>>2]|0;if((g|0)==(a|0))c[42550]=o&~(1<>2]=a;c[d>>2]=g}w=b<<3;c[e+4>>2]=w|3;w=e+w+4|0;c[w>>2]=c[w>>2]|1;w=f;l=x;return w|0}n=c[42552]|0;if(m>>>0>n>>>0){if(d|0){b=2<>>12&16;b=b>>>i;d=b>>>5&8;b=b>>>d;g=b>>>2&4;b=b>>>g;a=b>>>1&2;b=b>>>a;e=b>>>1&1;e=(d|i|g|a|e)+(b>>>e)|0;b=170240+(e<<1<<2)|0;a=b+8|0;g=c[a>>2]|0;i=g+8|0;d=c[i>>2]|0;if((d|0)==(b|0)){a=o&~(1<>2]=b;c[a>>2]=d;a=o}w=e<<3;h=w-m|0;c[g+4>>2]=m|3;f=g+m|0;c[f+4>>2]=h|1;c[g+w>>2]=h;if(n|0){e=c[42555]|0;b=n>>>3;d=170240+(b<<1<<2)|0;b=1<>2]|0}c[a>>2]=e;c[b+12>>2]=e;c[e+8>>2]=b;c[e+12>>2]=d}c[42552]=h;c[42555]=f;w=i;l=x;return w|0}j=c[42551]|0;if(j){d=(j&0-j)+-1|0;i=d>>>12&16;d=d>>>i;h=d>>>5&8;d=d>>>h;k=d>>>2&4;d=d>>>k;e=d>>>1&2;d=d>>>e;a=d>>>1&1;a=c[170504+((h|i|k|e|a)+(d>>>a)<<2)>>2]|0;d=(c[a+4>>2]&-8)-m|0;e=c[a+16+(((c[a+16>>2]|0)==0&1)<<2)>>2]|0;if(!e){k=a;h=d}else{do{i=(c[e+4>>2]&-8)-m|0;k=i>>>0>>0;d=k?i:d;a=k?e:a;e=c[e+16+(((c[e+16>>2]|0)==0&1)<<2)>>2]|0}while((e|0)!=0);k=a;h=d}i=k+m|0;if(i>>>0>k>>>0){f=c[k+24>>2]|0;b=c[k+12>>2]|0;do if((b|0)==(k|0)){a=k+20|0;b=c[a>>2]|0;if(!b){a=k+16|0;b=c[a>>2]|0;if(!b){d=0;break}}while(1){d=b+20|0;e=c[d>>2]|0;if(e|0){b=e;a=d;continue}d=b+16|0;e=c[d>>2]|0;if(!e)break;else{b=e;a=d}}c[a>>2]=0;d=b}else{d=c[k+8>>2]|0;c[d+12>>2]=b;c[b+8>>2]=d;d=b}while(0);do if(f|0){b=c[k+28>>2]|0;a=170504+(b<<2)|0;if((k|0)==(c[a>>2]|0)){c[a>>2]=d;if(!d){c[42551]=j&~(1<>2]|0)!=(k|0)&1)<<2)>>2]=d;if(!d)break}c[d+24>>2]=f;b=c[k+16>>2]|0;if(b|0){c[d+16>>2]=b;c[b+24>>2]=d}b=c[k+20>>2]|0;if(b|0){c[d+20>>2]=b;c[b+24>>2]=d}}while(0);if(h>>>0<16){w=h+m|0;c[k+4>>2]=w|3;w=k+w+4|0;c[w>>2]=c[w>>2]|1}else{c[k+4>>2]=m|3;c[i+4>>2]=h|1;c[i+h>>2]=h;if(n|0){e=c[42555]|0;b=n>>>3;d=170240+(b<<1<<2)|0;b=1<>2]|0}c[a>>2]=e;c[b+12>>2]=e;c[e+8>>2]=b;c[e+12>>2]=d}c[42552]=h;c[42555]=i}w=k+8|0;l=x;return w|0}else n=m}else n=m}else n=m}else if(a>>>0<=4294967231){a=a+11|0;m=a&-8;k=c[42551]|0;if(k){e=0-m|0;a=a>>>8;if(a)if(m>>>0>16777215)j=31;else{o=(a+1048320|0)>>>16&8;v=a<>>16&4;v=v<>>16&2;j=14-(n|o|j)+(v<>>15)|0;j=m>>>(j+7|0)&1|j<<1}else j=0;d=c[170504+(j<<2)>>2]|0;a:do if(!d){d=0;a=0;v=57}else{a=0;i=d;h=m<<((j|0)==31?0:25-(j>>>1)|0);d=0;while(1){f=(c[i+4>>2]&-8)-m|0;if(f>>>0>>0)if(!f){e=0;d=i;a=i;v=61;break a}else{a=i;e=f}f=c[i+20>>2]|0;i=c[i+16+(h>>>31<<2)>>2]|0;d=(f|0)==0|(f|0)==(i|0)?d:f;f=(i|0)==0;if(f){v=57;break}else h=h<<((f^1)&1)}}while(0);if((v|0)==57){if((d|0)==0&(a|0)==0){a=2<>>12&16;o=o>>>i;h=o>>>5&8;o=o>>>h;j=o>>>2&4;o=o>>>j;n=o>>>1&2;o=o>>>n;d=o>>>1&1;a=0;d=c[170504+((h|i|j|n|d)+(o>>>d)<<2)>>2]|0}if(!d){i=a;h=e}else v=61}if((v|0)==61)while(1){v=0;n=(c[d+4>>2]&-8)-m|0;o=n>>>0>>0;e=o?n:e;a=o?d:a;d=c[d+16+(((c[d+16>>2]|0)==0&1)<<2)>>2]|0;if(!d){i=a;h=e;break}else v=61}if((i|0)!=0?h>>>0<((c[42552]|0)-m|0)>>>0:0){g=i+m|0;if(g>>>0<=i>>>0){w=0;l=x;return w|0}f=c[i+24>>2]|0;b=c[i+12>>2]|0;do if((b|0)==(i|0)){a=i+20|0;b=c[a>>2]|0;if(!b){a=i+16|0;b=c[a>>2]|0;if(!b){b=0;break}}while(1){d=b+20|0;e=c[d>>2]|0;if(e|0){b=e;a=d;continue}d=b+16|0;e=c[d>>2]|0;if(!e)break;else{b=e;a=d}}c[a>>2]=0}else{w=c[i+8>>2]|0;c[w+12>>2]=b;c[b+8>>2]=w}while(0);do if(f){a=c[i+28>>2]|0;d=170504+(a<<2)|0;if((i|0)==(c[d>>2]|0)){c[d>>2]=b;if(!b){e=k&~(1<>2]|0)!=(i|0)&1)<<2)>>2]=b;if(!b){e=k;break}}c[b+24>>2]=f;a=c[i+16>>2]|0;if(a|0){c[b+16>>2]=a;c[a+24>>2]=b}a=c[i+20>>2]|0;if(a){c[b+20>>2]=a;c[a+24>>2]=b;e=k}else e=k}else e=k;while(0);do if(h>>>0>=16){c[i+4>>2]=m|3;c[g+4>>2]=h|1;c[g+h>>2]=h;b=h>>>3;if(h>>>0<256){d=170240+(b<<1<<2)|0;a=c[42550]|0;b=1<>2]|0}c[a>>2]=g;c[b+12>>2]=g;c[g+8>>2]=b;c[g+12>>2]=d;break}b=h>>>8;if(b)if(h>>>0>16777215)b=31;else{v=(b+1048320|0)>>>16&8;w=b<>>16&4;w=w<>>16&2;b=14-(u|v|b)+(w<>>15)|0;b=h>>>(b+7|0)&1|b<<1}else b=0;d=170504+(b<<2)|0;c[g+28>>2]=b;a=g+16|0;c[a+4>>2]=0;c[a>>2]=0;a=1<>2]=g;c[g+24>>2]=d;c[g+12>>2]=g;c[g+8>>2]=g;break}a=h<<((b|0)==31?0:25-(b>>>1)|0);d=c[d>>2]|0;while(1){if((c[d+4>>2]&-8|0)==(h|0)){v=97;break}e=d+16+(a>>>31<<2)|0;b=c[e>>2]|0;if(!b){v=96;break}else{a=a<<1;d=b}}if((v|0)==96){c[e>>2]=g;c[g+24>>2]=d;c[g+12>>2]=g;c[g+8>>2]=g;break}else if((v|0)==97){v=d+8|0;w=c[v>>2]|0;c[w+12>>2]=g;c[v>>2]=g;c[g+8>>2]=w;c[g+12>>2]=d;c[g+24>>2]=0;break}}else{w=h+m|0;c[i+4>>2]=w|3;w=i+w+4|0;c[w>>2]=c[w>>2]|1}while(0);w=i+8|0;l=x;return w|0}else n=m}else n=m}else n=-1;while(0);d=c[42552]|0;if(d>>>0>=n>>>0){b=d-n|0;a=c[42555]|0;if(b>>>0>15){w=a+n|0;c[42555]=w;c[42552]=b;c[w+4>>2]=b|1;c[a+d>>2]=b;c[a+4>>2]=n|3}else{c[42552]=0;c[42555]=0;c[a+4>>2]=d|3;w=a+d+4|0;c[w>>2]=c[w>>2]|1}w=a+8|0;l=x;return w|0}i=c[42553]|0;if(i>>>0>n>>>0){u=i-n|0;c[42553]=u;w=c[42556]|0;v=w+n|0;c[42556]=v;c[v+4>>2]=u|1;c[w+4>>2]=n|3;w=w+8|0;l=x;return w|0}if(!(c[42668]|0)){c[42670]=4096;c[42669]=4096;c[42671]=-1;c[42672]=-1;c[42673]=0;c[42661]=0;c[42668]=p&-16^1431655768;a=4096}else a=c[42670]|0;j=n+48|0;k=n+47|0;h=a+k|0;f=0-a|0;m=h&f;if(m>>>0<=n>>>0){w=0;l=x;return w|0}a=c[42660]|0;if(a|0?(o=c[42658]|0,p=o+m|0,p>>>0<=o>>>0|p>>>0>a>>>0):0){w=0;l=x;return w|0}b:do if(!(c[42661]&4)){d=c[42556]|0;c:do if(d){e=170648;while(1){a=c[e>>2]|0;if(a>>>0<=d>>>0?(s=e+4|0,(a+(c[s>>2]|0)|0)>>>0>d>>>0):0)break;a=c[e+8>>2]|0;if(!a){v=118;break c}else e=a}b=h-i&f;if(b>>>0<2147483647){a=WN(b|0)|0;if((a|0)==((c[e>>2]|0)+(c[s>>2]|0)|0)){if((a|0)!=(-1|0)){h=b;g=a;v=135;break b}}else{e=a;v=126}}else b=0}else v=118;while(0);do if((v|0)==118){d=WN(0)|0;if((d|0)!=(-1|0)?(b=d,q=c[42669]|0,r=q+-1|0,b=((r&b|0)==0?0:(r+b&0-q)-b|0)+m|0,q=c[42658]|0,r=b+q|0,b>>>0>n>>>0&b>>>0<2147483647):0){s=c[42660]|0;if(s|0?r>>>0<=q>>>0|r>>>0>s>>>0:0){b=0;break}a=WN(b|0)|0;if((a|0)==(d|0)){h=b;g=d;v=135;break b}else{e=a;v=126}}else b=0}while(0);do if((v|0)==126){d=0-b|0;if(!(j>>>0>b>>>0&(b>>>0<2147483647&(e|0)!=(-1|0))))if((e|0)==(-1|0)){b=0;break}else{h=b;g=e;v=135;break b}a=c[42670]|0;a=k-b+a&0-a;if(a>>>0>=2147483647){h=b;g=e;v=135;break b}if((WN(a|0)|0)==(-1|0)){WN(d|0)|0;b=0;break}else{h=a+b|0;g=e;v=135;break b}}while(0);c[42661]=c[42661]|4;v=133}else{b=0;v=133}while(0);if(((v|0)==133?m>>>0<2147483647:0)?(g=WN(m|0)|0,s=WN(0)|0,t=s-g|0,u=t>>>0>(n+40|0)>>>0,!((g|0)==(-1|0)|u^1|g>>>0>>0&((g|0)!=(-1|0)&(s|0)!=(-1|0))^1)):0){h=u?t:b;v=135}if((v|0)==135){b=(c[42658]|0)+h|0;c[42658]=b;if(b>>>0>(c[42659]|0)>>>0)c[42659]=b;j=c[42556]|0;do if(j){b=170648;while(1){a=c[b>>2]|0;d=b+4|0;e=c[d>>2]|0;if((g|0)==(a+e|0)){v=143;break}f=c[b+8>>2]|0;if(!f)break;else b=f}if(((v|0)==143?(c[b+12>>2]&8|0)==0:0)?g>>>0>j>>>0&a>>>0<=j>>>0:0){c[d>>2]=e+h;w=(c[42553]|0)+h|0;u=j+8|0;u=(u&7|0)==0?0:0-u&7;v=j+u|0;u=w-u|0;c[42556]=v;c[42553]=u;c[v+4>>2]=u|1;c[j+w+4>>2]=40;c[42557]=c[42672];break}if(g>>>0<(c[42554]|0)>>>0)c[42554]=g;a=g+h|0;b=170648;while(1){if((c[b>>2]|0)==(a|0)){v=151;break}b=c[b+8>>2]|0;if(!b){a=170648;break}}if((v|0)==151)if(!(c[b+12>>2]&8)){c[b>>2]=g;m=b+4|0;c[m>>2]=(c[m>>2]|0)+h;m=g+8|0;m=g+((m&7|0)==0?0:0-m&7)|0;b=a+8|0;b=a+((b&7|0)==0?0:0-b&7)|0;k=m+n|0;i=b-m-n|0;c[m+4>>2]=n|3;do if((j|0)!=(b|0)){if((c[42555]|0)==(b|0)){w=(c[42552]|0)+i|0;c[42552]=w;c[42555]=k;c[k+4>>2]=w|1;c[k+w>>2]=w;break}a=c[b+4>>2]|0;if((a&3|0)==1){h=a&-8;e=a>>>3;d:do if(a>>>0<256){a=c[b+8>>2]|0;d=c[b+12>>2]|0;if((d|0)==(a|0)){c[42550]=c[42550]&~(1<>2]=d;c[d+8>>2]=a;break}}else{g=c[b+24>>2]|0;a=c[b+12>>2]|0;do if((a|0)==(b|0)){e=b+16|0;d=e+4|0;a=c[d>>2]|0;if(!a){a=c[e>>2]|0;if(!a){a=0;break}else d=e}while(1){e=a+20|0;f=c[e>>2]|0;if(f|0){a=f;d=e;continue}e=a+16|0;f=c[e>>2]|0;if(!f)break;else{a=f;d=e}}c[d>>2]=0}else{w=c[b+8>>2]|0;c[w+12>>2]=a;c[a+8>>2]=w}while(0);if(!g)break;d=c[b+28>>2]|0;e=170504+(d<<2)|0;do if((c[e>>2]|0)!=(b|0)){c[g+16+(((c[g+16>>2]|0)!=(b|0)&1)<<2)>>2]=a;if(!a)break d}else{c[e>>2]=a;if(a|0)break;c[42551]=c[42551]&~(1<>2]=g;d=b+16|0;e=c[d>>2]|0;if(e|0){c[a+16>>2]=e;c[e+24>>2]=a}d=c[d+4>>2]|0;if(!d)break;c[a+20>>2]=d;c[d+24>>2]=a}while(0);b=b+h|0;f=h+i|0}else f=i;b=b+4|0;c[b>>2]=c[b>>2]&-2;c[k+4>>2]=f|1;c[k+f>>2]=f;b=f>>>3;if(f>>>0<256){d=170240+(b<<1<<2)|0;a=c[42550]|0;b=1<>2]|0}c[a>>2]=k;c[b+12>>2]=k;c[k+8>>2]=b;c[k+12>>2]=d;break}b=f>>>8;do if(!b)b=0;else{if(f>>>0>16777215){b=31;break}v=(b+1048320|0)>>>16&8;w=b<>>16&4;w=w<>>16&2;b=14-(u|v|b)+(w<>>15)|0;b=f>>>(b+7|0)&1|b<<1}while(0);e=170504+(b<<2)|0;c[k+28>>2]=b;a=k+16|0;c[a+4>>2]=0;c[a>>2]=0;a=c[42551]|0;d=1<>2]=k;c[k+24>>2]=e;c[k+12>>2]=k;c[k+8>>2]=k;break}a=f<<((b|0)==31?0:25-(b>>>1)|0);d=c[e>>2]|0;while(1){if((c[d+4>>2]&-8|0)==(f|0)){v=192;break}e=d+16+(a>>>31<<2)|0;b=c[e>>2]|0;if(!b){v=191;break}else{a=a<<1;d=b}}if((v|0)==191){c[e>>2]=k;c[k+24>>2]=d;c[k+12>>2]=k;c[k+8>>2]=k;break}else if((v|0)==192){v=d+8|0;w=c[v>>2]|0;c[w+12>>2]=k;c[v>>2]=k;c[k+8>>2]=w;c[k+12>>2]=d;c[k+24>>2]=0;break}}else{w=(c[42553]|0)+i|0;c[42553]=w;c[42556]=k;c[k+4>>2]=w|1}while(0);w=m+8|0;l=x;return w|0}else a=170648;while(1){b=c[a>>2]|0;if(b>>>0<=j>>>0?(w=b+(c[a+4>>2]|0)|0,w>>>0>j>>>0):0)break;a=c[a+8>>2]|0}f=w+-47|0;a=f+8|0;a=f+((a&7|0)==0?0:0-a&7)|0;f=j+16|0;a=a>>>0>>0?j:a;b=a+8|0;d=h+-40|0;u=g+8|0;u=(u&7|0)==0?0:0-u&7;v=g+u|0;u=d-u|0;c[42556]=v;c[42553]=u;c[v+4>>2]=u|1;c[g+d+4>>2]=40;c[42557]=c[42672];d=a+4|0;c[d>>2]=27;c[b>>2]=c[42662];c[b+4>>2]=c[42663];c[b+8>>2]=c[42664];c[b+12>>2]=c[42665];c[42662]=g;c[42663]=h;c[42665]=0;c[42664]=b;b=a+24|0;do{v=b;b=b+4|0;c[b>>2]=7}while((v+8|0)>>>0>>0);if((a|0)!=(j|0)){g=a-j|0;c[d>>2]=c[d>>2]&-2;c[j+4>>2]=g|1;c[a>>2]=g;b=g>>>3;if(g>>>0<256){d=170240+(b<<1<<2)|0;a=c[42550]|0;b=1<>2]|0}c[a>>2]=j;c[b+12>>2]=j;c[j+8>>2]=b;c[j+12>>2]=d;break}b=g>>>8;if(b)if(g>>>0>16777215)d=31;else{v=(b+1048320|0)>>>16&8;w=b<>>16&4;w=w<>>16&2;d=14-(u|v|d)+(w<>>15)|0;d=g>>>(d+7|0)&1|d<<1}else d=0;e=170504+(d<<2)|0;c[j+28>>2]=d;c[j+20>>2]=0;c[f>>2]=0;b=c[42551]|0;a=1<>2]=j;c[j+24>>2]=e;c[j+12>>2]=j;c[j+8>>2]=j;break}a=g<<((d|0)==31?0:25-(d>>>1)|0);d=c[e>>2]|0;while(1){if((c[d+4>>2]&-8|0)==(g|0)){v=213;break}e=d+16+(a>>>31<<2)|0;b=c[e>>2]|0;if(!b){v=212;break}else{a=a<<1;d=b}}if((v|0)==212){c[e>>2]=j;c[j+24>>2]=d;c[j+12>>2]=j;c[j+8>>2]=j;break}else if((v|0)==213){v=d+8|0;w=c[v>>2]|0;c[w+12>>2]=j;c[v>>2]=j;c[j+8>>2]=w;c[j+12>>2]=d;c[j+24>>2]=0;break}}}else{w=c[42554]|0;if((w|0)==0|g>>>0>>0)c[42554]=g;c[42662]=g;c[42663]=h;c[42665]=0;c[42559]=c[42668];c[42558]=-1;c[42563]=170240;c[42562]=170240;c[42565]=170248;c[42564]=170248;c[42567]=170256;c[42566]=170256;c[42569]=170264;c[42568]=170264;c[42571]=170272;c[42570]=170272;c[42573]=170280;c[42572]=170280;c[42575]=170288;c[42574]=170288;c[42577]=170296;c[42576]=170296;c[42579]=170304;c[42578]=170304;c[42581]=170312;c[42580]=170312;c[42583]=170320;c[42582]=170320;c[42585]=170328;c[42584]=170328;c[42587]=170336;c[42586]=170336;c[42589]=170344;c[42588]=170344;c[42591]=170352;c[42590]=170352;c[42593]=170360;c[42592]=170360;c[42595]=170368;c[42594]=170368;c[42597]=170376;c[42596]=170376;c[42599]=170384;c[42598]=170384;c[42601]=170392;c[42600]=170392;c[42603]=170400;c[42602]=170400;c[42605]=170408;c[42604]=170408;c[42607]=170416;c[42606]=170416;c[42609]=170424;c[42608]=170424;c[42611]=170432;c[42610]=170432;c[42613]=170440;c[42612]=170440;c[42615]=170448;c[42614]=170448;c[42617]=170456;c[42616]=170456;c[42619]=170464;c[42618]=170464;c[42621]=170472;c[42620]=170472;c[42623]=170480;c[42622]=170480;c[42625]=170488;c[42624]=170488;w=h+-40|0;u=g+8|0;u=(u&7|0)==0?0:0-u&7;v=g+u|0;u=w-u|0;c[42556]=v;c[42553]=u;c[v+4>>2]=u|1;c[g+w+4>>2]=40;c[42557]=c[42672]}while(0);b=c[42553]|0;if(b>>>0>n>>>0){u=b-n|0;c[42553]=u;w=c[42556]|0;v=w+n|0;c[42556]=v;c[v+4>>2]=u|1;c[w+4>>2]=n|3;w=w+8|0;l=x;return w|0}}c[(jJ()|0)>>2]=12;w=0;l=x;return w|0}function _I(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;if(!a)return;d=a+-8|0;f=c[42554]|0;a=c[a+-4>>2]|0;b=a&-8;j=d+b|0;do if(!(a&1)){e=c[d>>2]|0;if(!(a&3))return;h=d+(0-e)|0;g=e+b|0;if(h>>>0>>0)return;if((c[42555]|0)==(h|0)){a=j+4|0;b=c[a>>2]|0;if((b&3|0)!=3){i=h;b=g;break}c[42552]=g;c[a>>2]=b&-2;c[h+4>>2]=g|1;c[h+g>>2]=g;return}d=e>>>3;if(e>>>0<256){a=c[h+8>>2]|0;b=c[h+12>>2]|0;if((b|0)==(a|0)){c[42550]=c[42550]&~(1<>2]=b;c[b+8>>2]=a;i=h;b=g;break}}f=c[h+24>>2]|0;a=c[h+12>>2]|0;do if((a|0)==(h|0)){d=h+16|0;b=d+4|0;a=c[b>>2]|0;if(!a){a=c[d>>2]|0;if(!a){a=0;break}else b=d}while(1){d=a+20|0;e=c[d>>2]|0;if(e|0){a=e;b=d;continue}d=a+16|0;e=c[d>>2]|0;if(!e)break;else{a=e;b=d}}c[b>>2]=0}else{i=c[h+8>>2]|0;c[i+12>>2]=a;c[a+8>>2]=i}while(0);if(f){b=c[h+28>>2]|0;d=170504+(b<<2)|0;if((c[d>>2]|0)==(h|0)){c[d>>2]=a;if(!a){c[42551]=c[42551]&~(1<>2]|0)!=(h|0)&1)<<2)>>2]=a;if(!a){i=h;b=g;break}}c[a+24>>2]=f;b=h+16|0;d=c[b>>2]|0;if(d|0){c[a+16>>2]=d;c[d+24>>2]=a}b=c[b+4>>2]|0;if(b){c[a+20>>2]=b;c[b+24>>2]=a;i=h;b=g}else{i=h;b=g}}else{i=h;b=g}}else{i=d;h=d}while(0);if(h>>>0>=j>>>0)return;a=j+4|0;e=c[a>>2]|0;if(!(e&1))return;if(!(e&2)){if((c[42556]|0)==(j|0)){j=(c[42553]|0)+b|0;c[42553]=j;c[42556]=i;c[i+4>>2]=j|1;if((i|0)!=(c[42555]|0))return;c[42555]=0;c[42552]=0;return}if((c[42555]|0)==(j|0)){j=(c[42552]|0)+b|0;c[42552]=j;c[42555]=h;c[i+4>>2]=j|1;c[h+j>>2]=j;return}f=(e&-8)+b|0;d=e>>>3;do if(e>>>0<256){b=c[j+8>>2]|0;a=c[j+12>>2]|0;if((a|0)==(b|0)){c[42550]=c[42550]&~(1<>2]=a;c[a+8>>2]=b;break}}else{g=c[j+24>>2]|0;a=c[j+12>>2]|0;do if((a|0)==(j|0)){d=j+16|0;b=d+4|0;a=c[b>>2]|0;if(!a){a=c[d>>2]|0;if(!a){d=0;break}else b=d}while(1){d=a+20|0;e=c[d>>2]|0;if(e|0){a=e;b=d;continue}d=a+16|0;e=c[d>>2]|0;if(!e)break;else{a=e;b=d}}c[b>>2]=0;d=a}else{d=c[j+8>>2]|0;c[d+12>>2]=a;c[a+8>>2]=d;d=a}while(0);if(g|0){a=c[j+28>>2]|0;b=170504+(a<<2)|0;if((c[b>>2]|0)==(j|0)){c[b>>2]=d;if(!d){c[42551]=c[42551]&~(1<>2]|0)!=(j|0)&1)<<2)>>2]=d;if(!d)break}c[d+24>>2]=g;a=j+16|0;b=c[a>>2]|0;if(b|0){c[d+16>>2]=b;c[b+24>>2]=d}a=c[a+4>>2]|0;if(a|0){c[d+20>>2]=a;c[a+24>>2]=d}}}while(0);c[i+4>>2]=f|1;c[h+f>>2]=f;if((i|0)==(c[42555]|0)){c[42552]=f;return}}else{c[a>>2]=e&-2;c[i+4>>2]=b|1;c[h+b>>2]=b;f=b}a=f>>>3;if(f>>>0<256){d=170240+(a<<1<<2)|0;b=c[42550]|0;a=1<>2]|0}c[b>>2]=i;c[a+12>>2]=i;c[i+8>>2]=a;c[i+12>>2]=d;return}a=f>>>8;if(a)if(f>>>0>16777215)a=31;else{h=(a+1048320|0)>>>16&8;j=a<>>16&4;j=j<>>16&2;a=14-(g|h|a)+(j<>>15)|0;a=f>>>(a+7|0)&1|a<<1}else a=0;e=170504+(a<<2)|0;c[i+28>>2]=a;c[i+20>>2]=0;c[i+16>>2]=0;b=c[42551]|0;d=1<>>1)|0);d=c[e>>2]|0;while(1){if((c[d+4>>2]&-8|0)==(f|0)){a=73;break}e=d+16+(b>>>31<<2)|0;a=c[e>>2]|0;if(!a){a=72;break}else{b=b<<1;d=a}}if((a|0)==72){c[e>>2]=i;c[i+24>>2]=d;c[i+12>>2]=i;c[i+8>>2]=i;break}else if((a|0)==73){h=d+8|0;j=c[h>>2]|0;c[j+12>>2]=i;c[h>>2]=i;c[i+8>>2]=j;c[i+12>>2]=d;c[i+24>>2]=0;break}}else{c[42551]=b|d;c[e>>2]=i;c[i+24>>2]=e;c[i+12>>2]=i;c[i+8>>2]=i}while(0);j=(c[42558]|0)+-1|0;c[42558]=j;if(!j)a=170656;else return;while(1){a=c[a>>2]|0;if(!a)break;else a=a+8|0}c[42558]=-1;return}function $I(a,b){a=a|0;b=b|0;var d=0;if(a){d=O(b,a)|0;if((b|a)>>>0>65535)d=((d>>>0)/(a>>>0)|0|0)==(b|0)?d:-1}else d=0;a=ZI(d)|0;if(!a)return a|0;if(!(c[a+-4>>2]&3))return a|0;VN(a|0,0,d|0)|0;return a|0}function aJ(a,b){a=a|0;b=b|0;var d=0,e=0;if(!a){b=ZI(b)|0;return b|0}if(b>>>0>4294967231){c[(jJ()|0)>>2]=12;b=0;return b|0}d=bJ(a+-8|0,b>>>0<11?16:b+11&-8)|0;if(d|0){b=d+8|0;return b|0}d=ZI(b)|0;if(!d){b=0;return b|0}e=c[a+-4>>2]|0;e=(e&-8)-((e&3|0)==0?8:4)|0;TN(d|0,a|0,(e>>>0>>0?e:b)|0)|0;_I(a);b=d;return b|0}function bJ(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;l=a+4|0;m=c[l>>2]|0;d=m&-8;i=a+d|0;if(!(m&3)){if(b>>>0<256){a=0;return a|0}if(d>>>0>=(b+4|0)>>>0?(d-b|0)>>>0<=c[42670]<<1>>>0:0)return a|0;a=0;return a|0}if(d>>>0>=b>>>0){d=d-b|0;if(d>>>0<=15)return a|0;k=a+b|0;c[l>>2]=m&1|b|2;c[k+4>>2]=d|3;m=i+4|0;c[m>>2]=c[m>>2]|1;cJ(k,d);return a|0}if((c[42556]|0)==(i|0)){k=(c[42553]|0)+d|0;d=k-b|0;e=a+b|0;if(k>>>0<=b>>>0){a=0;return a|0}c[l>>2]=m&1|b|2;c[e+4>>2]=d|1;c[42556]=e;c[42553]=d;return a|0}if((c[42555]|0)==(i|0)){e=(c[42552]|0)+d|0;if(e>>>0>>0){a=0;return a|0}d=e-b|0;if(d>>>0>15){k=a+b|0;e=a+e|0;c[l>>2]=m&1|b|2;c[k+4>>2]=d|1;c[e>>2]=d;e=e+4|0;c[e>>2]=c[e>>2]&-2;e=k}else{c[l>>2]=m&1|e|2;e=a+e+4|0;c[e>>2]=c[e>>2]|1;e=0;d=0}c[42552]=d;c[42555]=e;return a|0}e=c[i+4>>2]|0;if(e&2|0){a=0;return a|0}j=(e&-8)+d|0;if(j>>>0>>0){a=0;return a|0}k=j-b|0;f=e>>>3;do if(e>>>0<256){e=c[i+8>>2]|0;d=c[i+12>>2]|0;if((d|0)==(e|0)){c[42550]=c[42550]&~(1<>2]=d;c[d+8>>2]=e;break}}else{h=c[i+24>>2]|0;d=c[i+12>>2]|0;do if((d|0)==(i|0)){f=i+16|0;e=f+4|0;d=c[e>>2]|0;if(!d){d=c[f>>2]|0;if(!d){f=0;break}else g=f}else g=e;while(1){f=d+20|0;e=c[f>>2]|0;if(e|0){d=e;g=f;continue}e=d+16|0;f=c[e>>2]|0;if(!f)break;else{d=f;g=e}}c[g>>2]=0;f=d}else{f=c[i+8>>2]|0;c[f+12>>2]=d;c[d+8>>2]=f;f=d}while(0);if(h|0){d=c[i+28>>2]|0;e=170504+(d<<2)|0;if((c[e>>2]|0)==(i|0)){c[e>>2]=f;if(!f){c[42551]=c[42551]&~(1<>2]|0)!=(i|0)&1)<<2)>>2]=f;if(!f)break}c[f+24>>2]=h;d=i+16|0;e=c[d>>2]|0;if(e|0){c[f+16>>2]=e;c[e+24>>2]=f}d=c[d+4>>2]|0;if(d|0){c[f+20>>2]=d;c[d+24>>2]=f}}}while(0);if(k>>>0<16){c[l>>2]=j|m&1|2;m=a+j+4|0;c[m>>2]=c[m>>2]|1;return a|0}else{i=a+b|0;c[l>>2]=m&1|b|2;c[i+4>>2]=k|3;m=a+j+4|0;c[m>>2]=c[m>>2]|1;cJ(i,k);return a|0}return 0}function cJ(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;i=a+b|0;d=c[a+4>>2]|0;do if(!(d&1)){f=c[a>>2]|0;if(!(d&3))return;h=a+(0-f)|0;b=f+b|0;if((c[42555]|0)==(h|0)){a=i+4|0;d=c[a>>2]|0;if((d&3|0)!=3)break;c[42552]=b;c[a>>2]=d&-2;c[h+4>>2]=b|1;c[i>>2]=b;return}e=f>>>3;if(f>>>0<256){a=c[h+8>>2]|0;d=c[h+12>>2]|0;if((d|0)==(a|0)){c[42550]=c[42550]&~(1<>2]=d;c[d+8>>2]=a;break}}g=c[h+24>>2]|0;a=c[h+12>>2]|0;do if((a|0)==(h|0)){e=h+16|0;d=e+4|0;a=c[d>>2]|0;if(!a){a=c[e>>2]|0;if(!a){a=0;break}else d=e}while(1){e=a+20|0;f=c[e>>2]|0;if(f|0){a=f;d=e;continue}e=a+16|0;f=c[e>>2]|0;if(!f)break;else{a=f;d=e}}c[d>>2]=0}else{f=c[h+8>>2]|0;c[f+12>>2]=a;c[a+8>>2]=f}while(0);if(g){d=c[h+28>>2]|0;e=170504+(d<<2)|0;if((c[e>>2]|0)==(h|0)){c[e>>2]=a;if(!a){c[42551]=c[42551]&~(1<>2]|0)!=(h|0)&1)<<2)>>2]=a;if(!a)break}c[a+24>>2]=g;d=h+16|0;e=c[d>>2]|0;if(e|0){c[a+16>>2]=e;c[e+24>>2]=a}d=c[d+4>>2]|0;if(d){c[a+20>>2]=d;c[d+24>>2]=a}}}else h=a;while(0);a=i+4|0;e=c[a>>2]|0;if(!(e&2)){if((c[42556]|0)==(i|0)){i=(c[42553]|0)+b|0;c[42553]=i;c[42556]=h;c[h+4>>2]=i|1;if((h|0)!=(c[42555]|0))return;c[42555]=0;c[42552]=0;return}if((c[42555]|0)==(i|0)){i=(c[42552]|0)+b|0;c[42552]=i;c[42555]=h;c[h+4>>2]=i|1;c[h+i>>2]=i;return}f=(e&-8)+b|0;d=e>>>3;do if(e>>>0<256){a=c[i+8>>2]|0;b=c[i+12>>2]|0;if((b|0)==(a|0)){c[42550]=c[42550]&~(1<>2]=b;c[b+8>>2]=a;break}}else{g=c[i+24>>2]|0;b=c[i+12>>2]|0;do if((b|0)==(i|0)){d=i+16|0;a=d+4|0;b=c[a>>2]|0;if(!b){b=c[d>>2]|0;if(!b){d=0;break}else a=d}while(1){d=b+20|0;e=c[d>>2]|0;if(e|0){b=e;a=d;continue}d=b+16|0;e=c[d>>2]|0;if(!e)break;else{b=e;a=d}}c[a>>2]=0;d=b}else{d=c[i+8>>2]|0;c[d+12>>2]=b;c[b+8>>2]=d;d=b}while(0);if(g|0){b=c[i+28>>2]|0;a=170504+(b<<2)|0;if((c[a>>2]|0)==(i|0)){c[a>>2]=d;if(!d){c[42551]=c[42551]&~(1<>2]|0)!=(i|0)&1)<<2)>>2]=d;if(!d)break}c[d+24>>2]=g;b=i+16|0;a=c[b>>2]|0;if(a|0){c[d+16>>2]=a;c[a+24>>2]=d}b=c[b+4>>2]|0;if(b|0){c[d+20>>2]=b;c[b+24>>2]=d}}}while(0);c[h+4>>2]=f|1;c[h+f>>2]=f;if((h|0)==(c[42555]|0)){c[42552]=f;return}}else{c[a>>2]=e&-2;c[h+4>>2]=b|1;c[h+b>>2]=b;f=b}b=f>>>3;if(f>>>0<256){d=170240+(b<<1<<2)|0;a=c[42550]|0;b=1<>2]|0}c[a>>2]=h;c[b+12>>2]=h;c[h+8>>2]=b;c[h+12>>2]=d;return}b=f>>>8;if(b)if(f>>>0>16777215)b=31;else{g=(b+1048320|0)>>>16&8;i=b<>>16&4;i=i<>>16&2;b=14-(e|g|b)+(i<>>15)|0;b=f>>>(b+7|0)&1|b<<1}else b=0;e=170504+(b<<2)|0;c[h+28>>2]=b;c[h+20>>2]=0;c[h+16>>2]=0;a=c[42551]|0;d=1<>2]=h;c[h+24>>2]=e;c[h+12>>2]=h;c[h+8>>2]=h;return}a=f<<((b|0)==31?0:25-(b>>>1)|0);d=c[e>>2]|0;while(1){if((c[d+4>>2]&-8|0)==(f|0)){b=69;break}e=d+16+(a>>>31<<2)|0;b=c[e>>2]|0;if(!b){b=68;break}else{a=a<<1;d=b}}if((b|0)==68){c[e>>2]=h;c[h+24>>2]=d;c[h+12>>2]=h;c[h+8>>2]=h;return}else if((b|0)==69){g=d+8|0;i=c[g>>2]|0;c[i+12>>2]=h;c[g>>2]=h;c[h+8>>2]=i;c[h+12>>2]=d;c[h+24>>2]=0;return}}function dJ(a,b){a=a|0;b=b|0;if(a>>>0<9){b=ZI(b)|0;return b|0}else{b=eJ(a,b)|0;return b|0}return 0}function eJ(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;a=a>>>0>16?a:16;if(a+-1&a){d=16;while(1)if(d>>>0>>0)d=d<<1;else{a=d;break}}if((-64-a|0)>>>0<=b>>>0){c[(jJ()|0)>>2]=12;h=0;return h|0}g=b>>>0<11?16:b+11&-8;d=ZI(g+12+a|0)|0;if(!d){h=0;return h|0}f=d+-8|0;do if(a+-1&d){e=(d+a+-1&0-a)+-8|0;b=f;e=(e-b|0)>>>0>15?e:e+a|0;b=e-b|0;a=d+-4|0;i=c[a>>2]|0;d=(i&-8)-b|0;if(!(i&3)){c[e>>2]=(c[f>>2]|0)+b;c[e+4>>2]=d;a=e;b=e;break}else{i=e+4|0;c[i>>2]=d|c[i>>2]&1|2;d=e+d+4|0;c[d>>2]=c[d>>2]|1;c[a>>2]=b|c[a>>2]&1|2;c[i>>2]=c[i>>2]|1;cJ(f,b);a=e;b=e;break}}else{a=f;b=f}while(0);a=a+4|0;d=c[a>>2]|0;if(d&3|0?(h=d&-8,h>>>0>(g+16|0)>>>0):0){i=h-g|0;f=b+g|0;c[a>>2]=g|d&1|2;c[f+4>>2]=i|3;h=b+h+4|0;c[h>>2]=c[h>>2]|1;cJ(f,i)}i=b+8|0;return i|0}function fJ(a){a=a|0;var b=0,d=0;b=l;l=l+16|0;d=b;c[d>>2]=kJ(c[a+60>>2]|0)|0;a=iJ(Da(6,d|0)|0)|0;l=b;return a|0}function gJ(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0;k=l;l=l+32|0;f=k;i=k+16|0;c[i>>2]=d;g=i+4|0;j=b+48|0;m=c[j>>2]|0;c[g>>2]=e-((m|0)!=0&1);h=b+44|0;c[i+8>>2]=c[h>>2];c[i+12>>2]=m;c[f>>2]=c[b+60>>2];c[f+4>>2]=i;c[f+8>>2]=2;f=iJ(ua(145,f|0)|0)|0;if((f|0)>=1){i=c[g>>2]|0;if(f>>>0>i>>>0){g=c[h>>2]|0;h=b+4|0;c[h>>2]=g;c[b+8>>2]=g+(f-i);if(!(c[j>>2]|0))f=e;else{c[h>>2]=g+1;a[d+(e+-1)>>0]=a[g>>0]|0;f=e}}}else c[b>>2]=c[b>>2]|f&48^16;l=k;return f|0}function hJ(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;f=l;l=l+32|0;g=f;e=f+20|0;c[g>>2]=c[a+60>>2];c[g+4>>2]=0;c[g+8>>2]=b;c[g+12>>2]=e;c[g+16>>2]=d;if((iJ(ta(140,g|0)|0)|0)<0){c[e>>2]=-1;a=-1}else a=c[e>>2]|0;l=f;return a|0}function iJ(a){a=a|0;if(a>>>0>4294963200){c[(jJ()|0)>>2]=0-a;a=-1}return a|0}function jJ(){return 170696}function kJ(a){a=a|0;return a|0}function lJ(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0;g=l;l=l+32|0;f=g;c[b+36>>2]=9;if((c[b>>2]&64|0)==0?(c[f>>2]=c[b+60>>2],c[f+4>>2]=21523,c[f+8>>2]=g+16,Ca(54,f|0)|0):0)a[b+75>>0]=-1;f=mJ(b,d,e)|0;l=g;return f|0}function mJ(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0;n=l;l=l+48|0;k=n+16|0;g=n;f=n+32|0;i=a+28|0;e=c[i>>2]|0;c[f>>2]=e;j=a+20|0;e=(c[j>>2]|0)-e|0;c[f+4>>2]=e;c[f+8>>2]=b;c[f+12>>2]=d;e=e+d|0;h=a+60|0;c[g>>2]=c[h>>2];c[g+4>>2]=f;c[g+8>>2]=2;g=iJ(va(146,g|0)|0)|0;a:do if((e|0)!=(g|0)){b=2;while(1){if((g|0)<0)break;e=e-g|0;p=c[f+4>>2]|0;o=g>>>0>p>>>0;f=o?f+8|0:f;b=b+(o<<31>>31)|0;p=g-(o?p:0)|0;c[f>>2]=(c[f>>2]|0)+p;o=f+4|0;c[o>>2]=(c[o>>2]|0)-p;c[k>>2]=c[h>>2];c[k+4>>2]=f;c[k+8>>2]=b;g=iJ(va(146,k|0)|0)|0;if((e|0)==(g|0)){m=3;break a}}c[a+16>>2]=0;c[i>>2]=0;c[j>>2]=0;c[a>>2]=c[a>>2]|32;if((b|0)==2)d=0;else d=d-(c[f+4>>2]|0)|0}else m=3;while(0);if((m|0)==3){p=c[a+44>>2]|0;c[a+16>>2]=p+(c[a+48>>2]|0);c[i>>2]=p;c[j>>2]=p}l=n;return d|0}function nJ(a,b){a=a|0;b=b|0;var d=0,e=0;d=l;l=l+16|0;e=d;c[e>>2]=a;c[e+4>>2]=b;b=iJ(Ea(91,e|0)|0)|0;l=d;return b|0}function oJ(){return}function pJ(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0;i=l;l=l+32|0;h=i;do if((g&4095|0)==0&(((g|0)<0)<<31>>31&-4096|0)==0){if(b>>>0>2147483646){c[(jJ()|0)>>2]=12;a=-1;break}c[h>>2]=a;c[h+4>>2]=b;c[h+8>>2]=d;c[h+12>>2]=e;c[h+16>>2]=f;c[h+20>>2]=g>>12;a=iJ(wa(192,h|0)|0)|0}else{c[(jJ()|0)>>2]=22;a=-1}while(0);l=i;return a|0}function qJ(b,d){b=b|0;d=d|0;var e=0,f=0,g=0;f=d&255;a:do if(!f)b=b+(rJ(b)|0)|0;else{if(b&3){e=d&255;do{g=a[b>>0]|0;if(g<<24>>24==0?1:g<<24>>24==e<<24>>24)break a;b=b+1|0}while((b&3|0)!=0)}f=O(f,16843009)|0;e=c[b>>2]|0;b:do if(!((e&-2139062144^-2139062144)&e+-16843009))do{g=e^f;if((g&-2139062144^-2139062144)&g+-16843009|0)break b;b=b+4|0;e=c[b>>2]|0}while(!((e&-2139062144^-2139062144)&e+-16843009|0));while(0);e=d&255;while(1){g=a[b>>0]|0;if(g<<24>>24==0?1:g<<24>>24==e<<24>>24)break;else b=b+1|0}}while(0);return b|0}function rJ(b){b=b|0;var d=0,e=0,f=0;f=b;a:do if(!(f&3))e=4;else{d=f;while(1){if(!(a[b>>0]|0)){b=d;break a}b=b+1|0;d=b;if(!(d&3)){e=4;break}}}while(0);if((e|0)==4){while(1){d=c[b>>2]|0;if(!((d&-2139062144^-2139062144)&d+-16843009))b=b+4|0;else break}if((d&255)<<24>>24)do b=b+1|0;while((a[b>>0]|0)!=0)}return b-f|0}function sJ(b,e){b=b|0;e=e|0;var f=0,g=0;g=0;while(1){if((d[125833+g>>0]|0)==(b|0)){b=2;break}f=g+1|0;if((f|0)==87){f=125921;g=87;b=5;break}else g=f}if((b|0)==2)if(!g)f=125921;else{f=125921;b=5}if((b|0)==5)while(1){do{b=f;f=f+1|0}while((a[b>>0]|0)!=0);g=g+-1|0;if(!g)break;else b=5}return tJ(f,c[e+20>>2]|0)|0}function tJ(a,b){a=a|0;b=b|0;return uJ(a,b)|0}function uJ(a,b){a=a|0;b=b|0;if(!b)b=0;else b=vJ(c[b>>2]|0,c[b+4>>2]|0,a)|0;return (b|0?b:a)|0}function vJ(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;o=(c[b>>2]|0)+1794895138|0;h=wJ(c[b+8>>2]|0,o)|0;f=wJ(c[b+12>>2]|0,o)|0;g=wJ(c[b+16>>2]|0,o)|0;a:do if((h>>>0>>2>>>0?(n=d-(h<<2)|0,f>>>0>>0&g>>>0>>0):0)?((g|f)&3|0)==0:0){n=f>>>2;m=g>>>2;l=0;while(1){j=h>>>1;k=l+j|0;i=k<<1;g=i+n|0;f=wJ(c[b+(g<<2)>>2]|0,o)|0;g=wJ(c[b+(g+1<<2)>>2]|0,o)|0;if(!(g>>>0>>0&f>>>0<(d-g|0)>>>0)){f=0;break a}if(a[b+(g+f)>>0]|0){f=0;break a}f=xJ(e,b+g|0)|0;if(!f)break;f=(f|0)<0;if((h|0)==1){f=0;break a}else{l=f?l:k;h=f?j:h-j|0}}f=i+m|0;g=wJ(c[b+(f<<2)>>2]|0,o)|0;f=wJ(c[b+(f+1<<2)>>2]|0,o)|0;if(f>>>0>>0&g>>>0<(d-f|0)>>>0)f=(a[b+(f+g)>>0]|0)==0?b+f|0:0;else f=0}else f=0;while(0);return f|0}function wJ(a,b){a=a|0;b=b|0;var c=0;c=QN(a|0)|0;return ((b|0)==0?a:c)|0}function xJ(b,c){b=b|0;c=c|0;var d=0,e=0;d=a[b>>0]|0;e=a[c>>0]|0;if(d<<24>>24==0?1:d<<24>>24!=e<<24>>24)b=e;else{do{b=b+1|0;c=c+1|0;d=a[b>>0]|0;e=a[c>>0]|0}while(!(d<<24>>24==0?1:d<<24>>24!=e<<24>>24));b=e}return (d&255)-(b&255)|0}function yJ(a){a=a|0;return sJ(a,c[(zJ()|0)+188>>2]|0)|0}function zJ(){return AJ()|0}function AJ(){return 55800}function BJ(a,b,c){a=+a;b=+b;c=c|0;var d=0.0,e=0.0,f=0.0;f=a*a;d=f*(f*f)*(f*1.58969099521155e-10+-2.5050760253406863e-08)+(f*(f*2.7557313707070068e-06+-1.984126982985795e-04)+.00833333333332249);e=f*a;if(!c)a=e*(f*d+-.16666666666666632)+a;else a=a-(e*.16666666666666632+(f*(b*.5-e*d)-b));return +a}function CJ(a){a=+a;var b=0,d=0,e=0,f=0,g=0.0,i=0.0,k=0.0,l=0.0,m=0.0;h[j>>3]=a;b=c[j>>2]|0;d=c[j+4>>2]|0;e=(d|0)<0;do if(e|d>>>0<1048576){if((b|0)==0&(d&2147483647|0)==0){a=-1.0/(a*a);break}if(e){a=(a-a)/0.0;break}else{h[j>>3]=a*18014398509481984.0;d=c[j+4>>2]|0;e=-1077;b=c[j>>2]|0;f=9;break}}else if(d>>>0<=2146435071)if((b|0)==0&0==0&(d|0)==1072693248)a=0.0;else{e=-1023;f=9}while(0);if((f|0)==9){f=d+614242|0;c[j>>2]=b;c[j+4>>2]=(f&1048575)+1072079006;m=+h[j>>3]+-1.0;k=m*(m*.5);i=m/(m+2.0);l=i*i;g=l*l;h[j>>3]=m-k;d=c[j+4>>2]|0;c[j>>2]=0;c[j+4>>2]=d;a=+h[j>>3];g=m-a-k+i*(k+(g*(g*(g*.15313837699209373+.22222198432149784)+.3999999999940942)+l*(g*(g*(g*.14798198605116586+.1818357216161805)+.2857142874366239)+.6666666666666735)));l=a*1.4426950407214463;k=+(e+(f>>>20)|0);i=l+k;a=i+(l+(k-i)+(g*1.4426950407214463+(g+a)*1.6751713164886512e-10))}return +a}function DJ(a,b){a=+a;b=b|0;var d=0,e=0,f=0;h[j>>3]=a;d=c[j>>2]|0;e=c[j+4>>2]|0;f=NN(d|0,e|0,52)|0;switch(f&2047){case 0:{if(a!=0.0){a=+DJ(a*18446744073709551616.0,b);d=(c[b>>2]|0)+-64|0}else d=0;c[b>>2]=d;break}case 2047:break;default:{c[b>>2]=(f&2047)+-1022;c[j>>2]=d;c[j+4>>2]=e&-2146435073|1071644672;a=+h[j>>3]}}return +a}function EJ(a,b){a=+a;b=+b;var c=0.0,d=0.0,e=0.0,f=0.0;c=a*a;d=c*c;e=c*.5;f=1.0-e;return +(f+(1.0-f-e+(c*(c*(c*(c*2.480158728947673e-05+-.001388888888887411)+.0416666666666666)+d*d*(c*(2.087572321298175e-09-c*1.1359647557788195e-11)+-2.7557314351390663e-07))-a*b)))}function FJ(a){a=+a;var b=0,d=0,e=0,f=0,g=0.0,i=0.0,k=0.0,l=0.0,m=0.0;h[j>>3]=a;b=c[j>>2]|0;d=c[j+4>>2]|0;e=(d|0)<0;do if(e|d>>>0<1048576){if((b|0)==0&(d&2147483647|0)==0){a=-1.0/(a*a);break}if(e){a=(a-a)/0.0;break}else{h[j>>3]=a*18014398509481984.0;d=c[j+4>>2]|0;e=-1077;b=c[j>>2]|0;f=9;break}}else if(d>>>0<=2146435071)if((b|0)==0&0==0&(d|0)==1072693248)a=0.0;else{e=-1023;f=9}while(0);if((f|0)==9){f=d+614242|0;c[j>>2]=b;c[j+4>>2]=(f&1048575)+1072079006;k=+h[j>>3]+-1.0;i=k*(k*.5);l=k/(k+2.0);m=l*l;g=m*m;h[j>>3]=k-i;d=c[j+4>>2]|0;c[j>>2]=0;c[j+4>>2]=d;a=+h[j>>3];g=k-a-i+l*(i+(g*(g*(g*.15313837699209373+.22222198432149784)+.3999999999940942)+m*(g*(g*(g*.14798198605116586+.1818357216161805)+.2857142874366239)+.6666666666666735)));m=a*.4342944818781689;i=+(e+(f>>>20)|0);l=i*.30102999566361177;k=l+m;a=k+(m+(l-k)+(g*.4342944818781689+(i*3.694239077158931e-13+(g+a)*2.5082946711645275e-11)))}return +a}function GJ(a,b){a=+a;b=b|0;var d=0,e=0.0,f=0.0,g=0.0,i=0,k=0.0,m=0,n=0,o=0,p=0,q=0,r=0,s=0.0;r=l;l=l+48|0;m=r+16|0;n=r;h[j>>3]=a;d=c[j>>2]|0;i=c[j+4>>2]|0;o=NN(d|0,i|0,63)|0;q=i&2147483647;do if(q>>>0<1074752123)if((i&1048575|0)!=598523){d=(o|0)!=0;if(q>>>0<1073928573)if(d){g=a+1.5707963267341256;k=g+6.077100506506192e-11;h[b>>3]=k;h[b+8>>3]=g-k+6.077100506506192e-11;d=-1;break}else{g=a+-1.5707963267341256;k=g+-6.077100506506192e-11;h[b>>3]=k;h[b+8>>3]=g-k+-6.077100506506192e-11;d=1;break}else if(d){g=a+3.1415926534682512;k=g+1.2154201013012384e-10;h[b>>3]=k;h[b+8>>3]=g-k+1.2154201013012384e-10;d=-2;break}else{g=a+-3.1415926534682512;k=g+-1.2154201013012384e-10;h[b>>3]=k;h[b+8>>3]=g-k+-1.2154201013012384e-10;d=2;break}}else p=21;else{if(q>>>0<1075594812)if(q>>>0<1075183037){if((q|0)==1074977148){p=21;break}if(!o){g=a+-4.712388980202377;k=g+-1.8231301519518578e-10;h[b>>3]=k;h[b+8>>3]=g-k+-1.8231301519518578e-10;d=3;break}else{g=a+4.712388980202377;k=g+1.8231301519518578e-10;h[b>>3]=k;h[b+8>>3]=g-k+1.8231301519518578e-10;d=-3;break}}else{if((q|0)==1075388923){p=21;break}if(!o){g=a+-6.2831853069365025;k=g+-2.430840202602477e-10;h[b>>3]=k;h[b+8>>3]=g-k+-2.430840202602477e-10;d=4;break}else{g=a+6.2831853069365025;k=g+2.430840202602477e-10;h[b>>3]=k;h[b+8>>3]=g-k+2.430840202602477e-10;d=-4;break}}if(q>>>0>=1094263291){if(q>>>0>2146435071){k=a-a;h[b+8>>3]=k;h[b>>3]=k;d=0;break}c[j>>2]=d;c[j+4>>2]=i&1048575|1096810496;a=+h[j>>3];d=0;do{k=+(~~a|0);h[m+(d<<3)>>3]=k;a=(a-k)*16777216.0;d=d+1|0}while((d|0)!=2);h[m+16>>3]=a;if(a==0.0){d=1;while(1)if(+h[m+(d<<3)>>3]==0.0)d=d+-1|0;else break}else d=2;d=HJ(m,n,(q>>>20)+-1046|0,d+1|0,1)|0;a=+h[n>>3];if(!o){h[b>>3]=a;h[b+8>>3]=+h[n+8>>3];break}else{h[b>>3]=-a;h[b+8>>3]=-+h[n+8>>3];d=0-d|0;break}}else p=21}while(0);if((p|0)==21){g=a*.6366197723675814+6755399441055744.0+-6755399441055744.0;d=~~g;e=a-g*1.5707963267341256;f=g*6.077100506506192e-11;a=e-f;h[b>>3]=a;h[j>>3]=a;p=NN(c[j>>2]|0,c[j+4>>2]|0,52)|0;i=q>>>20;if((i-(p&2047)|0)>16){f=g*6.077100506303966e-11;k=e-f;f=g*2.0222662487959506e-21-(e-k-f);a=k-f;h[b>>3]=a;h[j>>3]=a;q=NN(c[j>>2]|0,c[j+4>>2]|0,52)|0;s=g*2.0222662487111665e-21;e=k-s;g=g*8.4784276603689e-32-(k-e-s);if((i-(q&2047)|0)>49){a=e-g;h[b>>3]=a;f=g}else e=k}h[b+8>>3]=e-a-f}l=r;return d|0}function HJ(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0.0,i=0.0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0.0;H=l;l=l+560|0;C=H+480|0;z=H+320|0;G=H+160|0;E=H;D=c[56044+(f<<2)>>2]|0;p=e+-1|0;y=(d+-3|0)/24|0;y=(y|0)>0?y:0;B=O(y,-24)|0;j=d+-24+B|0;if((D+p|0)>=0){n=D+e|0;k=y-p|0;m=0;while(1){if((k|0)<0)g=0.0;else g=+(c[56060+(k<<2)>>2]|0);h[z+(m<<3)>>3]=g;m=m+1|0;if((m|0)==(n|0))break;else k=k+1|0}}o=(e|0)>0;n=0;while(1){if(o){m=n+p|0;g=0.0;k=0;do{g=g+ +h[a+(k<<3)>>3]*+h[z+(m-k<<3)>>3];k=k+1|0}while((k|0)!=(e|0))}else g=0.0;h[E+(n<<3)>>3]=g;if((n|0)<(D|0))n=n+1|0;else break}t=(j|0)>0;u=24-j|0;v=23-j|0;w=(e|0)>0;x=(j|0)==0;k=D;a:while(1){g=+h[E+(k<<3)>>3];o=(k|0)>0;if(o){m=k;n=0;while(1){i=+(~~(g*5.9604644775390625e-08)|0);c[C+(n<<2)>>2]=~~(g-i*16777216.0);s=m;m=m+-1|0;g=+h[E+(m<<3)>>3]+i;if((s|0)<=1)break;else n=n+1|0}}g=+IJ(g,j);g=g-+A(+(g*.125))*8.0;m=~~g;g=g-+(m|0);do if(!t)if(!x)if(!(g>=.5)){p=0;s=m;break}else{n=2;F=20;break}else{n=c[C+(k+-1<<2)>>2]>>23;F=19;break}else{s=C+(k+-1<<2)|0;n=c[s>>2]|0;F=n>>u;n=n-(F<>2]=n;n=n>>v;m=F+m|0;F=19}while(0);if((F|0)==19){F=0;if((n|0)>0)F=20;else{p=n;s=m}}if((F|0)==20){F=0;s=m+1|0;if(o){m=0;r=0;do{p=C+(r<<2)|0;q=c[p>>2]|0;if(!m)if(!q)m=0;else{m=1;o=16777216;F=23}else{o=16777215;F=23}if((F|0)==23){F=0;c[p>>2]=o-q}r=r+1|0}while((r|0)!=(k|0))}else m=0;b:do if(t){switch(j|0){case 1:{o=8388607;break}case 2:{o=4194303;break}default:break b}r=C+(k+-1<<2)|0;c[r>>2]=c[r>>2]&o}while(0);if((n|0)==2){g=1.0-g;if(!m)p=2;else{p=2;g=g-+IJ(1.0,j)}}else p=n}if(!(g==0.0)){F=42;break}if((k|0)>(D|0)){m=0;n=k;do{n=n+-1|0;m=c[C+(n<<2)>>2]|m}while((n|0)>(D|0));if(m){F=41;break}else m=1}else m=1;while(1)if(!(c[C+(D-m<<2)>>2]|0))m=m+1|0;else break;o=m+k|0;if((m|0)<=0){k=o;continue}while(1){n=k+1|0;m=k+e|0;h[z+(m<<3)>>3]=+(c[56060+(n+y<<2)>>2]|0);if(w){g=0.0;k=0;do{g=g+ +h[a+(k<<3)>>3]*+h[z+(m-k<<3)>>3];k=k+1|0}while((k|0)!=(e|0))}else g=0.0;h[E+(n<<3)>>3]=g;if((n|0)<(o|0))k=n;else{k=o;continue a}}}if((F|0)==41)while(1){F=0;j=j+-24|0;k=k+-1|0;if(!(c[C+(k<<2)>>2]|0))F=41;else{o=k;break}}else if((F|0)==42){g=+IJ(g,0-j|0);if(g>=16777216.0){i=+(~~(g*5.9604644775390625e-08)|0);c[C+(k<<2)>>2]=~~(g-i*16777216.0);j=B+d|0;k=k+1|0;g=i}c[C+(k<<2)>>2]=~~g;o=k}g=+IJ(1.0,j);n=(o|0)>-1;if(n){j=o;while(1){h[E+(j<<3)>>3]=g*+(c[C+(j<<2)>>2]|0);if((j|0)>0){g=g*5.9604644775390625e-08;j=j+-1|0}else break}if(n){k=o;while(1){m=o-k|0;j=0;g=0.0;while(1){g=g+ +h[10840+(j<<3)>>3]*+h[E+(j+k<<3)>>3];if((j|0)>=(D|0)|(j|0)>=(m|0))break;else j=j+1|0}h[G+(m<<3)>>3]=g;if((k|0)>0)k=k+-1|0;else break}}}switch(f|0){case 0:{if(n){g=0.0;j=o;while(1){g=g+ +h[G+(j<<3)>>3];if((j|0)>0)j=j+-1|0;else break}}else g=0.0;i=(p|0)==0?g:-g;F=72;break}case 2:case 1:{if(n){g=0.0;j=o;while(1){g=g+ +h[G+(j<<3)>>3];if((j|0)>0)j=j+-1|0;else break}}else g=0.0;k=(p|0)==0;h[b>>3]=k?g:-g;g=+h[G>>3]-g;if((o|0)>=1){j=1;while(1){g=g+ +h[G+(j<<3)>>3];if((j|0)==(o|0))break;else j=j+1|0}}i=k?g:-g;b=b+8|0;F=72;break}case 3:{if((o|0)>0){j=o;g=+h[G+(o<<3)>>3];do{F=j;j=j+-1|0;E=G+(j<<3)|0;i=+h[E>>3];I=g;g=i+g;h[G+(F<<3)>>3]=I+(i-g);h[E>>3]=g}while((F|0)>1);k=(o|0)>1;if(k){j=o;g=+h[G+(o<<3)>>3];do{F=j;j=j+-1|0;E=G+(j<<3)|0;I=+h[E>>3];i=g;g=I+g;h[G+(F<<3)>>3]=i+(I-g);h[E>>3]=g}while((F|0)>2);if(k){j=o;i=0.0;while(1){i=i+ +h[G+(j<<3)>>3];if((j|0)>2)j=j+-1|0;else break}}else i=0.0}else i=0.0}else i=0.0;g=+h[G>>3];if(!p){h[b>>3]=g;g=+h[G+8>>3]}else{h[b>>3]=-g;i=-i;g=-+h[G+8>>3]}h[b+8>>3]=g;b=b+16|0;F=72;break}default:{}}if((F|0)==72)h[b>>3]=i;l=H;return s&7|0}function IJ(a,b){a=+a;b=b|0;var d=0,e=0;if((b|0)<=1023){if((b|0)<-1022){a=a*2.2250738585072014e-308;e=(b|0)<-2044;d=b+2044|0;a=e?a*2.2250738585072014e-308:a;b=e?((d|0)>-1022?d:-1022):b+1022|0}}else{a=a*8988465674311579538646525.0e283;d=(b|0)>2046;e=b+-2046|0;a=d?a*8988465674311579538646525.0e283:a;b=d?((e|0)<1023?e:1023):b+-1023|0}d=ON(b+1023|0,0,52)|0;e=z;c[j>>2]=d;c[j+4>>2]=e;return +(a*+h[j>>3])}function JJ(a){a=+a;var b=0,d=0,e=0,f=0.0,g=0.0;h[j>>3]=a;d=c[j+4>>2]|0;b=d&2147483647;do if(b>>>0>2146435071)a=a+a;else{if(b>>>0<1048576){h[j>>3]=a*18014398509481984.0;d=c[j+4>>2]|0;b=d&2147483647;if(!b)break;else e=696219795}else e=715094163;c[j>>2]=0;c[j+4>>2]=((b>>>0)/3|0)+e|d&-2147483648;f=+h[j>>3];g=f*f*(f/a);h[j>>3]=(g*(g*g)*(g*.14599619288661245+-.758397934778766)+(g*(g*1.6214297201053545+-1.8849797954337717)+1.87595182427177))*f;d=HN(c[j>>2]|0,c[j+4>>2]|0,-2147483648,0)|0;e=z;c[j>>2]=d&-1073741824;c[j+4>>2]=e;f=+h[j>>3];a=a/(f*f);a=(a-f)/(f+f+a)*f+f}while(0);return +a}function KJ(a,b){a=+a;b=+b;var d=0,e=0;h[j>>3]=a;e=c[j>>2]|0;d=c[j+4>>2]|0;h[j>>3]=b;d=c[j+4>>2]&-2147483648|d&2147483647;c[j>>2]=e;c[j+4>>2]=d;return +(+h[j>>3])}function LJ(a,b){a=+a;b=+b;return +(+KJ(a,b))}function MJ(a,b){a=+a;b=b|0;return +(+IJ(a,b))}function NJ(a,b){a=+a;b=+b;return +(+OJ(a,b))}function OJ(a,b){a=+a;b=+b;var d=0,e=0,f=0,g=0,i=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;h[j>>3]=a;i=c[j>>2]|0;l=c[j+4>>2]|0;h[j>>3]=b;n=c[j>>2]|0;o=c[j+4>>2]|0;e=NN(i|0,l|0,52)|0;e=e&2047;m=NN(n|0,o|0,52)|0;m=m&2047;p=l&-2147483648;g=ON(n|0,o|0,1)|0;k=z;a:do if(!((g|0)==0&(k|0)==0)?(f=PJ(b)|0,d=z&2147483647,!((e|0)==2047|(d>>>0>2146435072|(d|0)==2146435072&f>>>0>0))):0){d=ON(i|0,l|0,1)|0;f=z;if(!(f>>>0>k>>>0|(f|0)==(k|0)&d>>>0>g>>>0))return +((d|0)==(g|0)&(f|0)==(k|0)?a*0.0:a);if(!e){d=ON(i|0,l|0,12)|0;f=z;if((f|0)>-1|(f|0)==-1&d>>>0>4294967295){e=0;do{e=e+-1|0;d=ON(d|0,f|0,1)|0;f=z}while((f|0)>-1|(f|0)==-1&d>>>0>4294967295)}else e=0;i=ON(i|0,l|0,1-e|0)|0;g=z}else g=l&1048575|1048576;if(!m){f=ON(n|0,o|0,12)|0;k=z;if((k|0)>-1|(k|0)==-1&f>>>0>4294967295){d=0;do{d=d+-1|0;f=ON(f|0,k|0,1)|0;k=z}while((k|0)>-1|(k|0)==-1&f>>>0>4294967295)}else d=0;n=ON(n|0,o|0,1-d|0)|0;m=d;l=z}else l=o&1048575|1048576;f=IN(i|0,g|0,n|0,l|0)|0;d=z;k=(d|0)>-1|(d|0)==-1&f>>>0>4294967295;b:do if((e|0)>(m|0)){while(1){if(k){if((f|0)==0&(d|0)==0)break}else{f=i;d=g}i=ON(f|0,d|0,1)|0;g=z;e=e+-1|0;f=IN(i|0,g|0,n|0,l|0)|0;d=z;k=(d|0)>-1|(d|0)==-1&f>>>0>4294967295;if((e|0)<=(m|0))break b}b=a*0.0;break a}while(0);if(k){if((f|0)==0&(d|0)==0){b=a*0.0;break}}else{d=g;f=i}if(d>>>0<1048576|(d|0)==1048576&f>>>0<0)do{f=ON(f|0,d|0,1)|0;d=z;e=e+-1|0}while(d>>>0<1048576|(d|0)==1048576&f>>>0<0);if((e|0)>0){o=HN(f|0,d|0,0,-1048576)|0;d=z;e=ON(e|0,0,52)|0;d=d|z;e=o|e}else{e=NN(f|0,d|0,1-e|0)|0;d=z}c[j>>2]=e;c[j+4>>2]=d|p;b=+h[j>>3]}else q=3;while(0);if((q|0)==3){b=a*b;b=b/b}return +b}function PJ(a){a=+a;var b=0;h[j>>3]=a;b=c[j>>2]|0;z=c[j+4>>2]|0;return b|0}function QJ(a,b){a=+a;b=+b;var d=0.0,e=0,f=0,g=0,i=0,k=0.0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;q=l;l=l+32|0;m=q+24|0;n=q+16|0;o=q+8|0;p=q;h[j>>3]=a;t=c[j>>2]|0;g=c[j+4>>2]|0;h[j>>3]=b;e=c[j>>2]|0;g=g&2147483647;f=c[j+4>>2]&2147483647;i=g>>>0>>0|(g|0)==(f|0)&t>>>0>>0;s=i?e:t;r=i?f:g;e=i?t:e;f=i?g:f;g=NN(s|0,r|0,52)|0;i=NN(e|0,f|0,52)|0;c[j>>2]=s;c[j+4>>2]=r;a=+h[j>>3];c[j>>2]=e;c[j+4>>2]=f;k=+h[j>>3];do if((i|0)!=2047){if(!((e|0)==0&(f|0)==0|(g|0)==2047)){if((g-i|0)>64){a=a+k;break}if((g|0)>1533){d=5260135901548373507240989.0e186;b=a*1.90109156629516e-211;a=k*1.90109156629516e-211}else{t=(i|0)<573;d=t?1.90109156629516e-211:1.0;b=t?a*5260135901548373507240989.0e186:a;a=t?k*5260135901548373507240989.0e186:k}RJ(m,n,b);RJ(o,p,a);a=d*+C(+(+h[p>>3]+ +h[n>>3]+ +h[o>>3]+ +h[m>>3]))}}else a=k;while(0);l=q;return +a}function RJ(a,b,c){a=a|0;b=b|0;c=+c;var d=0.0,e=0.0;e=c*134217729.0;e=e+(c-e);d=c-e;c=c*c;h[a>>3]=c;h[b>>3]=d*d+(e*e-c+e*2.0*d);return}function SJ(a,b,d){a=+a;b=b|0;d=d|0;var e=0.0,f=0,g=0,i=0.0,k=0,m=0;k=l;l=l+16|0;g=k;h[j>>3]=a;f=c[j+4>>2]&2147483647;do if(f>>>0<1072243196)if(f>>>0<1044816030){h[b>>3]=a;h[d>>3]=1.0;break}else{h[b>>3]=+BJ(a,0.0,0);h[d>>3]=+EJ(a,0.0);break}else{if(f>>>0>2146435071){i=a-a;h[d>>3]=i;h[b>>3]=i;break}f=GJ(a,g)|0;m=g+8|0;e=+BJ(+h[g>>3],+h[m>>3],1);a=+EJ(+h[g>>3],+h[m>>3]);switch(f&3){case 0:{h[b>>3]=e;i=a;break}case 1:{h[b>>3]=a;i=-e;break}case 2:{h[b>>3]=-e;i=-a;break}case 3:{h[b>>3]=-a;i=e;break}default:{}}h[d>>3]=i}while(0);l=k;return}function TJ(a,b){a=+a;b=b|0;return +(+DJ(a,b))}function UJ(a){a=a|0;if(a>>>0<131072)a=(d[127725+((d[127725+(a>>>8)>>0]|0)<<5|a>>>3&31)>>0]|0)>>>(a&7)&1;else a=0;return a|0}function VJ(b,c,e){b=b|0;c=c|0;e=e|0;var f=0,g=0;if(!e)f=0;else{f=a[b>>0]|0;a:do if(!(f<<24>>24))f=0;else while(1){e=e+-1|0;g=a[c>>0]|0;if(!(f<<24>>24==g<<24>>24&((e|0)!=0&g<<24>>24!=0)))break a;b=b+1|0;c=c+1|0;f=a[b>>0]|0;if(!(f<<24>>24)){f=0;break}}while(0);f=(f&255)-(d[c>>0]|0)|0}return f|0}function WJ(b,c){b=b|0;c=c|0;b=qJ(b,c)|0;return ((a[b>>0]|0)==(c&255)<<24>>24?b:0)|0}function XJ(a){a=a|0;return ((a|0)==32|(a+-9|0)>>>0<5)&1|0}function YJ(a,b,c){a=a|0;b=b|0;c=c|0;c=$J(a,b,c,-1,0)|0;return c|0}function ZJ(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;h=d&255;f=(e|0)!=0;a:do if(f&(b&3|0)!=0){g=d&255;while(1){if((a[b>>0]|0)==g<<24>>24){i=6;break a}b=b+1|0;e=e+-1|0;f=(e|0)!=0;if(!(f&(b&3|0)!=0)){i=5;break}}}else i=5;while(0);if((i|0)==5)if(f)i=6;else e=0;b:do if((i|0)==6){g=d&255;if((a[b>>0]|0)!=g<<24>>24){f=O(h,16843009)|0;c:do if(e>>>0>3)while(1){h=c[b>>2]^f;if((h&-2139062144^-2139062144)&h+-16843009|0)break;b=b+4|0;e=e+-4|0;if(e>>>0<=3){i=11;break c}}else i=11;while(0);if((i|0)==11)if(!e){e=0;break}while(1){if((a[b>>0]|0)==g<<24>>24)break b;b=b+1|0;e=e+-1|0;if(!e){e=0;break}}}}while(0);return (e|0?b:0)|0}function _J(a){a=a|0;return (a+-48|0)>>>0<10|0}function $J(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0;j=l;l=l+128|0;h=j;c[h>>2]=0;i=h+4|0;c[i>>2]=a;c[h+44>>2]=a;g=h+8|0;c[g>>2]=(a|0)<0?-1:a+2147483647|0;c[h+76>>2]=-1;aK(h,0);d=bK(h,d,1,e,f)|0;if(b|0)c[b>>2]=a+((c[i>>2]|0)+(c[h+108>>2]|0)-(c[g>>2]|0));l=j;return d|0}function aK(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;c[a+104>>2]=b;d=c[a+8>>2]|0;e=c[a+4>>2]|0;f=d-e|0;c[a+108>>2]=f;c[a+100>>2]=(b|0)!=0&(f|0)>(b|0)?e+b|0:d;return}function bK(b,e,f,g,h){b=b|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;a:do if(e>>>0>36){c[(jJ()|0)>>2]=22;h=0;g=0}else{r=b+4|0;q=b+100|0;do{i=c[r>>2]|0;if(i>>>0<(c[q>>2]|0)>>>0){c[r>>2]=i+1;i=d[i>>0]|0}else i=cK(b)|0}while((XJ(i)|0)!=0);b:do switch(i|0){case 43:case 45:{i=((i|0)==45)<<31>>31;j=c[r>>2]|0;if(j>>>0<(c[q>>2]|0)>>>0){c[r>>2]=j+1;p=i;i=d[j>>0]|0;break b}else{p=i;i=cK(b)|0;break b}}default:p=0}while(0);j=(e|0)==0;do if((e|16|0)==16&(i|0)==48){i=c[r>>2]|0;if(i>>>0<(c[q>>2]|0)>>>0){c[r>>2]=i+1;i=d[i>>0]|0}else i=cK(b)|0;if((i|32|0)!=120)if(j){e=8;n=46;break}else{n=32;break}i=c[r>>2]|0;if(i>>>0<(c[q>>2]|0)>>>0){c[r>>2]=i+1;i=d[i>>0]|0}else i=cK(b)|0;if((d[130894+i>>0]|0)>15){g=(c[q>>2]|0)==0;if(!g)c[r>>2]=(c[r>>2]|0)+-1;if(!f){aK(b,0);h=0;g=0;break a}if(g){h=0;g=0;break a}c[r>>2]=(c[r>>2]|0)+-1;h=0;g=0;break a}else{e=16;n=46}}else{e=j?10:e;if(e>>>0>(d[130894+i>>0]|0)>>>0)n=32;else{if(c[q>>2]|0)c[r>>2]=(c[r>>2]|0)+-1;aK(b,0);c[(jJ()|0)>>2]=22;h=0;g=0;break a}}while(0);c:do if((n|0)==32)if((e|0)==10){e=i+-48|0;if(e>>>0<10){i=0;j=e;do{i=(i*10|0)+j|0;e=c[r>>2]|0;if(e>>>0<(c[q>>2]|0)>>>0){c[r>>2]=e+1;e=d[e>>0]|0}else e=cK(b)|0;j=e+-48|0}while(j>>>0<10&i>>>0<429496729);f=0}else{e=i;i=0;f=0}k=e+-48|0;if(k>>>0<10){j=e;do{e=GN(i|0,f|0,10,0)|0;l=z;m=((k|0)<0)<<31>>31;o=~m;if(l>>>0>o>>>0|(l|0)==(o|0)&e>>>0>~k>>>0){e=10;n=72;break c}i=HN(e|0,l|0,k|0,m|0)|0;f=z;e=c[r>>2]|0;if(e>>>0<(c[q>>2]|0)>>>0){c[r>>2]=e+1;j=d[e>>0]|0}else j=cK(b)|0;k=j+-48|0}while(k>>>0<10&(f>>>0<429496729|(f|0)==429496729&i>>>0<2576980378));if(k>>>0>9){j=p;e=f}else{e=10;n=72}}else{j=p;e=f}}else n=46;while(0);d:do if((n|0)==46){if(!(e+-1&e)){n=a[131150+((e*23|0)>>>5&7)>>0]|0;f=a[130894+i>>0]|0;j=f&255;if(e>>>0>j>>>0){i=0;k=j;do{i=k|i<>2]|0;if(j>>>0<(c[q>>2]|0)>>>0){c[r>>2]=j+1;j=d[j>>0]|0}else j=cK(b)|0;f=a[130894+j>>0]|0;k=f&255}while(i>>>0<134217728&e>>>0>k>>>0);k=0}else{j=i;k=0;i=0}l=NN(-1,-1,n|0)|0;m=z;if(e>>>0<=(f&255)>>>0|(m>>>0>>0|(m|0)==(k|0)&l>>>0>>0)){f=k;n=72;break}else j=k;while(1){i=ON(i|0,j|0,n|0)|0;k=z;i=i|f&255;j=c[r>>2]|0;if(j>>>0<(c[q>>2]|0)>>>0){c[r>>2]=j+1;j=d[j>>0]|0}else j=cK(b)|0;f=a[130894+j>>0]|0;if(e>>>0<=(f&255)>>>0|(k>>>0>m>>>0|(k|0)==(m|0)&i>>>0>l>>>0)){f=k;n=72;break d}else j=k}}f=a[130894+i>>0]|0;j=f&255;if(e>>>0>j>>>0){i=0;k=j;do{i=k+(O(i,e)|0)|0;j=c[r>>2]|0;if(j>>>0<(c[q>>2]|0)>>>0){c[r>>2]=j+1;j=d[j>>0]|0}else j=cK(b)|0;f=a[130894+j>>0]|0;k=f&255}while(i>>>0<119304647&e>>>0>k>>>0);k=0}else{j=i;i=0;k=0}if(e>>>0>(f&255)>>>0){n=LN(-1,-1,e|0,0)|0;o=z;m=k;while(1){if(m>>>0>o>>>0|(m|0)==(o|0)&i>>>0>n>>>0){f=m;n=72;break d}k=GN(i|0,m|0,e|0,0)|0;l=z;f=f&255;if(l>>>0>4294967295|(l|0)==-1&k>>>0>~f>>>0){f=m;n=72;break d}i=HN(k|0,l|0,f|0,0)|0;k=z;j=c[r>>2]|0;if(j>>>0<(c[q>>2]|0)>>>0){c[r>>2]=j+1;j=d[j>>0]|0}else j=cK(b)|0;f=a[130894+j>>0]|0;if(e>>>0<=(f&255)>>>0){f=k;n=72;break}else m=k}}else{f=k;n=72}}while(0);if((n|0)==72)if(e>>>0>(d[130894+j>>0]|0)>>>0){do{i=c[r>>2]|0;if(i>>>0<(c[q>>2]|0)>>>0){c[r>>2]=i+1;i=d[i>>0]|0}else i=cK(b)|0}while(e>>>0>(d[130894+i>>0]|0)>>>0);c[(jJ()|0)>>2]=34;j=(g&1|0)==0&0==0?p:0;e=h;i=g}else{j=p;e=f}if(c[q>>2]|0)c[r>>2]=(c[r>>2]|0)+-1;if(!(e>>>0>>0|(e|0)==(h|0)&i>>>0>>0)){if(!((g&1|0)!=0|0!=0|(j|0)!=0)){c[(jJ()|0)>>2]=34;g=HN(g|0,h|0,-1,-1)|0;h=z;break}if(e>>>0>h>>>0|(e|0)==(h|0)&i>>>0>g>>>0){c[(jJ()|0)>>2]=34;break}}g=((j|0)<0)<<31>>31;g=IN(i^j|0,e^g|0,j|0,g|0)|0;h=z}while(0);z=h;return g|0}function cK(b){b=b|0;var e=0,f=0,g=0,h=0,i=0,j=0;f=b+104|0;h=c[f>>2]|0;if((h|0)!=0?(c[b+108>>2]|0)>=(h|0):0)i=4;else{e=dK(b)|0;if((e|0)>=0){g=c[f>>2]|0;f=b+8|0;if(g){j=c[f>>2]|0;h=c[b+4>>2]|0;f=g-(c[b+108>>2]|0)|0;g=j;if((j-h|0)<(f|0))f=g;else f=h+(f+-1)|0}else{g=c[f>>2]|0;f=g}c[b+100>>2]=f;f=b+4|0;if(!g)f=c[f>>2]|0;else{f=c[f>>2]|0;j=b+108|0;c[j>>2]=g+1-f+(c[j>>2]|0)}f=f+-1|0;if((e|0)!=(d[f>>0]|0|0))a[f>>0]=e}else i=4}if((i|0)==4){c[b+100>>2]=0;e=-1}return e|0}function dK(a){a=a|0;var b=0,e=0;e=l;l=l+16|0;b=e;if((eK(a)|0)==0?(bb[c[a+32>>2]&31](a,b,1)|0)==1:0)a=d[b>>0]|0;else a=-1;l=e;return a|0}function eK(b){b=b|0;var d=0,e=0;d=b+74|0;e=a[d>>0]|0;a[d>>0]=e+255|e;d=b+20|0;e=b+28|0;if((c[d>>2]|0)>>>0>(c[e>>2]|0)>>>0)bb[c[b+36>>2]&31](b,0,0)|0;c[b+16>>2]=0;c[e>>2]=0;c[d>>2]=0;d=c[b>>2]|0;if(!(d&4)){e=(c[b+44>>2]|0)+(c[b+48>>2]|0)|0;c[b+8>>2]=e;c[b+4>>2]=e;d=d<<27>>31}else{c[b>>2]=d|32;d=-1}return d|0}function fK(a){a=a|0;return (a+-48|0)>>>0<10|0}function gK(a){a=a|0;if(!(hK(a)|0))a=(_J(a)|0)!=0&1;else a=1;return a|0}function hK(a){a=a|0;return ((a|32)+-97|0)>>>0<26|0}function iK(b,c){b=b|0;c=c|0;var e=0,f=0,g=0;e=a[b>>0]|0;a:do if(!(e<<24>>24))b=0;else{g=b;b=e;f=e&255;while(1){e=a[c>>0]|0;if(!(e<<24>>24))break a;if(b<<24>>24!=e<<24>>24?(f=jK(f)|0,(f|0)!=(jK(d[c>>0]|0)|0)):0)break;b=g+1|0;c=c+1|0;e=a[b>>0]|0;if(!(e<<24>>24)){b=0;break a}else{g=b;b=e;f=e&255}}b=a[g>>0]|0}while(0);g=jK(b&255)|0;return g-(jK(d[c>>0]|0)|0)|0}function jK(a){a=a|0;var b=0;b=(kK(a)|0)==0;return (b?a:a|32)|0}function kK(a){a=a|0;return (a+-65|0)>>>0<26|0}function lK(a){a=a|0;return mK(a,0)|0}function mK(c,f){c=c|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0;k=(f<<1)+-1|0;l=f+-1|0;a:do if(!((c+-43008|0)>>>0<22272|((c+-11776|0)>>>0<30784|((c+-1536|0)>>>0<2560|(nK(c)|0)==0)))){g=(f|0)!=0;if(g&(c+-4256|0)>>>0<46){if((c|0)>4293)switch(c|0){case 4295:case 4301:break;default:break a}c=c+7264|0;break}if((c+-11520|0)>>>0<38&(g^1)){c=c+-7264|0;break}else g=0;do{i=a[59170+(g<<2)+2>>0]|0;j=i<<24>>24;h=c-(e[59170+(g<<2)>>1]|0)|0;if((h-(l&j)|0)>>>0<(d[59170+(g<<2)+3>>0]|0)>>>0){m=11;break}g=g+1|0}while((g|0)!=61);if((m|0)==11)if(i<<24>>24==1){c=f+c-(h&1)|0;break}else{c=(O(k,j)|0)+c|0;break}i=1-f|0;g=b[58682+(i<<1)>>1]|0;b:do if(g<<16>>16){h=0;while(1){if((g&65535|0)==(c|0))break;h=h+1|0;g=b[58682+(h<<2)+(i<<1)>>1]|0;if(!(g<<16>>16))break b}c=e[58682+(h<<2)+(f<<1)>>1]|0;break a}while(0);return ((c+-66600+(f*40|0)|0)>>>0<40?c+-40+(f*80|0)|0:c)|0}while(0);return c|0}function nK(a){a=a|0;if(a>>>0<131072)a=(d[131159+((d[131159+(a>>>8)>>0]|0)<<5|a>>>3&31)>>0]|0)>>>(a&7)&1;else a=a>>>0<196606&1;return a|0}function oK(a){a=a|0;var b=0;b=a;while(1)if(!(c[b>>2]|0))break;else b=b+4|0;return b-a>>2|0}function pK(b,c,e){b=b|0;c=c|0;e=e|0;var f=0,g=0,h=0;if(!e)b=0;else{f=a[b>>0]|0;a:do if(!(f<<24>>24))b=0;else{h=b;b=f;f=f&255;while(1){e=e+-1|0;g=a[c>>0]|0;if(!((e|0)!=0&g<<24>>24!=0))break a;if(b<<24>>24!=g<<24>>24?(g=jK(f)|0,(g|0)!=(jK(d[c>>0]|0)|0)):0)break;b=h+1|0;c=c+1|0;f=a[b>>0]|0;if(!(f<<24>>24)){b=0;break a}else{h=b;b=f;f=f&255}}b=a[h>>0]|0}while(0);b=jK(b&255)|0;b=b-(jK(d[c>>0]|0)|0)|0}return b|0}function qK(a){a=a|0;if(a>>>0>=255)if((a+-57344|0)>>>0<8185|(a>>>0<8232|(a+-8234|0)>>>0<47062))a=1;else return (a&65534|0)!=65534&(a+-65532|0)>>>0<1048580&1|0;else a=(a+1&127)>>>0>32&1;return a|0}function rK(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,m=0;k=l;l=l+16|0;g=k;i=(f|0)==0?170764:f;f=c[i>>2]|0;a:do if(!d)if(!f)f=0;else j=17;else{h=(b|0)==0?g:b;if(!e)f=-2;else{if(!f){f=a[d>>0]|0;if(f<<24>>24>-1){c[h>>2]=f&255;f=f<<24>>24!=0&1;break}g=(c[c[(vK()|0)+188>>2]>>2]|0)==0;f=a[d>>0]|0;if(g){c[h>>2]=f<<24>>24&57343;f=1;break}f=(f&255)+-194|0;if(f>>>0>50){j=17;break}f=c[55208+(f<<2)>>2]|0;g=e+-1|0;if(g){d=d+1|0;j=11}}else{g=e;j=11}b:do if((j|0)==11){b=a[d>>0]|0;m=(b&255)>>>3;if((m+-16|m+(f>>26))>>>0>7){j=17;break a}while(1){d=d+1|0;f=(b&255)+-128|f<<6;g=g+-1|0;if((f|0)>=0)break;if(!g)break b;b=a[d>>0]|0;if((b&-64)<<24>>24!=-128){j=17;break a}}c[i>>2]=0;c[h>>2]=f;f=e-g|0;break a}while(0);c[i>>2]=f;f=-2}}while(0);if((j|0)==17){c[i>>2]=0;c[(jJ()|0)>>2]=84;f=-1}l=k;return f|0}function sK(a,b){a=a|0;b=b|0;if(!a)a=0;else a=tK(a,b,0)|0;return a|0}function tK(b,d,e){b=b|0;d=d|0;e=e|0;do if(b){if(d>>>0<128){a[b>>0]=d;b=1;break}if(!(c[c[(uK()|0)+188>>2]>>2]|0))if((d&-128|0)==57216){a[b>>0]=d;b=1;break}else{c[(jJ()|0)>>2]=84;b=-1;break}if(d>>>0<2048){a[b>>0]=d>>>6|192;a[b+1>>0]=d&63|128;b=2;break}if(d>>>0<55296|(d&-8192|0)==57344){a[b>>0]=d>>>12|224;a[b+1>>0]=d>>>6&63|128;a[b+2>>0]=d&63|128;b=3;break}if((d+-65536|0)>>>0<1048576){a[b>>0]=d>>>18|240;a[b+1>>0]=d>>>12&63|128;a[b+2>>0]=d>>>6&63|128;a[b+3>>0]=d&63|128;b=4;break}else{c[(jJ()|0)>>2]=84;b=-1;break}}else b=1;while(0);return b|0}function uK(){return AJ()|0}function vK(){return AJ()|0}function wK(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0;p=l;l=l+272|0;n=p+8|0;o=p;do if(!(a[d>>0]|0)){d=Na(134135)|0;if(d|0?a[d>>0]|0:0)break;d=Na(134142+(b*12|0)|0)|0;if(d|0?a[d>>0]|0:0)break;d=Na(134214)|0;if(d|0?a[d>>0]|0:0)break;d=134219}while(0);e=0;a:do{switch(a[d+e>>0]|0){case 47:case 0:break a;default:{}}e=e+1|0}while(e>>>0<15);f=a[d>>0]|0;if(f<<24>>24!=46?(a[d+e>>0]|0)==0:0)if(f<<24>>24==67)m=15;else{k=d;m=16}else{d=134219;m=15}if((m|0)==15)if(!(a[d+1>>0]|0))m=18;else{k=d;m=16}b:do if((m|0)==16)if((xJ(k,134219)|0)!=0?(xJ(k,134227)|0)!=0:0){d=c[42692]|0;if(d|0)do{if(!(xJ(k,d+8|0)|0))break b;d=c[d+24>>2]|0}while((d|0)!=0);pa(170772);d=c[42692]|0;c:do if(d|0){while(1){if(!(xJ(k,d+8|0)|0))break;d=c[d+24>>2]|0;if(!d)break c}Fa(170772);break b}while(0);d:do if(((c[42677]|0)==0?(g=Na(134233)|0,(g|0)!=0):0)?(a[g>>0]|0)!=0:0){i=254-e|0;j=e+1|0;f=g;while(1){h=qJ(f,58)|0;d=a[h>>0]|0;g=h-f+((d<<24>>24!=0)<<31>>31)|0;if(g>>>0>>0){TN(n|0,f|0,g|0)|0;f=n+g|0;a[f>>0]=47;TN(f+1|0,k|0,e|0)|0;a[n+(j+g)>>0]=0;f=qa(n|0,o|0)|0;if(f|0)break;d=a[h>>0]|0}f=h+(d<<24>>24!=0&1)|0;if(!(a[f>>0]|0)){m=41;break d}}d=ZI(28)|0;if(!d){nJ(f,c[o>>2]|0)|0;m=41;break}else{c[d>>2]=f;c[d+4>>2]=c[o>>2];o=d+8|0;TN(o|0,k|0,e|0)|0;a[o+e>>0]=0;c[d+24>>2]=c[42692];c[42692]=d;break}}else m=41;while(0);if((m|0)==41){d=ZI(28)|0;if(d){c[d>>2]=c[13790];c[d+4>>2]=c[13791];o=d+8|0;TN(o|0,k|0,e|0)|0;a[o+e>>0]=0;c[d+24>>2]=c[42692];c[42692]=d}}Fa(170772);d=(b|0)==0&(d|0)==0?55160:d}else{d=k;m=18}while(0);do if((m|0)==18){if((b|0)==0?(a[d+1>>0]|0)==46:0){d=55160;break}d=0}while(0);l=p;return d|0}function xK(a,b){a=a|0;b=b|0;yK(a,b)|0;return a|0}function yK(b,d){b=b|0;d=d|0;var e=0,f=0;e=d;a:do if(!((e^b)&3)){if(e&3)do{e=a[d>>0]|0;a[b>>0]=e;if(!(e<<24>>24))break a;d=d+1|0;b=b+1|0}while((d&3|0)!=0);e=c[d>>2]|0;if(!((e&-2139062144^-2139062144)&e+-16843009)){f=b;while(1){d=d+4|0;b=f+4|0;c[f>>2]=e;e=c[d>>2]|0;if((e&-2139062144^-2139062144)&e+-16843009|0)break;else f=b}}f=8}else f=8;while(0);if((f|0)==8){f=a[d>>0]|0;a[b>>0]=f;if(f<<24>>24)do{d=d+1|0;b=b+1|0;f=a[d>>0]|0;a[b>>0]=f}while(f<<24>>24!=0)}return b|0}function zK(a){a=a|0;return ((a|0)==32|(a|0)==9)&1|0}function AK(a){a=a|0;if(!a)a=0;else a=(BK(56324,a)|0)!=0&1;return a|0}function BK(a,b){a=a|0;b=b|0;var d=0;if(!b)a=a+((oK(a)|0)<<2)|0;else{while(1){d=c[a>>2]|0;if((d|0)==0|(d|0)==(b|0))break;else a=a+4|0}a=d|0?a:0}return a|0}function CK(a,b){a=a|0;b=b|0;do switch(b|0){case 1:{a=DK(a)|0;break}case 2:{a=nK(a)|0;break}case 3:{a=EK(a)|0;break}case 4:{a=FK(a)|0;break}case 5:{a=fK(a)|0;break}case 6:{a=GK(a)|0;break}case 7:{a=HK(a)|0;break}case 8:{a=qK(a)|0;break}case 9:{a=UJ(a)|0;break}case 10:{a=AK(a)|0;break}case 11:{a=IK(a)|0;break}case 12:{a=JK(a)|0;break}default:a=0}while(0);return a|0}function DK(a){a=a|0;if(!(fK(a)|0))a=(nK(a)|0)!=0&1;else a=1;return a|0}function EK(a){a=a|0;return zK(a)|0}function FK(a){a=a|0;return ((a+-65529|0)>>>0<3|((a&-2|0)==8232|(a>>>0<32|(a+-127|0)>>>0<33)))&1|0}function GK(a){a=a|0;if(!(AK(a)|0))a=(qK(a)|0)!=0&1;else a=0;return a|0}function HK(a){a=a|0;return (lK(a)|0)!=(a|0)|0}function IK(a){a=a|0;return (KK(a)|0)!=(a|0)|0}function JK(a){a=a|0;return ((a+-48|0)>>>0<10|((a|32)+-97|0)>>>0<6)&1|0}function KK(a){a=a|0;return mK(a,1)|0}function LK(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,m=0,n=0;n=l;l=l+128|0;g=n+124|0;m=n;h=m;i=56412;j=h+124|0;do{c[h>>2]=c[i>>2];h=h+4|0;i=i+4|0}while((h|0)<(j|0));if((d+-1|0)>>>0>2147483646)if(!d){b=g;d=1;k=4}else{c[(jJ()|0)>>2]=75;d=-1}else k=4;if((k|0)==4){k=-2-b|0;k=d>>>0>k>>>0?k:d;c[m+48>>2]=k;g=m+20|0;c[g>>2]=b;c[m+44>>2]=b;d=b+k|0;b=m+16|0;c[b>>2]=d;c[m+28>>2]=d;d=MK(m,e,f)|0;if(k){m=c[g>>2]|0;a[m+(((m|0)==(c[b>>2]|0))<<31>>31)>>0]=0}}l=n;return d|0}function MK(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;s=l;l=l+224|0;n=s+120|0;p=s+80|0;q=s;r=s+136|0;f=p;g=f+40|0;do{c[f>>2]=0;f=f+4|0}while((f|0)<(g|0));c[n>>2]=c[e>>2];if((NK(0,d,n,q,p)|0)<0)e=-1;else{if((c[b+76>>2]|0)>-1)o=OK(b)|0;else o=0;e=c[b>>2]|0;m=e&32;if((a[b+74>>0]|0)<1)c[b>>2]=e&-33;f=b+48|0;if(!(c[f>>2]|0)){g=b+44|0;h=c[g>>2]|0;c[g>>2]=r;i=b+28|0;c[i>>2]=r;j=b+20|0;c[j>>2]=r;c[f>>2]=80;k=b+16|0;c[k>>2]=r+80;e=NK(b,d,n,q,p)|0;if(h){bb[c[b+36>>2]&31](b,0,0)|0;e=(c[j>>2]|0)==0?-1:e;c[g>>2]=h;c[f>>2]=0;c[k>>2]=0;c[i>>2]=0;c[j>>2]=0}}else e=NK(b,d,n,q,p)|0;f=c[b>>2]|0;c[b>>2]=f|m;if(o|0)PK(b);e=(f&32|0)==0?e:-1}l=s;return e|0}function NK(d,e,f,g,i){d=d|0;e=e|0;f=f|0;g=g|0;i=i|0;var j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0;I=l;l=l+64|0;D=I+16|0;E=I;A=I+24|0;G=I+8|0;H=I+20|0;c[D>>2]=e;w=(d|0)!=0;x=A+40|0;y=x;A=A+39|0;B=G+4|0;j=0;e=0;m=0;a:while(1){do if((e|0)>-1)if((j|0)>(2147483647-e|0)){c[(jJ()|0)>>2]=75;e=-1;break}else{e=j+e|0;break}while(0);r=c[D>>2]|0;j=a[r>>0]|0;if(!(j<<24>>24)){v=88;break}else k=r;b:while(1){switch(j<<24>>24){case 37:{j=k;v=9;break b}case 0:{j=k;break b}default:{}}u=k+1|0;c[D>>2]=u;j=a[u>>0]|0;k=u}c:do if((v|0)==9)while(1){v=0;if((a[k+1>>0]|0)!=37)break c;j=j+1|0;k=k+2|0;c[D>>2]=k;if((a[k>>0]|0)!=37)break;else v=9}while(0);j=j-r|0;if(w)QK(d,r,j);if(j|0)continue;u=(_J(a[(c[D>>2]|0)+1>>0]|0)|0)==0;k=c[D>>2]|0;if(!u?(a[k+2>>0]|0)==36:0){s=(a[k+1>>0]|0)+-48|0;n=1;j=3}else{s=-1;n=m;j=1}j=k+j|0;c[D>>2]=j;k=a[j>>0]|0;u=(k<<24>>24)+-32|0;if(u>>>0>31|(1<>24)+-32|m;j=j+1|0;c[D>>2]=j;k=a[j>>0]|0;u=(k<<24>>24)+-32|0}while(!(u>>>0>31|(1<>24==42){if((_J(a[j+1>>0]|0)|0)!=0?(F=c[D>>2]|0,(a[F+2>>0]|0)==36):0){j=F+1|0;c[i+((a[j>>0]|0)+-48<<2)>>2]=10;j=c[g+((a[j>>0]|0)+-48<<3)>>2]|0;k=1;n=F+3|0}else{if(n|0){e=-1;break}if(w){u=(c[f>>2]|0)+(4-1)&~(4-1);j=c[u>>2]|0;c[f>>2]=u+4}else j=0;k=0;n=(c[D>>2]|0)+1|0}c[D>>2]=n;t=(j|0)<0;u=t?0-j|0:j;m=t?m|8192:m;t=k;j=n}else{j=RK(D)|0;if((j|0)<0){e=-1;break}u=j;t=n;j=c[D>>2]|0}do if((a[j>>0]|0)==46){if((a[j+1>>0]|0)!=42){c[D>>2]=j+1;p=RK(D)|0;j=c[D>>2]|0;break}if(_J(a[j+2>>0]|0)|0?(C=c[D>>2]|0,(a[C+3>>0]|0)==36):0){p=C+2|0;c[i+((a[p>>0]|0)+-48<<2)>>2]=10;p=c[g+((a[p>>0]|0)+-48<<3)>>2]|0;j=C+4|0;c[D>>2]=j;break}if(t|0){e=-1;break a}if(w){q=(c[f>>2]|0)+(4-1)&~(4-1);j=c[q>>2]|0;c[f>>2]=q+4}else j=0;q=(c[D>>2]|0)+2|0;c[D>>2]=q;p=j;j=q}else p=-1;while(0);q=0;while(1){if(((a[j>>0]|0)+-65|0)>>>0>57){e=-1;break a}k=j;j=j+1|0;c[D>>2]=j;k=a[(a[k>>0]|0)+-65+(134246+(q*58|0))>>0]|0;n=k&255;if((n+-1|0)>>>0>=8)break;else q=n}if(!(k<<24>>24)){e=-1;break}o=(s|0)>-1;do if(k<<24>>24==19)if(o){e=-1;break a}else v=50;else{if(o){c[i+(s<<2)>>2]=n;o=g+(s<<3)|0;s=c[o+4>>2]|0;v=E;c[v>>2]=c[o>>2];c[v+4>>2]=s;v=50;break}if(!w){e=0;break a}SK(E,n,f);j=c[D>>2]|0}while(0);if((v|0)==50){v=0;if(!w){j=0;m=t;continue}}k=a[j+-1>>0]|0;k=(q|0)!=0&(k&15|0)==3?k&-33:k;j=m&-65537;s=(m&8192|0)==0?m:j;d:do switch(k|0){case 110:switch((q&255)<<24>>24){case 0:{c[c[E>>2]>>2]=e;j=0;m=t;continue a}case 1:{c[c[E>>2]>>2]=e;j=0;m=t;continue a}case 2:{j=c[E>>2]|0;c[j>>2]=e;c[j+4>>2]=((e|0)<0)<<31>>31;j=0;m=t;continue a}case 3:{b[c[E>>2]>>1]=e;j=0;m=t;continue a}case 4:{a[c[E>>2]>>0]=e;j=0;m=t;continue a}case 6:{c[c[E>>2]>>2]=e;j=0;m=t;continue a}case 7:{j=c[E>>2]|0;c[j>>2]=e;c[j+4>>2]=((e|0)<0)<<31>>31;j=0;m=t;continue a}default:{j=0;m=t;continue a}}case 112:{k=120;j=p>>>0>8?p:8;m=s|8;v=62;break}case 88:case 120:{j=p;m=s;v=62;break}case 111:{k=E;j=c[k>>2]|0;k=c[k+4>>2]|0;o=UK(j,k,x)|0;m=y-o|0;q=0;n=134710;p=(s&8|0)==0|(p|0)>(m|0)?p:m+1|0;m=s;v=68;break}case 105:case 100:{k=E;j=c[k>>2]|0;k=c[k+4>>2]|0;if((k|0)<0){j=IN(0,0,j|0,k|0)|0;k=z;m=E;c[m>>2]=j;c[m+4>>2]=k;m=1;n=134710;v=67;break d}else{m=(s&2049|0)!=0&1;n=(s&2048|0)==0?((s&1|0)==0?134710:134712):134711;v=67;break d}}case 117:{k=E;m=0;n=134710;j=c[k>>2]|0;k=c[k+4>>2]|0;v=67;break}case 99:{a[A>>0]=c[E>>2];r=A;q=0;n=134710;o=x;k=1;break}case 109:{k=yJ(c[(jJ()|0)>>2]|0)|0;v=72;break}case 115:{k=c[E>>2]|0;k=k|0?k:134720;v=72;break}case 67:{c[G>>2]=c[E>>2];c[B>>2]=0;c[E>>2]=G;p=-1;m=G;v=76;break}case 83:{j=c[E>>2]|0;if(!p){WK(d,32,u,0,s);j=0;v=85}else{m=j;v=76}break}case 65:case 71:case 70:case 69:case 97:case 103:case 102:case 101:{j=XK(d,+h[E>>3],u,p,s,k)|0;m=t;continue a}default:{q=0;n=134710;o=x;k=p;j=s}}while(0);e:do if((v|0)==62){s=E;r=c[s>>2]|0;s=c[s+4>>2]|0;o=TK(r,s,x,k&32)|0;n=(m&8|0)==0|(r|0)==0&(s|0)==0;q=n?0:2;n=n?134710:134710+(k>>4)|0;p=j;j=r;k=s;v=68}else if((v|0)==67){o=VK(j,k,x)|0;q=m;m=s;v=68}else if((v|0)==72){v=0;s=ZJ(k,0,p)|0;m=(s|0)==0;r=k;q=0;n=134710;o=m?k+p|0:s;k=m?p:s-k|0}else if((v|0)==76){v=0;o=m;j=0;k=0;while(1){n=c[o>>2]|0;if(!n)break;k=sK(H,n)|0;if((k|0)<0|k>>>0>(p-j|0)>>>0)break;j=k+j|0;if(p>>>0>j>>>0)o=o+4|0;else break}if((k|0)<0){e=-1;break a}WK(d,32,u,j,s);if(!j){j=0;v=85}else{n=0;while(1){k=c[m>>2]|0;if(!k){v=85;break e}k=sK(H,k)|0;n=k+n|0;if((n|0)>(j|0)){v=85;break e}QK(d,H,k);if(n>>>0>=j>>>0){v=85;break}else m=m+4|0}}}while(0);if((v|0)==68){v=0;k=(j|0)!=0|(k|0)!=0;j=(p|0)!=0|k;k=y-o+((k^1)&1)|0;r=j?o:x;o=x;k=j?((p|0)>(k|0)?p:k):p;j=(p|0)>-1?m&-65537:m}else if((v|0)==85){v=0;WK(d,32,u,j,s^8192);j=(u|0)>(j|0)?u:j;m=t;continue}p=o-r|0;o=(k|0)<(p|0)?p:k;s=o+q|0;m=(u|0)<(s|0)?s:u;WK(d,32,m,s,j);QK(d,n,q);WK(d,48,m,s,j^65536);WK(d,48,o,p,0);QK(d,r,p);WK(d,32,m,s,j^8192);j=m;m=t}f:do if((v|0)==88)if(!d)if(m){e=1;while(1){j=c[i+(e<<2)>>2]|0;if(!j)break;SK(g+(e<<3)|0,j,f);j=e+1|0;if((e|0)<9)e=j;else{e=j;break}}if((e|0)<10)while(1){if(c[i+(e<<2)>>2]|0){e=-1;break f}if((e|0)<9)e=e+1|0;else{e=1;break}}else e=1}else e=0;while(0);l=I;return e|0}function OK(a){a=a|0;return 0}function PK(a){a=a|0;return}function QK(a,b,d){a=a|0;b=b|0;d=d|0;if(!(c[a>>2]&32))ZK(b,d,a)|0;return}function RK(b){b=b|0;var d=0,e=0;if(!(_J(a[c[b>>2]>>0]|0)|0))d=0;else{d=0;do{e=c[b>>2]|0;d=(d*10|0)+-48+(a[e>>0]|0)|0;e=e+1|0;c[b>>2]=e}while((_J(a[e>>0]|0)|0)!=0)}return d|0}function SK(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0.0;a:do if(b>>>0<=20)do switch(b|0){case 9:{e=(c[d>>2]|0)+(4-1)&~(4-1);b=c[e>>2]|0;c[d>>2]=e+4;c[a>>2]=b;break a}case 10:{e=(c[d>>2]|0)+(4-1)&~(4-1);b=c[e>>2]|0;c[d>>2]=e+4;e=a;c[e>>2]=b;c[e+4>>2]=((b|0)<0)<<31>>31;break a}case 11:{e=(c[d>>2]|0)+(4-1)&~(4-1);b=c[e>>2]|0;c[d>>2]=e+4;e=a;c[e>>2]=b;c[e+4>>2]=0;break a}case 12:{e=(c[d>>2]|0)+(8-1)&~(8-1);b=e;f=c[b>>2]|0;b=c[b+4>>2]|0;c[d>>2]=e+8;e=a;c[e>>2]=f;c[e+4>>2]=b;break a}case 13:{f=(c[d>>2]|0)+(4-1)&~(4-1);e=c[f>>2]|0;c[d>>2]=f+4;e=(e&65535)<<16>>16;f=a;c[f>>2]=e;c[f+4>>2]=((e|0)<0)<<31>>31;break a}case 14:{f=(c[d>>2]|0)+(4-1)&~(4-1);e=c[f>>2]|0;c[d>>2]=f+4;f=a;c[f>>2]=e&65535;c[f+4>>2]=0;break a}case 15:{f=(c[d>>2]|0)+(4-1)&~(4-1);e=c[f>>2]|0;c[d>>2]=f+4;e=(e&255)<<24>>24;f=a;c[f>>2]=e;c[f+4>>2]=((e|0)<0)<<31>>31;break a}case 16:{f=(c[d>>2]|0)+(4-1)&~(4-1);e=c[f>>2]|0;c[d>>2]=f+4;f=a;c[f>>2]=e&255;c[f+4>>2]=0;break a}case 17:{f=(c[d>>2]|0)+(8-1)&~(8-1);g=+h[f>>3];c[d>>2]=f+8;h[a>>3]=g;break a}case 18:{f=(c[d>>2]|0)+(8-1)&~(8-1);g=+h[f>>3];c[d>>2]=f+8;h[a>>3]=g;break a}default:break a}while(0);while(0);return}function TK(b,c,e,f){b=b|0;c=c|0;e=e|0;f=f|0;if(!((b|0)==0&(c|0)==0))do{e=e+-1|0;a[e>>0]=d[134758+(b&15)>>0]|0|f;b=NN(b|0,c|0,4)|0;c=z}while(!((b|0)==0&(c|0)==0));return e|0}function UK(b,c,d){b=b|0;c=c|0;d=d|0;if(!((b|0)==0&(c|0)==0))do{d=d+-1|0;a[d>>0]=b&7|48;b=NN(b|0,c|0,3)|0;c=z}while(!((b|0)==0&(c|0)==0));return d|0}function VK(b,c,d){b=b|0;c=c|0;d=d|0;var e=0;if(c>>>0>0|(c|0)==0&b>>>0>4294967295){while(1){e=MN(b|0,c|0,10,0)|0;d=d+-1|0;a[d>>0]=e&255|48;e=b;b=LN(b|0,c|0,10,0)|0;if(!(c>>>0>9|(c|0)==9&e>>>0>4294967295))break;else c=z}c=b}else c=b;if(c)while(1){d=d+-1|0;a[d>>0]=(c>>>0)%10|0|48;if(c>>>0<10)break;else c=(c>>>0)/10|0}return d|0}function WK(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0;g=l;l=l+256|0;f=g;if((c|0)>(d|0)&(e&73728|0)==0){e=c-d|0;VN(f|0,b<<24>>24|0,(e>>>0<256?e:256)|0)|0;if(e>>>0>255){b=c-d|0;do{QK(a,f,256);e=e+-256|0}while(e>>>0>255);e=b&255}QK(a,f,e)}l=g;return}function XK(b,e,f,g,h,i){b=b|0;e=+e;f=f|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0.0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;H=l;l=l+560|0;m=H+8|0;u=H;G=H+524|0;F=G;n=H+512|0;c[u>>2]=0;E=n+12|0;YK(e)|0;if((z|0)<0){e=-e;C=1;B=134727}else{C=(h&2049|0)!=0&1;B=(h&2048|0)==0?((h&1|0)==0?134728:134733):134730}YK(e)|0;do if(0==0&(z&2146435072|0)==2146435072){G=(i&32|0)!=0;j=C+3|0;WK(b,32,f,j,h&-65537);QK(b,B,C);QK(b,e!=e|0.0!=0.0?(G?134895:134754):G?134746:134750,3);WK(b,32,f,j,h^8192)}else{r=+TJ(e,u)*2.0;j=r!=0.0;if(j)c[u>>2]=(c[u>>2]|0)+-1;w=i|32;if((w|0)==97){p=i&32;s=(p|0)==0?B:B+9|0;q=C|2;j=12-g|0;do if(!(g>>>0>11|(j|0)==0)){e=8.0;do{j=j+-1|0;e=e*16.0}while((j|0)!=0);if((a[s>>0]|0)==45){e=-(e+(-r-e));break}else{e=r+e-e;break}}else e=r;while(0);k=c[u>>2]|0;j=(k|0)<0?0-k|0:k;j=VK(j,((j|0)<0)<<31>>31,E)|0;if((j|0)==(E|0)){j=n+11|0;a[j>>0]=48}a[j+-1>>0]=(k>>31&2)+43;o=j+-2|0;a[o>>0]=i+15;m=(g|0)<1;n=(h&8|0)==0;j=G;do{D=~~e;k=j+1|0;a[j>>0]=p|d[134758+D>>0];e=(e-+(D|0))*16.0;if((k-F|0)==1?!(n&(m&e==0.0)):0){a[k>>0]=46;j=j+2|0}else j=k}while(e!=0.0);if((g|0)!=0?(-2-F+j|0)<(g|0):0){k=j-F|0;j=g+2|0}else{j=j-F|0;k=j}E=E-o|0;F=E+q+j|0;WK(b,32,f,F,h);QK(b,s,q);WK(b,48,f,F,h^65536);QK(b,G,k);WK(b,48,j-k|0,0,0);QK(b,o,E);WK(b,32,f,F,h^8192);j=F;break}k=(g|0)<0?6:g;if(j){j=(c[u>>2]|0)+-28|0;c[u>>2]=j;e=r*268435456.0}else{e=r;j=c[u>>2]|0}D=(j|0)<0?m:m+288|0;m=D;do{y=~~e>>>0;c[m>>2]=y;m=m+4|0;e=(e-+(y>>>0))*1.0e9}while(e!=0.0);if((j|0)>0){n=D;p=m;while(1){o=(j|0)<29?j:29;j=p+-4|0;if(j>>>0>=n>>>0){m=0;do{x=ON(c[j>>2]|0,0,o|0)|0;x=HN(x|0,z|0,m|0,0)|0;y=z;v=MN(x|0,y|0,1e9,0)|0;c[j>>2]=v;m=LN(x|0,y|0,1e9,0)|0;j=j+-4|0}while(j>>>0>=n>>>0);if(m){n=n+-4|0;c[n>>2]=m}}m=p;while(1){if(m>>>0<=n>>>0)break;j=m+-4|0;if(!(c[j>>2]|0))m=j;else break}j=(c[u>>2]|0)-o|0;c[u>>2]=j;if((j|0)>0)p=m;else break}}else n=D;if((j|0)<0){g=((k+25|0)/9|0)+1|0;t=(w|0)==102;do{s=0-j|0;s=(s|0)<9?s:9;if(n>>>0>>0){o=(1<>>s;q=0;j=n;do{y=c[j>>2]|0;c[j>>2]=(y>>>s)+q;q=O(y&o,p)|0;j=j+4|0}while(j>>>0>>0);j=(c[n>>2]|0)==0?n+4|0:n;if(!q){n=j;j=m}else{c[m>>2]=q;n=j;j=m+4|0}}else{n=(c[n>>2]|0)==0?n+4|0:n;j=m}m=t?D:n;m=(j-m>>2|0)>(g|0)?m+(g<<2)|0:j;j=(c[u>>2]|0)+s|0;c[u>>2]=j}while((j|0)<0);j=n;g=m}else{j=n;g=m}y=D;if(j>>>0>>0){m=(y-j>>2)*9|0;o=c[j>>2]|0;if(o>>>0>=10){n=10;do{n=n*10|0;m=m+1|0}while(o>>>0>=n>>>0)}}else m=0;t=(w|0)==103;v=(k|0)!=0;n=k-((w|0)!=102?m:0)+((v&t)<<31>>31)|0;if((n|0)<(((g-y>>2)*9|0)+-9|0)){n=n+9216|0;s=D+4+(((n|0)/9|0)+-1024<<2)|0;n=(n|0)%9|0;if((n|0)<8){o=10;while(1){o=o*10|0;if((n|0)<7)n=n+1|0;else break}}else o=10;p=c[s>>2]|0;q=(p>>>0)%(o>>>0)|0;n=(s+4|0)==(g|0);if(!(n&(q|0)==0)){r=(((p>>>0)/(o>>>0)|0)&1|0)==0?9007199254740992.0:9007199254740994.0;x=(o|0)/2|0;e=q>>>0>>0?.5:n&(q|0)==(x|0)?1.0:1.5;if(C){x=(a[B>>0]|0)==45;e=x?-e:e;r=x?-r:r}n=p-q|0;c[s>>2]=n;if(r+e!=r){x=n+o|0;c[s>>2]=x;if(x>>>0>999999999){m=s;while(1){n=m+-4|0;c[m>>2]=0;if(n>>>0>>0){j=j+-4|0;c[j>>2]=0}x=(c[n>>2]|0)+1|0;c[n>>2]=x;if(x>>>0>999999999)m=n;else break}}else n=s;m=(y-j>>2)*9|0;p=c[j>>2]|0;if(p>>>0>=10){o=10;do{o=o*10|0;m=m+1|0}while(p>>>0>=o>>>0)}}else n=s}else n=s;n=n+4|0;n=g>>>0>n>>>0?n:g;x=j}else{n=g;x=j}w=n;while(1){if(w>>>0<=x>>>0){u=0;break}j=w+-4|0;if(!(c[j>>2]|0))w=j;else{u=1;break}}g=0-m|0;do if(t){j=k+((v^1)&1)|0;if((j|0)>(m|0)&(m|0)>-5){o=i+-1|0;k=j+-1-m|0}else{o=i+-2|0;k=j+-1|0}j=h&8;if(!j){if(u?(A=c[w+-4>>2]|0,(A|0)!=0):0)if(!((A>>>0)%10|0)){n=0;j=10;do{j=j*10|0;n=n+1|0}while(!((A>>>0)%(j>>>0)|0|0))}else n=0;else n=9;j=((w-y>>2)*9|0)+-9|0;if((o|32|0)==102){s=j-n|0;s=(s|0)>0?s:0;k=(k|0)<(s|0)?k:s;s=0;break}else{s=j+m-n|0;s=(s|0)>0?s:0;k=(k|0)<(s|0)?k:s;s=0;break}}else s=j}else{o=i;s=h&8}while(0);t=k|s;p=(t|0)!=0&1;q=(o|32|0)==102;if(q){v=0;j=(m|0)>0?m:0}else{j=(m|0)<0?g:m;j=VK(j,((j|0)<0)<<31>>31,E)|0;n=E;if((n-j|0)<2)do{j=j+-1|0;a[j>>0]=48}while((n-j|0)<2);a[j+-1>>0]=(m>>31&2)+43;j=j+-2|0;a[j>>0]=o;v=j;j=n-j|0}j=C+1+k+p+j|0;WK(b,32,f,j,h);QK(b,B,C);WK(b,48,f,j,h^65536);if(q){o=x>>>0>D>>>0?D:x;s=G+9|0;p=s;q=G+8|0;n=o;do{m=VK(c[n>>2]|0,0,s)|0;if((n|0)==(o|0)){if((m|0)==(s|0)){a[q>>0]=48;m=q}}else if(m>>>0>G>>>0){VN(G|0,48,m-F|0)|0;do m=m+-1|0;while(m>>>0>G>>>0)}QK(b,m,p-m|0);n=n+4|0}while(n>>>0<=D>>>0);if(t|0)QK(b,134774,1);if(n>>>0>>0&(k|0)>0)while(1){m=VK(c[n>>2]|0,0,s)|0;if(m>>>0>G>>>0){VN(G|0,48,m-F|0)|0;do m=m+-1|0;while(m>>>0>G>>>0)}QK(b,m,(k|0)<9?k:9);n=n+4|0;m=k+-9|0;if(!(n>>>0>>0&(k|0)>9)){k=m;break}else k=m}WK(b,48,k+9|0,9,0)}else{t=u?w:x+4|0;if((k|0)>-1){u=G+9|0;s=(s|0)==0;g=u;p=0-F|0;q=G+8|0;o=x;do{m=VK(c[o>>2]|0,0,u)|0;if((m|0)==(u|0)){a[q>>0]=48;m=q}do if((o|0)==(x|0)){n=m+1|0;QK(b,m,1);if(s&(k|0)<1){m=n;break}QK(b,134774,1);m=n}else{if(m>>>0<=G>>>0)break;VN(G|0,48,m+p|0)|0;do m=m+-1|0;while(m>>>0>G>>>0)}while(0);F=g-m|0;QK(b,m,(k|0)>(F|0)?F:k);k=k-F|0;o=o+4|0}while(o>>>0>>0&(k|0)>-1)}WK(b,48,k+18|0,18,0);QK(b,v,E-v|0)}WK(b,32,f,j,h^8192)}while(0);l=H;return ((j|0)<(f|0)?f:j)|0}function YK(a){a=+a;var b=0;h[j>>3]=a;b=c[j>>2]|0;z=c[j+4>>2]|0;return b|0}function ZK(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;f=e+16|0;g=c[f>>2]|0;if(!g)if(!(_K(e)|0)){g=c[f>>2]|0;h=5}else f=0;else h=5;a:do if((h|0)==5){j=e+20|0;i=c[j>>2]|0;f=i;if((g-i|0)>>>0>>0){f=bb[c[e+36>>2]&31](e,b,d)|0;break}b:do if((a[e+75>>0]|0)>-1){i=d;while(1){if(!i){h=0;g=b;break b}g=i+-1|0;if((a[b+g>>0]|0)==10)break;else i=g}f=bb[c[e+36>>2]&31](e,b,i)|0;if(f>>>0>>0)break a;h=i;g=b+i|0;d=d-i|0;f=c[j>>2]|0}else{h=0;g=b}while(0);TN(f|0,g|0,d|0)|0;c[j>>2]=(c[j>>2]|0)+d;f=h+d|0}while(0);return f|0}function _K(b){b=b|0;var d=0,e=0;d=b+74|0;e=a[d>>0]|0;a[d>>0]=e+255|e;d=c[b>>2]|0;if(!(d&8)){c[b+8>>2]=0;c[b+4>>2]=0;e=c[b+44>>2]|0;c[b+28>>2]=e;c[b+20>>2]=e;c[b+16>>2]=e+(c[b+48>>2]|0);b=0}else{c[b>>2]=d|32;b=-1}return b|0}function $K(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=a+20|0;f=c[e>>2]|0;a=(c[a+16>>2]|0)-f|0;a=a>>>0>d>>>0?d:a;TN(f|0,b|0,a|0)|0;c[e>>2]=(c[e>>2]|0)+a;return d|0}function aL(b){b=b|0;var c=0,d=0,e=0,f=0;e=a[b>>0]|0;c=1;d=134776;f=97;while(1){if(e<<24>>24==f<<24>>24?(xJ(b,d)|0)==0:0)break;d=d+6|0;f=a[d>>0]|0;if(!(f<<24>>24)){c=0;break}else c=c+1|0}return c|0}function bL(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0;h=l;l=l+16|0;g=h;do if(b>>>0>6)d=0;else{pa(170780);if((b|0)!=6){d=cL(b,d)|0;Fa(170780);break}if(!d){d=176254;b=0}else{b=g;e=134849;f=b+16|0;do{a[b>>0]=a[e>>0]|0;b=b+1|0;e=e+1|0}while((b|0)<(f|0));f=0;do{b=qJ(d,59)|0;e=b-d|0;if((e|0)<16){TN(g|0,d|0,e|0)|0;a[g+e>>0]=0;d=(a[b>>0]|0)==0?d:b+1|0}cL(f,g)|0;f=f+1|0}while((f|0)!=6);d=176254;b=0}while(1){f=c[170740+(b<<2)>>2]|0;f=f|0?f+8|0:134865;e=rJ(f)|0;TN(d|0,f|0,e|0)|0;f=d+e|0;a[f>>0]=59;b=b+1|0;if((b|0)==6)break;else d=d+(e+1)|0}a[f>>0]=0;Fa(170780);d=176254}while(0);l=h;return d|0}function cL(a,b){a=a|0;b=b|0;if(!b)a=c[170740+(a<<2)>>2]|0;else{b=wK(a,b)|0;c[170740+(a<<2)>>2]=b;a=b}return (a|0?a+8|0:134865)|0}function dL(b,c,d){b=b|0;c=c|0;d=d|0;var e=0,f=0;a:do if(!d)b=0;else{while(1){e=a[b>>0]|0;f=a[c>>0]|0;if(e<<24>>24!=f<<24>>24)break;d=d+-1|0;if(!d){b=0;break a}else{b=b+1|0;c=c+1|0}}b=(e&255)-(f&255)|0}while(0);return b|0}function eL(a){a=a|0;return fL(a)|0}function fL(a){a=a|0;return PN(a|0)|0}function gL(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;if((c[f+76>>2]|0)>-1)m=OK(f)|0;else m=0;g=e+-1|0;if((e|0)<2){n=f+74|0;l=a[n>>0]|0;a[n>>0]=l+255|l;if(m|0)PK(f);if(!g)a[b>>0]=0;else b=0}else{a:do if(g){k=f+4|0;l=f+8|0;e=b;while(1){h=c[k>>2]|0;o=h;p=(c[l>>2]|0)-o|0;i=ZJ(h,10,p)|0;j=(i|0)==0;i=j?p:1-o+i|0;i=i>>>0>>0?i:g;TN(e|0,h|0,i|0)|0;h=(c[k>>2]|0)+i|0;c[k>>2]=h;e=e+i|0;i=g-i|0;if(!(j&(i|0)!=0)){n=17;break a}if(h>>>0>=(c[l>>2]|0)>>>0){g=dK(f)|0;if((g|0)<0)break;else j=g}else{c[k>>2]=h+1;j=d[h>>0]|0}g=i+-1|0;h=e+1|0;a[e>>0]=j;if(!((g|0)!=0&(j&255|0)!=10)){e=h;n=17;break a}else e=h}if((e|0)!=(b|0)?(c[f>>2]&16|0)!=0:0)n=17;else b=0}else{e=b;n=17}while(0);if((n|0)==17)if(!b)b=0;else a[e>>0]=0;if(m)PK(f)}return b|0}function hL(b,c){b=b|0;c=c|0;var d=0;d=a[c>>0]|0;do if(d<<24>>24){b=WJ(b,d<<24>>24)|0;if(b){if(a[c+1>>0]|0)if(a[b+1>>0]|0){if(!(a[c+2>>0]|0)){b=iL(b,c)|0;break}if(a[b+2>>0]|0){if(!(a[c+3>>0]|0)){b=jL(b,c)|0;break}if(a[b+3>>0]|0)if(!(a[c+4>>0]|0)){b=kL(b,c)|0;break}else{b=lL(b,c)|0;break}else b=0}else b=0}else b=0}else b=0}while(0);return b|0}function iL(b,c){b=b|0;c=c|0;var e=0,f=0,g=0;g=(d[c>>0]|0)<<8|(d[c+1>>0]|0);f=d[b>>0]|0;while(1){c=b+1|0;e=a[c>>0]|0;if(!(e<<24>>24))break;f=f<<8&65280|e&255;if((f|0)==(g|0))break;else b=c}return (e<<24>>24?b:0)|0}function jL(b,c){b=b|0;c=c|0;var e=0,f=0;f=(d[c+1>>0]|0)<<16|(d[c>>0]|0)<<24|(d[c+2>>0]|0)<<8;e=b+2|0;c=a[e>>0]|0;b=(d[b+1>>0]|0)<<16|(d[b>>0]|0)<<24|(c&255)<<8;if(!((b|0)==(f|0)|c<<24>>24==0))do{e=e+1|0;c=a[e>>0]|0;b=(b|c&255)<<8}while(!((b|0)==(f|0)|c<<24>>24==0));return (c<<24>>24?e+-2|0:0)|0}function kL(b,c){b=b|0;c=c|0;var e=0,f=0;f=(d[c+1>>0]|0)<<16|(d[c>>0]|0)<<24|(d[c+2>>0]|0)<<8|(d[c+3>>0]|0);c=b+3|0;e=a[c>>0]|0;b=(d[b+1>>0]|0)<<16|(d[b>>0]|0)<<24|(d[b+2>>0]|0)<<8|e&255;if(!(e<<24>>24==0|(b|0)==(f|0)))do{c=c+1|0;e=a[c>>0]|0;b=b<<8|e&255}while(!(e<<24>>24==0|(b|0)==(f|0)));return (e<<24>>24?c+-3|0:0)|0}function lL(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;v=l;l=l+1056|0;t=v+1024|0;u=v;c[t>>2]=0;c[t+4>>2]=0;c[t+8>>2]=0;c[t+12>>2]=0;c[t+16>>2]=0;c[t+20>>2]=0;c[t+24>>2]=0;c[t+28>>2]=0;e=a[d>>0]|0;a:do if(e<<24>>24){s=0;do{if(!(a[b+s>>0]|0)){e=0;break a}r=t+(((e&255)>>>5&255)<<2)|0;c[r>>2]=c[r>>2]|1<<(e&31);s=s+1|0;c[u+((e&255)<<2)>>2]=s;e=a[d+s>>0]|0}while(e<<24>>24!=0);m=s>>>0>1;if(m){f=0;k=-1;g=1;b:while(1){h=1;e=f;while(1){f=g;c:while(1){j=1;while(1){g=a[d+(j+k)>>0]|0;i=a[d+f>>0]|0;if(g<<24>>24!=i<<24>>24)break c;if((j|0)==(h|0))break;j=j+1|0;f=j+e|0;if(f>>>0>=s>>>0){n=h;e=k;break b}}e=h+e|0;f=e+1|0;if(f>>>0>=s>>>0){n=h;e=k;break b}}h=f-k|0;if((g&255)<=(i&255))break;g=f+1|0;if(g>>>0>=s>>>0){n=h;e=k;break b}else e=f}g=e+2|0;if(g>>>0>=s>>>0){n=1;break}else{f=e+1|0;k=e}}if(m){h=0;m=-1;i=1;while(1){f=1;g=h;while(1){h=i;d:while(1){k=1;while(1){i=a[d+(k+m)>>0]|0;j=a[d+h>>0]|0;if(i<<24>>24!=j<<24>>24)break d;if((k|0)==(f|0))break;k=k+1|0;h=k+g|0;if(h>>>0>=s>>>0){i=n;g=m;h=26;break a}}g=f+g|0;h=g+1|0;if(h>>>0>=s>>>0){i=n;g=m;h=26;break a}}f=h-m|0;if((i&255)>=(j&255))break;i=h+1|0;if(i>>>0>=s>>>0){i=n;g=m;h=26;break a}else g=h}i=g+2|0;if(i>>>0>=s>>>0){i=n;f=1;h=26;break}else{h=g+1|0;m=g}}}else{i=n;f=1;g=-1;h=26}}else{i=1;e=-1;f=1;g=-1;h=26}}else{i=1;e=-1;s=0;f=1;g=-1;h=26}while(0);e:do if((h|0)==26){q=(g+1|0)>>>0>(e+1|0)>>>0;f=q?f:i;q=q?g:e;r=q+1|0;if(!(dL(d,d+f|0,r)|0))p=s-f|0;else{f=s-q+-1|0;p=0;f=(q>>>0>f>>>0?q:f)+1|0}k=s|63;m=s+-1|0;n=(p|0)!=0;o=s-f|0;e=b;j=0;g=b;while(1){h=e;do if((g-h|0)>>>0>>0){i=ZJ(g,0,k)|0;if(i)if((i-h|0)>>>0>>0){e=0;break e}else break;else{i=g+k|0;break}}else i=g;while(0);g=a[e+m>>0]|0;f:do if(!(1<<(g&31)&c[t+(((g&255)>>>5&255)<<2)>>2])){h=0;g=s}else{g=s-(c[u+((g&255)<<2)>>2]|0)|0;if(g|0){h=0;g=n&(j|0)!=0&g>>>0>>0?o:g;break}g=r>>>0>j>>>0?r:j;h=a[d+g>>0]|0;g:do if(!(h<<24>>24))g=r;else{while(1){if(h<<24>>24!=(a[e+g>>0]|0))break;g=g+1|0;h=a[d+g>>0]|0;if(!(h<<24>>24)){g=r;break g}}h=0;g=g-q|0;break f}while(0);while(1){if(g>>>0<=j>>>0)break e;g=g+-1|0;if((a[d+g>>0]|0)!=(a[e+g>>0]|0)){h=p;g=f;break}}}while(0);e=e+g|0;j=h;g=i}}while(0);l=v;return e|0}function mL(a,b,c){a=a|0;b=b|0;c=c|0;nL(a,b,c)|0;return a|0}function nL(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;g=d;a:do if(!((g^b)&3)){f=(e|0)!=0;if(f&(g&3|0)!=0)do{g=a[d>>0]|0;a[b>>0]=g;if(!(g<<24>>24))break a;e=e+-1|0;d=d+1|0;b=b+1|0;f=(e|0)!=0}while(f&(d&3|0)!=0);if(f){if(a[d>>0]|0){b:do if(e>>>0>3){f=d;while(1){d=c[f>>2]|0;if((d&-2139062144^-2139062144)&d+-16843009|0){d=f;break b}c[b>>2]=d;e=e+-4|0;d=f+4|0;b=b+4|0;if(e>>>0>3)f=d;else break}}while(0);h=11}}else e=0}else h=11;while(0);c:do if((h|0)==11)if(!e)e=0;else while(1){h=a[d>>0]|0;a[b>>0]=h;if(!(h<<24>>24))break c;e=e+-1|0;b=b+1|0;if(!e){e=0;break}else d=d+1|0}while(0);VN(b|0,0,e|0)|0;return b|0}function oL(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0;g=l;l=l+32|0;f=g;c[f>>2]=0;c[f+4>>2]=0;c[f+8>>2]=0;c[f+12>>2]=0;c[f+16>>2]=0;c[f+20>>2]=0;c[f+24>>2]=0;c[f+28>>2]=0;e=a[d>>0]|0;do if(!(e<<24>>24))d=0;else{if(!(a[d+1>>0]|0)){d=b;while(1)if((a[d>>0]|0)==e<<24>>24)d=d+1|0;else break;d=d-b|0;break}do{h=f+(((e&255)>>>5&255)<<2)|0;c[h>>2]=c[h>>2]|1<<(e&31);d=d+1|0;e=a[d>>0]|0}while(e<<24>>24!=0);e=a[b>>0]|0;a:do if(!(e<<24>>24))d=b;else{d=b;do{if(!(c[f+(((e&255)>>>5&255)<<2)>>2]&1<<(e&31)))break a;d=d+1|0;e=a[d>>0]|0}while(e<<24>>24!=0)}while(0);d=d-b|0}while(0);l=g;return d|0}function pL(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=l;l=l+16|0;f=e;c[f>>2]=d;d=qL(a,b,f)|0;l=e;return d|0}function qL(a,b,c){a=a|0;b=b|0;c=c|0;return LK(a,2147483647,b,c)|0}function rL(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0;m=l;l=l+208|0;j=m+8|0;k=m;h=O(d,b)|0;i=k;c[i>>2]=1;c[i+4>>2]=0;a:do if(h|0){i=0-d|0;c[j+4>>2]=d;c[j>>2]=d;f=2;b=d;g=d;while(1){b=b+d+g|0;c[j+(f<<2)>>2]=b;if(b>>>0>>0){n=g;f=f+1|0;g=b;b=n}else break}g=a+h+i|0;if(g>>>0>a>>>0){h=g;f=1;b=1;do{do if((b&3|0)!=3){b=f+-1|0;if((c[j+(b<<2)>>2]|0)>>>0<(h-a|0)>>>0)sL(a,d,e,f,j);else uL(a,d,e,k,f,0,j);if((f|0)==1){vL(k,1);f=0;break}else{vL(k,b);f=1;break}}else{sL(a,d,e,f,j);tL(k,2);f=f+2|0}while(0);b=c[k>>2]|1;c[k>>2]=b;a=a+d|0}while(a>>>0>>0)}else{f=1;b=1}uL(a,d,e,k,f,0,j);g=k+4|0;while(1){if((f|0)==1&(b|0)==1){if(!(c[g>>2]|0))break a}else if((f|0)>=2){vL(k,2);n=f+-2|0;c[k>>2]=c[k>>2]^7;tL(k,1);uL(a+(0-(c[j+(n<<2)>>2]|0))+i|0,d,e,k,f+-1|0,1,j);vL(k,1);b=c[k>>2]|1;c[k>>2]=b;h=a+i|0;uL(h,d,e,k,n,1,j);a=h;f=n;continue}b=wL(k)|0;tL(k,b);a=a+i|0;f=b+f|0;b=c[k>>2]|0}}while(0);l=m;return}function sL(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,m=0,n=0;n=l;l=l+240|0;m=n;c[m>>2]=a;a:do if((e|0)>1){k=0-b|0;g=a;j=e;e=1;while(1){h=g+k|0;i=j+-2|0;g=h+(0-(c[f+(i<<2)>>2]|0))|0;if((ab[d&63](a,g)|0)>-1?(ab[d&63](a,h)|0)>-1:0)break a;a=e+1|0;e=m+(e<<2)|0;if((ab[d&63](g,h)|0)>-1){c[e>>2]=g;e=j+-1|0}else{c[e>>2]=h;g=h;e=i}if((e|0)<=1){e=a;break a}j=e;e=a;a=c[m>>2]|0}}else e=1;while(0);yL(b,m,e);l=n;return}function tL(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;f=a+4|0;if(b>>>0>31){e=c[f>>2]|0;c[a>>2]=e;c[f>>2]=0;b=b+-32|0;d=0}else{d=c[f>>2]|0;e=c[a>>2]|0}c[a>>2]=d<<32-b|e>>>b;c[f>>2]=d>>>b;return}function uL(a,b,d,e,f,g,h){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0;p=l;l=l+240|0;n=p+232|0;o=p;q=c[e>>2]|0;c[n>>2]=q;j=c[e+4>>2]|0;k=n+4|0;c[k>>2]=j;c[o>>2]=a;a:do if((q|0)!=1|(j|0)!=0?(m=0-b|0,i=a+(0-(c[h+(f<<2)>>2]|0))|0,(ab[d&63](i,a)|0)>=1):0){e=1;g=(g|0)==0;j=i;while(1){if(g&(f|0)>1){g=a+m|0;i=c[h+(f+-2<<2)>>2]|0;if((ab[d&63](g,j)|0)>-1){i=10;break a}if((ab[d&63](g+(0-i)|0,j)|0)>-1){i=10;break a}}g=e+1|0;c[o+(e<<2)>>2]=j;q=wL(n)|0;tL(n,q);f=q+f|0;if(!((c[n>>2]|0)!=1|(c[k>>2]|0)!=0)){e=g;a=j;i=10;break a}a=j+(0-(c[h+(f<<2)>>2]|0))|0;if((ab[d&63](a,c[o>>2]|0)|0)<1){a=j;e=g;g=0;i=9;break}else{q=j;e=g;g=1;j=a;a=q}}}else{e=1;i=9}while(0);if((i|0)==9?(g|0)==0:0)i=10;if((i|0)==10){yL(b,o,e);sL(a,b,d,f,h)}l=p;return}function vL(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;f=a+4|0;if(b>>>0>31){e=c[a>>2]|0;c[f>>2]=e;c[a>>2]=0;b=b+-32|0;d=0}else{d=c[a>>2]|0;e=c[f>>2]|0}c[f>>2]=d>>>(32-b|0)|e<>2]=d<>2]|0)+-1|0)|0;if(!b){b=xL(c[a+4>>2]|0)|0;return ((b|0)==0?0:b+32|0)|0}else return b|0;return 0}function xL(a){a=a|0;var b=0;if(a)if(!(a&1)){b=a;a=0;do{a=a+1|0;b=b>>>1}while(!(b&1|0))}else a=0;else a=32;return a|0}function yL(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;h=l;l=l+256|0;e=h;a:do if((d|0)>=2?(g=b+(d<<2)|0,c[g>>2]=e,a|0):0)while(1){f=a>>>0<256?a:256;TN(e|0,c[b>>2]|0,f|0)|0;e=0;do{i=b+(e<<2)|0;e=e+1|0;TN(c[i>>2]|0,c[b+(e<<2)>>2]|0,f|0)|0;c[i>>2]=(c[i>>2]|0)+f}while((e|0)!=(d|0));a=a-f|0;if(!a)break a;e=c[g>>2]|0}while(0);l=h;return}function zL(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=l;l=l+16|0;f=e;c[f>>2]=d;d=MK(a,b,f)|0;l=e;return d|0}function AL(b){b=b|0;var d=0,e=0,f=0;f=l;l=l+16|0;e=f;oa(0,e|0)|0;d=0;e=(c[e+4>>2]|0)*65537^(e>>>4)+b;while(1){a[b+d>>0]=(e&15)+65|e<<1&32;d=d+1|0;if((d|0)==6)break;else e=e>>>5}l=f;return b|0}function BL(a,b,c){a=a|0;b=b|0;c=c|0;c=$J(a,b,c,-2147483648,0)|0;return c|0}function CL(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;h=l;l=l+32|0;f=h;e=a[d>>0]|0;a:do if(e<<24>>24!=0?(a[d+1>>0]|0)!=0:0){VN(f|0,0,32)|0;e=a[d>>0]|0;if(e<<24>>24)do{i=f+(((e&255)>>>5&255)<<2)|0;c[i>>2]=c[i>>2]|1<<(e&31);d=d+1|0;e=a[d>>0]|0}while(e<<24>>24!=0);d=a[b>>0]|0;if(!(d<<24>>24))e=b;else{e=b;do{if(c[f+(((d&255)>>>5&255)<<2)>>2]&1<<(d&31)|0)break a;e=e+1|0;d=a[e>>0]|0}while(d<<24>>24!=0)}}else g=3;while(0);if((g|0)==3)e=qJ(b,e<<24>>24)|0;l=h;return e-b|0}function DL(b,d){b=b|0;d=d|0;var e=0;if(!b){b=c[42697]|0;if(!b)b=0;else e=3}else e=3;do if((e|0)==3){b=b+(oL(b,d)|0)|0;if(!(a[b>>0]|0)){c[42697]=0;b=0;break}d=b+(CL(b,d)|0)|0;c[42697]=d;if(!(a[d>>0]|0)){c[42697]=0;break}else{c[42697]=d+1;a[d>>0]=0;break}}while(0);return b|0}function EL(b,c,d){b=b|0;c=c|0;d=d|0;var e=0;e=c&255;do{if(!d){c=0;break}d=d+-1|0;c=b+d|0}while((a[c>>0]|0)!=e<<24>>24);return c|0}function FL(b,d,e){b=b|0;d=d|0;e=e|0;var f=0;if(!b){b=c[e>>2]|0;if(!b)b=0;else f=3}else f=3;do if((f|0)==3){b=b+(oL(b,d)|0)|0;if(!(a[b>>0]|0)){c[e>>2]=0;b=0;break}d=b+(CL(b,d)|0)|0;c[e>>2]=d;if(!(a[d>>0]|0)){c[e>>2]=0;break}else{c[e>>2]=d+1;a[d>>0]=0;break}}while(0);return b|0}function GL(a){a=a|0;var b=0,c=0;b=(rJ(a)|0)+1|0;c=ZI(b)|0;if(!c)a=0;else a=TN(c|0,a|0,b|0)|0;return a|0}function HL(a,b){a=a|0;b=b|0;return EL(a,b,(rJ(a)|0)+1|0)|0}function IL(a,b){a=a|0;b=b|0;xK(a+(rJ(a)|0)|0,b)|0;return a|0}function JL(b,c){b=b|0;c=c|0;c=b+(CL(b,c)|0)|0;return (a[c>>0]|0?c:0)|0}function KL(a){a=a|0;var b=0;if((c[a+76>>2]|0)>-1){b=(OK(a)|0)==0;a=(c[a>>2]|0)>>>4&1}else a=(c[a>>2]|0)>>>4&1;return a|0}function LL(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;if((c[a+76>>2]|0)>-1)f=OK(a)|0;else f=0;ML(a);g=(c[a>>2]&1|0)!=0;if(!g){e=NL()|0;d=c[a+52>>2]|0;b=a+56|0;if(d|0)c[d+56>>2]=c[b>>2];b=c[b>>2]|0;if(b|0)c[b+52>>2]=d;if((c[e>>2]|0)==(a|0))c[e>>2]=b;OL()}b=PL(a)|0;b=$a[c[a+12>>2]&31](a)|0|b;d=c[a+92>>2]|0;if(d|0)_I(d);if(g){if(f|0)PK(a)}else _I(a);return b|0}function ML(a){a=a|0;var b=0;if(c[a+68>>2]|0){b=c[a+116>>2]|0;a=a+112|0;if(b|0)c[b+112>>2]=c[a>>2];a=c[a>>2]|0;if(!a)a=(RL()|0)+232|0;else a=a+116|0;c[a>>2]=b}return}function NL(){pa(170792);return 170800}function OL(){Fa(170792);return}function PL(a){a=a|0;var b=0,d=0;do if(a){if((c[a+76>>2]|0)<=-1){b=QL(a)|0;break}d=(OK(a)|0)==0;b=QL(a)|0;if(!d)PK(a)}else{if(!(c[13917]|0))b=0;else b=PL(c[13917]|0)|0;a=c[(NL()|0)>>2]|0;if(a)do{if((c[a+76>>2]|0)>-1)d=OK(a)|0;else d=0;if((c[a+20>>2]|0)>>>0>(c[a+28>>2]|0)>>>0)b=QL(a)|0|b;if(d|0)PK(a);a=c[a+56>>2]|0}while((a|0)!=0);OL()}while(0);return b|0}function QL(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0;b=a+20|0;h=a+28|0;if((c[b>>2]|0)>>>0>(c[h>>2]|0)>>>0?(bb[c[a+36>>2]&31](a,0,0)|0,(c[b>>2]|0)==0):0)a=-1;else{d=a+4|0;e=c[d>>2]|0;f=a+8|0;g=c[f>>2]|0;if(e>>>0>>0)bb[c[a+40>>2]&31](a,e-g|0,1)|0;c[a+16>>2]=0;c[h>>2]=0;c[b>>2]=0;c[f>>2]=0;c[d>>2]=0;a=0}return a|0}function RL(){return AJ()|0}function SL(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0;k=l;l=l+64|0;j=k+40|0;h=k+24|0;g=k+16|0;f=k;i=k+56|0;if(WJ(134882,a[d>>0]|0)|0){e=ZI(1156)|0;if(!e)e=0;else{VN(e|0,0,124)|0;if(!(WJ(d,43)|0))c[e>>2]=(a[d>>0]|0)==114?8:4;if(WJ(d,101)|0){c[f>>2]=b;c[f+4>>2]=2;c[f+8>>2]=1;za(221,f|0)|0}if((a[d>>0]|0)==97){c[g>>2]=b;c[g+4>>2]=3;d=za(221,g|0)|0;if(!(d&1024)){c[h>>2]=b;c[h+4>>2]=4;c[h+8>>2]=d|1024;za(221,h|0)|0}f=c[e>>2]|128;c[e>>2]=f}else f=c[e>>2]|0;c[e+60>>2]=b;c[e+44>>2]=e+132;c[e+48>>2]=1024;d=e+75|0;a[d>>0]=-1;if((f&8|0)==0?(c[j>>2]=b,c[j+4>>2]=21523,c[j+8>>2]=i,(Ca(54,j|0)|0)==0):0)a[d>>0]=10;c[e+32>>2]=6;c[e+36>>2]=9;c[e+40>>2]=7;c[e+12>>2]=15;if(!(c[42676]|0))c[e+76>>2]=-1;TL(e)|0}}else{c[(jJ()|0)>>2]=22;e=0}l=k;return e|0}function TL(a){a=a|0;var b=0,d=0;b=NL()|0;c[a+56>>2]=c[b>>2];d=c[b>>2]|0;if(d|0)c[d+52>>2]=a;c[b>>2]=a;OL();return a|0}function UL(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0;j=l;l=l+16|0;g=j;a:do if(!e)b=0;else{do if(f|0){i=(b|0)==0?g:b;b=a[e>>0]|0;if(b<<24>>24>-1){c[i>>2]=b&255;b=b<<24>>24!=0&1;break a}h=(c[c[(VL()|0)+188>>2]>>2]|0)==0;b=a[e>>0]|0;if(h){c[i>>2]=b<<24>>24&57343;b=1;break a}b=(b&255)+-194|0;if(b>>>0<=50){g=e+1|0;h=c[55208+(b<<2)>>2]|0;if(f>>>0<4?h&-2147483648>>>((f*6|0)+-6|0)|0:0)break;b=d[g>>0]|0;f=b>>>3;if((f+-16|f+(h>>26))>>>0<=7){b=b+-128|h<<6;if((b|0)>=0){c[i>>2]=b;b=2;break a}g=(d[e+2>>0]|0)+-128|0;if(g>>>0<=63){g=g|b<<6;if((g|0)>=0){c[i>>2]=g;b=3;break a}b=(d[e+3>>0]|0)+-128|0;if(b>>>0<=63){c[i>>2]=b|g<<6;b=4;break a}}}}}while(0);c[(jJ()|0)>>2]=84;b=-1}while(0);l=j;return b|0}function VL(){return AJ()|0}function WL(a,b){a=a|0;b=b|0;var c=0;c=rJ(a)|0;return ((XL(a,1,c,b)|0)!=(c|0))<<31>>31|0}function XL(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;f=O(d,b)|0;d=(b|0)==0?0:d;if((c[e+76>>2]|0)>-1){g=(OK(e)|0)==0;a=ZK(a,f,e)|0;if(!g)PK(e)}else a=ZK(a,f,e)|0;if((a|0)!=(f|0))d=(a>>>0)/(b>>>0)|0;return d|0}function YL(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,m=0;m=l;l=l+16|0;j=m;k=e&255;a[j>>0]=k;g=b+16|0;h=c[g>>2]|0;if(!h)if(!(_K(b)|0)){h=c[g>>2]|0;i=4}else f=-1;else i=4;do if((i|0)==4){i=b+20|0;g=c[i>>2]|0;if(g>>>0>>0?(f=e&255,(f|0)!=(a[b+75>>0]|0)):0){c[i>>2]=g+1;a[g>>0]=k;break}if((bb[c[b+36>>2]&31](b,j,1)|0)==1)f=d[j>>0]|0;else f=-1}while(0);l=m;return f|0}function ZL(b,c){b=b|0;c=c|0;var d=0,e=0,f=0;d=b;e=134867;f=d+15|0;do{a[d>>0]=a[e>>0]|0;d=d+1|0;e=e+1|0}while((d|0)<(f|0));if(!c){a[b+14>>0]=48;a[b+15>>0]=0}else{e=c;d=14;while(1){d=d+1|0;if(e>>>0<10)break;else e=(e>>>0)/10|0}a[b+d>>0]=0;while(1){d=d+-1|0;a[b+d>>0]=(c>>>0)%10|0|48;if(c>>>0<10)break;else c=(c>>>0)/10|0}}return}function _L(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;g=l;l=l+48|0;f=g+40|0;e=g+8|0;d=g;c[d>>2]=a;c[d+4>>2]=b;d=ya(197,d|0)|0;if((d|0)==-9?(c[e>>2]=a,c[e+4>>2]=1,(za(221,e|0)|0)>=0):0){ZL(e,a);c[f>>2]=e;c[f+4>>2]=b;b=iJ(xa(195,f|0)|0)|0}else b=iJ(d)|0;l=g;return b|0}function $L(a,b){a=a|0;b=b|0;var d=0,e=0;d=l;l=l+16|0;e=d;c[e>>2]=a;c[e+4>>2]=b;b=iJ(Aa(33,e|0)|0)|0;l=d;return b|0}function aM(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;i=l;l=l+48|0;h=i+32|0;g=i+16|0;e=i;if(WJ(134882,a[d>>0]|0)|0){f=bM(d)|0;c[e>>2]=b;c[e+4>>2]=f|32768;c[e+8>>2]=438;e=iJ(Ba(5,e|0)|0)|0;if((e|0)>=0){if(f&524288|0){c[g>>2]=e;c[g+4>>2]=2;c[g+8>>2]=1;za(221,g|0)|0}b=SL(e,d)|0;if(!b){c[h>>2]=e;Da(6,h|0)|0;b=0}}else b=0}else{c[(jJ()|0)>>2]=22;b=0}l=i;return b|0}function bM(b){b=b|0;var c=0,d=0,e=0;d=(WJ(b,43)|0)==0;c=a[b>>0]|0;d=d?c<<24>>24!=114&1:2;e=(WJ(b,120)|0)==0;d=e?d:d|128;b=(WJ(b,101)|0)==0;b=b?d:d|524288;b=c<<24>>24==114?b:b|64;b=c<<24>>24==119?b|512:b;return (c<<24>>24==97?b|1024:b)|0}function cM(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=l;l=l+16|0;f=e;c[f>>2]=d;d=dM(a,b,f)|0;l=e;return d|0}function dM(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0;g=l;l=l+128|0;e=g;f=e;h=f+124|0;do{c[f>>2]=0;f=f+4|0}while((f|0)<(h|0));c[e+32>>2]=18;c[e+44>>2]=a;c[e+76>>2]=-1;c[e+84>>2]=a;h=fM(e,b,d)|0;l=g;return h|0}function eM(a,b,c){a=a|0;b=b|0;c=c|0;return nM(a,b,c)|0}function fM(b,e,f){b=b|0;e=e|0;f=f|0;var i=0,j=0,k=0,m=0,n=0,o=0.0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0;L=l;l=l+288|0;F=L+8|0;G=L+17|0;H=L;I=L+16|0;if((c[b+76>>2]|0)>-1)K=OK(b)|0;else K=0;i=a[e>>0]|0;a:do if(i<<24>>24){y=b+4|0;A=b+100|0;B=b+108|0;C=b+8|0;D=G+10|0;E=G+33|0;x=F+4|0;p=e;u=0;e=0;j=0;k=i;i=0;b:while(1){c:do if(!(XJ(k&255)|0)){k=(a[p>>0]|0)==37;d:do if(k){m=p+1|0;n=a[m>>0]|0;e:do switch(n<<24>>24){case 37:break d;case 42:{w=0;m=p+2|0;break}default:{if(_J(n&255)|0?(a[p+2>>0]|0)==36:0){w=gM(f,(d[m>>0]|0)+-48|0)|0;m=p+3|0;break e}v=(c[f>>2]|0)+(4-1)&~(4-1);w=c[v>>2]|0;c[f>>2]=v+4}}while(0);if(!(_J(d[m>>0]|0)|0))s=0;else{k=0;do{k=(k*10|0)+-48+(d[m>>0]|0)|0;m=m+1|0}while((_J(d[m>>0]|0)|0)!=0);s=k}p=a[m>>0]|0;n=m+1|0;if(p<<24>>24==109){k=(w|0)!=0&1;j=0;m=n;p=a[n>>0]|0;i=0}else k=0;n=m+1|0;switch(p<<24>>24){case 104:{v=(a[n>>0]|0)==104;p=v?-2:-1;m=v?m+2|0:n;break}case 108:{v=(a[n>>0]|0)==108;p=v?3:1;m=v?m+2|0:n;break}case 106:{p=3;m=n;break}case 116:case 122:{p=1;m=n;break}case 76:{p=2;m=n;break}case 110:case 112:case 67:case 83:case 91:case 99:case 115:case 88:case 71:case 70:case 69:case 65:case 103:case 102:case 101:case 97:case 120:case 117:case 111:case 105:case 100:{p=0;break}default:{J=136;break b}}r=d[m>>0]|0;t=(r&47|0)==3;r=t?r|32:r;t=t?1:p;q=r&255;switch(q<<24>>24){case 99:{s=(s|0)>1?s:1;break}case 91:break;case 110:{hM(w,t,u,((u|0)<0)<<31>>31);n=u;break c}default:{aK(b,0);do{n=c[y>>2]|0;if(n>>>0<(c[A>>2]|0)>>>0){c[y>>2]=n+1;n=d[n>>0]|0}else n=cK(b)|0}while((XJ(n)|0)!=0);if(!(c[A>>2]|0))n=c[y>>2]|0;else{n=(c[y>>2]|0)+-1|0;c[y>>2]=n}u=(c[B>>2]|0)+u+n-(c[C>>2]|0)|0}}aK(b,s);p=c[y>>2]|0;n=c[A>>2]|0;if(p>>>0>>0)c[y>>2]=p+1;else{if((cK(b)|0)<0){J=136;break b}n=c[A>>2]|0}if(n|0)c[y>>2]=(c[y>>2]|0)+-1;f:do switch(q<<24>>24){case 91:case 99:case 115:{v=(r|0)==99;g:do if((r|16|0)==115){VN(G|0,-1,257)|0;a[G>>0]=0;if((r|0)==115){a[E>>0]=0;a[D>>0]=0;a[D+1>>0]=0;a[D+2>>0]=0;a[D+3>>0]=0;a[D+4>>0]=0}}else{n=m+1|0;q=(a[n>>0]|0)==94;r=q&1;m=q?m+2|0:n;VN(G|0,r|0,257)|0;a[G>>0]=0;n=a[m>>0]|0;switch(n<<24>>24){case 45:{n=46;J=65;break}case 93:{n=94;J=65;break}default:{}}while(1){if((J|0)==65){J=0;a[G+n>>0]=r^1;n=m+1|0;m=n;n=a[n>>0]|0}h:do switch(n<<24>>24){case 0:{J=136;break b}case 93:break g;case 45:{q=m+1|0;n=a[q>>0]|0;switch(n<<24>>24){case 93:case 0:{n=45;break h}default:{}}m=a[m+-1>>0]|0;if((m&255)<(n&255)){p=(r^1)&255;m=m&255;do{m=m+1|0;a[G+m>>0]=p;n=a[q>>0]|0}while((m|0)<(n&255|0));m=q}else m=q;break}default:{}}while(0);n=(n&255)+1|0;J=65}}while(0);n=v?s+1|0:31;r=(t|0)==1;t=(k|0)!=0;i:do if(r){if(t){i=ZI(n<<2)|0;if(!i){j=0;i=0;J=136;break b}}else i=w;c[F>>2]=0;c[x>>2]=0;q=n;j=0;j:while(1){p=(i|0)==0;do{k:while(1){n=c[y>>2]|0;if(n>>>0<(c[A>>2]|0)>>>0){c[y>>2]=n+1;n=d[n>>0]|0}else n=cK(b)|0;if(!(a[G+(n+1)>>0]|0))break j;a[I>>0]=n;switch(rK(H,I,1,F)|0){case -1:{j=0;J=136;break b}case -2:break;default:break k}}if(!p){c[i+(j<<2)>>2]=c[H>>2];j=j+1|0}}while(!(t&(j|0)==(q|0)));j=q<<1|1;n=aJ(i,j<<2)|0;if(!n){j=0;J=136;break b}else{p=q;q=j;i=n;j=p}}if(!(iM(F)|0)){j=0;J=136;break b}else{q=j;j=0;p=i}}else{if(t){j=ZI(n)|0;if(!j){j=0;i=0;J=136;break b}else{p=n;i=0}while(1){do{n=c[y>>2]|0;if(n>>>0<(c[A>>2]|0)>>>0){c[y>>2]=n+1;n=d[n>>0]|0}else n=cK(b)|0;if(!(a[G+(n+1)>>0]|0)){q=i;p=0;i=0;break i}a[j+i>>0]=n;i=i+1|0}while((i|0)!=(p|0));i=p<<1|1;n=aJ(j,i)|0;if(!n){i=0;J=136;break b}else{q=p;p=i;j=n;i=q}}}if(!w)while(1){i=c[y>>2]|0;if(i>>>0<(c[A>>2]|0)>>>0){c[y>>2]=i+1;i=d[i>>0]|0}else i=cK(b)|0;if(!(a[G+(i+1)>>0]|0)){q=0;j=0;p=0;i=0;break i}}else j=0;while(1){i=c[y>>2]|0;if(i>>>0<(c[A>>2]|0)>>>0){c[y>>2]=i+1;i=d[i>>0]|0}else i=cK(b)|0;if(!(a[G+(i+1)>>0]|0)){q=j;j=w;p=0;i=0;break i}a[w+j>>0]=i;j=j+1|0}}while(0);if(!(c[A>>2]|0))n=c[y>>2]|0;else{n=(c[y>>2]|0)+-1|0;c[y>>2]=n}n=n-(c[C>>2]|0)+(c[B>>2]|0)|0;if(!n)break b;if(!((n|0)==(s|0)|v^1))break b;do if(t)if(r){c[w>>2]=p;break}else{c[w>>2]=j;break}while(0);if(!v){if(p|0)c[p+(q<<2)>>2]=0;if(!j){j=0;break f}a[j+q>>0]=0}break}case 120:case 88:case 112:{n=16;J=124;break}case 111:{n=8;J=124;break}case 117:case 100:{n=10;J=124;break}case 105:{n=0;J=124;break}case 71:case 103:case 70:case 102:case 69:case 101:case 65:case 97:{o=+jM(b,t,0);if((c[B>>2]|0)==((c[C>>2]|0)-(c[y>>2]|0)|0))break b;if(w)switch(t|0){case 0:{g[w>>2]=o;break f}case 1:{h[w>>3]=o;break f}case 2:{h[w>>3]=o;break f}default:break f}break}default:{}}while(0);do if((J|0)==124){J=0;n=bK(b,n,0,-1,-1)|0;if((c[B>>2]|0)==((c[C>>2]|0)-(c[y>>2]|0)|0))break b;if((w|0)!=0&(r|0)==112){c[w>>2]=n;break}else{hM(w,t,n,z);break}}while(0);e=e+((w|0)!=0&1)|0;n=(c[B>>2]|0)+u+(c[y>>2]|0)-(c[C>>2]|0)|0;break c}while(0);m=p+(k&1)|0;aK(b,0);k=c[y>>2]|0;if(k>>>0<(c[A>>2]|0)>>>0){c[y>>2]=k+1;k=d[k>>0]|0}else k=cK(b)|0;if((k|0)!=(d[m>>0]|0)){J=22;break b}n=u+1|0}else{m=p;while(1){k=m+1|0;if(!(XJ(d[k>>0]|0)|0))break;else m=k}aK(b,0);do{k=c[y>>2]|0;if(k>>>0<(c[A>>2]|0)>>>0){c[y>>2]=k+1;k=d[k>>0]|0}else k=cK(b)|0}while((XJ(k)|0)!=0);if(!(c[A>>2]|0))k=c[y>>2]|0;else{k=(c[y>>2]|0)+-1|0;c[y>>2]=k}n=(c[B>>2]|0)+u+k-(c[C>>2]|0)|0}while(0);p=m+1|0;k=a[p>>0]|0;if(!(k<<24>>24))break a;else u=n}if((J|0)==22){if(c[A>>2]|0)c[y>>2]=(c[y>>2]|0)+-1;if((e|0)!=0|(k|0)>-1)break;else{e=0;J=137}}else if((J|0)==136)if(!e){e=k;J=137}if((J|0)==137){k=e;e=-1}if(k){_I(j);_I(i)}}else e=0;while(0);if(K|0)PK(b);l=L;return e|0}function gM(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;e=l;l=l+16|0;d=e;c[d>>2]=c[a>>2];while(1){f=(c[d>>2]|0)+(4-1)&~(4-1);a=c[f>>2]|0;c[d>>2]=f+4;if(b>>>0>1)b=b+-1|0;else break}l=e;return a|0}function hM(d,e,f,g){d=d|0;e=e|0;f=f|0;g=g|0;a:do if(d|0)switch(e|0){case -2:{a[d>>0]=f;break a}case -1:{b[d>>1]=f;break a}case 0:{c[d>>2]=f;break a}case 1:{c[d>>2]=f;break a}case 3:{e=d;c[e>>2]=f;c[e+4>>2]=g;break a}default:break a}while(0);return}function iM(a){a=a|0;if(!a)a=1;else a=(c[a>>2]|0)==0&1;return a|0}function jM(b,e,f){b=b|0;e=e|0;f=f|0;var g=0.0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;switch(e|0){case 0:{l=-149;m=24;j=4;break}case 1:{l=-1074;m=53;j=4;break}case 2:{l=-1074;m=53;j=4;break}default:g=0.0}a:do if((j|0)==4){o=b+4|0;n=b+100|0;do{e=c[o>>2]|0;if(e>>>0<(c[n>>2]|0)>>>0){c[o>>2]=e+1;e=d[e>>0]|0}else e=cK(b)|0}while((XJ(e)|0)!=0);b:do switch(e|0){case 43:case 45:{i=1-(((e|0)==45&1)<<1)|0;e=c[o>>2]|0;if(e>>>0<(c[n>>2]|0)>>>0){c[o>>2]=e+1;h=d[e>>0]|0;break b}else{h=cK(b)|0;break b}}default:{h=e;i=1}}while(0);e=0;do{if((h|32|0)!=(a[134886+e>>0]|0))break;do if(e>>>0<7){h=c[o>>2]|0;if(h>>>0<(c[n>>2]|0)>>>0){c[o>>2]=h+1;h=d[h>>0]|0;break}else{h=cK(b)|0;break}}while(0);e=e+1|0}while(e>>>0<8);c:do switch(e|0){case 8:break;case 3:{j=23;break}default:{k=(f|0)!=0;if(k&e>>>0>3)if((e|0)==8)break c;else{j=23;break c}d:do if(!e){e=0;do{if((h|32|0)!=(a[134895+e>>0]|0))break d;do if(e>>>0<2){h=c[o>>2]|0;if(h>>>0<(c[n>>2]|0)>>>0){c[o>>2]=h+1;h=d[h>>0]|0;break}else{h=cK(b)|0;break}}while(0);e=e+1|0}while(e>>>0<3)}while(0);switch(e|0){case 3:{e=c[o>>2]|0;if(e>>>0<(c[n>>2]|0)>>>0){c[o>>2]=e+1;e=d[e>>0]|0}else e=cK(b)|0;if((e|0)==40)e=1;else{if(!(c[n>>2]|0)){g=s;break a}c[o>>2]=(c[o>>2]|0)+-1;g=s;break a}while(1){h=c[o>>2]|0;if(h>>>0<(c[n>>2]|0)>>>0){c[o>>2]=h+1;h=d[h>>0]|0}else h=cK(b)|0;if(!((h+-48|0)>>>0<10|(h+-65|0)>>>0<26)?!((h|0)==95|(h+-97|0)>>>0<26):0)break;e=e+1|0}if((h|0)==41){g=s;break a}h=(c[n>>2]|0)==0;if(!h)c[o>>2]=(c[o>>2]|0)+-1;if(!k){c[(jJ()|0)>>2]=22;aK(b,0);g=0.0;break a}if(!e){g=s;break a}while(1){e=e+-1|0;if(!h)c[o>>2]=(c[o>>2]|0)+-1;if(!e){g=s;break a}}}case 0:{if((h|0)==48){e=c[o>>2]|0;if(e>>>0<(c[n>>2]|0)>>>0){c[o>>2]=e+1;e=d[e>>0]|0}else e=cK(b)|0;if((e|32|0)==120){g=+kM(b,m,l,i,f);break a}if(!(c[n>>2]|0))e=48;else{c[o>>2]=(c[o>>2]|0)+-1;e=48}}else e=h;g=+lM(b,e,m,l,i,f);break a}default:{if(c[n>>2]|0)c[o>>2]=(c[o>>2]|0)+-1;c[(jJ()|0)>>2]=22;aK(b,0);g=0.0;break a}}}}while(0);if((j|0)==23){h=(c[n>>2]|0)==0;if(!h)c[o>>2]=(c[o>>2]|0)+-1;if((f|0)!=0&e>>>0>3)do{if(!h)c[o>>2]=(c[o>>2]|0)+-1;e=e+-1|0}while(e>>>0>3)}g=+(i|0)*t}while(0);return +g}function kM(a,b,e,f,g){a=a|0;b=b|0;e=e|0;f=f|0;g=g|0;var h=0.0,i=0,j=0,k=0.0,l=0,m=0,n=0,o=0.0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;y=a+4|0;i=c[y>>2]|0;x=a+100|0;if(i>>>0<(c[x>>2]|0)>>>0){c[y>>2]=i+1;j=d[i>>0]|0;l=0}else{j=cK(a)|0;l=0}a:while(1){switch(j|0){case 46:{w=8;break a}case 48:break;default:{s=0;n=0;o=1.0;h=0.0;i=0;m=j;t=l;v=0;u=0;l=0;j=0;break a}}i=c[y>>2]|0;if(i>>>0<(c[x>>2]|0)>>>0){c[y>>2]=i+1;j=d[i>>0]|0;l=1;continue}else{j=cK(a)|0;l=1;continue}}if((w|0)==8){i=c[y>>2]|0;if(i>>>0<(c[x>>2]|0)>>>0){c[y>>2]=i+1;j=d[i>>0]|0}else j=cK(a)|0;if((j|0)==48){l=0;j=0;do{i=c[y>>2]|0;if(i>>>0<(c[x>>2]|0)>>>0){c[y>>2]=i+1;m=d[i>>0]|0}else m=cK(a)|0;l=HN(l|0,j|0,-1,-1)|0;j=z}while((m|0)==48);s=1;n=0;o=1.0;h=0.0;i=0;t=1;v=0;u=0}else{s=1;n=0;o=1.0;h=0.0;i=0;m=j;t=l;v=0;u=0;l=0;j=0}}while(1){q=m+-48|0;p=m|32;if(q>>>0>=10){r=(m|0)==46;if(!(r|(p+-97|0)>>>0<6))break;if(r)if(!s){s=1;k=o;r=t;l=u;j=v;q=u;p=v}else{m=46;break}else w=20}else w=20;if((w|0)==20){w=0;m=(m|0)>57?p+-87|0:q;do if(!((v|0)<0|(v|0)==0&u>>>0<8))if((v|0)<0|(v|0)==0&u>>>0<14){o=o*.0625;k=o;h=h+o*+(m|0);break}else{t=(n|0)!=0|(m|0)==0;n=t?n:1;k=o;h=t?h:h+o*.5;break}else{k=o;i=m+(i<<4)|0}while(0);q=HN(u|0,v|0,1,0)|0;r=1;p=z}m=c[y>>2]|0;if(m>>>0<(c[x>>2]|0)>>>0){c[y>>2]=m+1;o=k;m=d[m>>0]|0;t=r;v=p;u=q;continue}else{o=k;m=cK(a)|0;t=r;v=p;u=q;continue}}do if(!t){i=(c[x>>2]|0)==0;if(!i)c[y>>2]=(c[y>>2]|0)+-1;if(g){if(!i)c[y>>2]=(c[y>>2]|0)+-1;if(!((s|0)==0|i))c[y>>2]=(c[y>>2]|0)+-1}else aK(a,0);h=+(f|0)*0.0}else{p=(s|0)==0;q=p?u:l;p=p?v:j;if((v|0)<0|(v|0)==0&u>>>0<8){l=u;j=v;while(1){i=i<<4;w=l;l=HN(l|0,j|0,1,0)|0;if(!((j|0)<0|(j|0)==0&w>>>0<7)){n=i;break}else j=z}}else n=i;if((m|32|0)==112){j=mM(a,g)|0;i=z;if((j|0)==0&(i|0)==-2147483648){if(!g){aK(a,0);h=0.0;break}if(!(c[x>>2]|0)){j=0;i=0}else{c[y>>2]=(c[y>>2]|0)+-1;j=0;i=0}}}else if(!(c[x>>2]|0)){j=0;i=0}else{c[y>>2]=(c[y>>2]|0)+-1;j=0;i=0}l=ON(q|0,p|0,2)|0;l=HN(l|0,z|0,-32,-1)|0;l=HN(l|0,z|0,j|0,i|0)|0;i=z;if(!n){h=+(f|0)*0.0;break}y=0-e|0;g=((y|0)<0)<<31>>31;if((i|0)>(g|0)|(i|0)==(g|0)&l>>>0>y>>>0){c[(jJ()|0)>>2]=34;h=+(f|0)*1797693134862315708145274.0e284*1797693134862315708145274.0e284;break}y=e+-106|0;g=((y|0)<0)<<31>>31;if((i|0)<(g|0)|(i|0)==(g|0)&l>>>0>>0){c[(jJ()|0)>>2]=34;h=+(f|0)*2.2250738585072014e-308*2.2250738585072014e-308;break}if((n|0)>-1){j=n;do{y=!(h>=.5);j=j<<1|(y^1)&1;h=h+(y?h:h+-1.0);l=HN(l|0,i|0,-1,-1)|0;i=z}while((j|0)>-1);o=h;m=j}else{o=h;m=n}y=((b|0)<0)<<31>>31;e=IN(32,0,e|0,((e|0)<0)<<31>>31|0)|0;i=HN(e|0,z|0,l|0,i|0)|0;e=z;if((e|0)<(y|0)|(e|0)==(y|0)&i>>>0>>0)if((i|0)>0)w=59;else{j=0;i=84;w=61}else{i=b;w=59}if((w|0)==59)if((i|0)<53){j=i;i=84-i|0;w=61}else{k=0.0;h=+(f|0)}if((w|0)==61){h=+(f|0);k=+LJ(+IJ(1.0,i),h);i=j}f=(m&1|0)==0&(o!=0.0&(i|0)<32);h=(f?0.0:o)*h+(k+h*+((m+(f&1)|0)>>>0))-k;if(!(h!=0.0))c[(jJ()|0)>>2]=34;h=+MJ(h,l)}while(0);return +h}function lM(a,b,e,f,g,h){a=a|0;b=b|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0.0,j=0.0,k=0,m=0,n=0,o=0,p=0,q=0,r=0.0,s=0.0,t=0.0,u=0,v=0,w=0,x=0,y=0,A=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0.0;J=l;l=l+512|0;G=J;H=f+e|0;I=0-H|0;D=a+4|0;E=a+100|0;k=0;a:while(1){switch(b|0){case 46:{A=6;break a}case 48:break;default:{v=0;p=k;q=0;o=0;break a}}b=c[D>>2]|0;if(b>>>0<(c[E>>2]|0)>>>0){c[D>>2]=b+1;b=d[b>>0]|0;k=1;continue}else{b=cK(a)|0;k=1;continue}}if((A|0)==6){b=c[D>>2]|0;if(b>>>0<(c[E>>2]|0)>>>0){c[D>>2]=b+1;b=d[b>>0]|0}else b=cK(a)|0;if((b|0)==48){k=0;b=0;while(1){k=HN(k|0,b|0,-1,-1)|0;o=z;b=c[D>>2]|0;if(b>>>0<(c[E>>2]|0)>>>0){c[D>>2]=b+1;b=d[b>>0]|0}else b=cK(a)|0;if((b|0)==48)b=o;else{v=1;p=1;q=k;break}}}else{v=1;p=k;q=0;o=0}}c[G>>2]=0;n=b+-48|0;m=(b|0)==46;b:do if(m|n>>>0<10){C=G+496|0;w=0;k=0;u=0;x=v;y=p;A=n;p=0;n=0;c:while(1){do if(m)if(!x){x=1;q=p;o=n}else break c;else{p=HN(p|0,n|0,1,0)|0;n=z;v=(b|0)!=48;if((k|0)>=125){if(!v)break;c[C>>2]=c[C>>2]|1;break}m=G+(k<<2)|0;if(!w)b=A;else b=b+-48+((c[m>>2]|0)*10|0)|0;c[m>>2]=b;w=w+1|0;y=(w|0)==9;w=y?0:w;k=k+(y&1)|0;u=v?p:u;y=1}while(0);b=c[D>>2]|0;if(b>>>0<(c[E>>2]|0)>>>0){c[D>>2]=b+1;b=d[b>>0]|0}else b=cK(a)|0;A=b+-48|0;m=(b|0)==46;if(!(m|A>>>0<10)){v=x;m=y;A=29;break b}}b=w;m=(y|0)!=0;A=37}else{w=0;k=0;u=0;m=p;p=0;n=0;A=29}while(0);do if((A|0)==29){C=(v|0)==0;q=C?p:q;o=C?n:o;m=(m|0)!=0;if(!(m&(b|32|0)==101))if((b|0)>-1){b=w;A=37;break}else{b=w;A=39;break}m=mM(a,h)|0;b=z;if((m|0)==0&(b|0)==-2147483648){if(!h){aK(a,0);i=0.0;break}if(!(c[E>>2]|0)){m=0;b=0}else{c[D>>2]=(c[D>>2]|0)+-1;m=0;b=0}}y=HN(m|0,b|0,q|0,o|0)|0;b=w;o=z;A=41}while(0);if((A|0)==37)if(c[E>>2]|0){c[D>>2]=(c[D>>2]|0)+-1;if(m){y=q;A=41}else A=40}else A=39;if((A|0)==39)if(m){y=q;A=41}else A=40;do if((A|0)==40){c[(jJ()|0)>>2]=22;aK(a,0);i=0.0}else if((A|0)==41){m=c[G>>2]|0;if(!m){i=+(g|0)*0.0;break}if(((n|0)<0|(n|0)==0&p>>>0<10)&((y|0)==(p|0)&(o|0)==(n|0))?(e|0)>30|(m>>>e|0)==0:0){i=+(g|0)*+(m>>>0);break}a=(f|0)/-2|0;E=((a|0)<0)<<31>>31;if((o|0)>(E|0)|(o|0)==(E|0)&y>>>0>a>>>0){c[(jJ()|0)>>2]=34;i=+(g|0)*1797693134862315708145274.0e284*1797693134862315708145274.0e284;break}a=f+-106|0;E=((a|0)<0)<<31>>31;if((o|0)<(E|0)|(o|0)==(E|0)&y>>>0>>0){c[(jJ()|0)>>2]=34;i=+(g|0)*2.2250738585072014e-308*2.2250738585072014e-308;break}if(b){if((b|0)<9){n=G+(k<<2)|0;m=c[n>>2]|0;while(1){m=m*10|0;if((b|0)>=8)break;else b=b+1|0}c[n>>2]=m}k=k+1|0}if((u|0)<9?(u|0)<=(y|0)&(y|0)<18:0){if((y|0)==9){i=+(g|0)*+((c[G>>2]|0)>>>0);break}if((y|0)<9){i=+(g|0)*+((c[G>>2]|0)>>>0)/+(c[56536+(8-y<<2)>>2]|0);break}a=e+27+(O(y,-3)|0)|0;b=c[G>>2]|0;if((a|0)>30|(b>>>a|0)==0){i=+(g|0)*+(b>>>0)*+(c[56536+(y+-10<<2)>>2]|0);break}}b=(y|0)%9|0;if(!b){b=0;n=0}else{u=(y|0)>-1?b:b+9|0;p=c[56536+(8-u<<2)>>2]|0;if(k){q=1e9/(p|0)|0;n=0;o=0;m=y;b=0;do{D=G+(b<<2)|0;E=c[D>>2]|0;a=((E>>>0)/(p>>>0)|0)+n|0;c[D>>2]=a;n=O(q,(E>>>0)%(p>>>0)|0)|0;a=(b|0)==(o|0)&(a|0)==0;m=a?m+-9|0:m;o=a?o+1&127:o;b=b+1|0}while((b|0)!=(k|0));if(!n)n=o;else{c[G+(k<<2)>>2]=n;n=o;k=k+1|0}}else{n=0;k=0;m=y}b=0;y=9-u+m|0}d:while(1){u=(y|0)<18;v=(y|0)==18;w=G+(n<<2)|0;while(1){if(!u){if(!v){m=y;break d}if((c[w>>2]|0)>>>0>=9007199){m=18;break d}}m=0;x=k;k=k+127|0;while(1){o=k&127;p=G+(o<<2)|0;k=ON(c[p>>2]|0,0,29)|0;k=HN(k|0,z|0,m|0,0)|0;m=z;if(m>>>0>0|(m|0)==0&k>>>0>1e9){q=LN(k|0,m|0,1e9,0)|0;k=MN(k|0,m|0,1e9,0)|0}else q=0;c[p>>2]=k;a=(o|0)==(n|0);x=(k|0)==0&(((o|0)!=(x+127&127|0)|a)^1)?o:x;if(a)break;else{m=q;k=o+-1|0}}b=b+-29|0;if(q|0)break;else k=x}n=n+127&127;k=x+127&127;m=G+((x+126&127)<<2)|0;if((n|0)==(x|0))c[m>>2]=c[m>>2]|c[G+(k<<2)>>2];else k=x;c[G+(n<<2)>>2]=q;y=y+9|0}e:while(1){w=k+1&127;x=G+((k+127&127)<<2)|0;while(1){q=(m|0)==18;v=(m|0)>27?9:1;y=n;while(1){p=0;while(1){n=p+y&127;if((n|0)==(k|0)){F=2;A=88;break}n=c[G+(n<<2)>>2]|0;o=c[56568+(p<<2)>>2]|0;if(n>>>0>>0){F=2;A=88;break}if(n>>>0>o>>>0)break;n=p+1|0;if((p|0)<1)p=n;else{F=n;A=88;break}}if((A|0)==88?(A=0,q&(F|0)==2):0){i=0.0;o=0;break e}b=v+b|0;if((y|0)==(k|0))y=k;else break}q=(1<>>v;p=0;n=y;o=y;do{D=G+(o<<2)|0;E=c[D>>2]|0;a=(E>>>v)+p|0;c[D>>2]=a;p=O(E&q,u)|0;a=(o|0)==(n|0)&(a|0)==0;m=a?m+-9|0:m;n=a?n+1&127:n;o=o+1&127}while((o|0)!=(k|0));if(!p)continue;if((w|0)!=(n|0))break;c[x>>2]=c[x>>2]|1}c[G+(k<<2)>>2]=p;k=w}do{n=o+y&127;m=k+1&127;if((n|0)==(k|0)){c[G+(m+-1<<2)>>2]=0;k=m}i=i*1.0e9+ +((c[G+(n<<2)>>2]|0)>>>0);o=o+1|0}while((o|0)!=2);t=+(g|0);j=i*t;o=b+53|0;p=o-f|0;q=(p|0)<(e|0);n=q?((p|0)>0?p:0):e;if((n|0)<53){K=+LJ(+IJ(1.0,105-n|0),j);r=+NJ(j,+IJ(1.0,53-n|0));s=K;i=r;r=K+(j-r)}else{s=0.0;i=0.0;r=j}m=y+2&127;if((m|0)!=(k|0)){m=c[G+(m<<2)>>2]|0;do if(m>>>0>=5e8){if((m|0)!=5e8){i=t*.75+i;break}if((y+3&127|0)==(k|0)){i=t*.5+i;break}else{i=t*.75+i;break}}else{if((m|0)==0?(y+3&127|0)==(k|0):0)break;i=t*.25+i}while(0);if((53-n|0)>1?!(+NJ(i,1.0)!=0.0):0)j=i+1.0;else j=i}else j=i;i=r+j-s;do if((o&2147483647|0)>(-2-H|0)){H=!(+B(+i)>=9007199254740992.0);b=b+((H^1)&1)|0;i=H?i:i*.5;if((b+50|0)<=(I|0)?!(j!=0.0&(q&((n|0)!=(p|0)|H))):0)break;c[(jJ()|0)>>2]=34}while(0);i=+MJ(i,b)}while(0);l=J;return +i}function mM(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,h=0,i=0;h=a+4|0;e=c[h>>2]|0;i=a+100|0;if(e>>>0<(c[i>>2]|0)>>>0){c[h>>2]=e+1;e=d[e>>0]|0}else e=cK(a)|0;switch(e|0){case 43:case 45:{f=(e|0)==45&1;e=c[h>>2]|0;if(e>>>0<(c[i>>2]|0)>>>0){c[h>>2]=e+1;e=d[e>>0]|0}else e=cK(a)|0;if((b|0)!=0&(e+-48|0)>>>0>9?(c[i>>2]|0)!=0:0)c[h>>2]=(c[h>>2]|0)+-1;break}default:f=0}if((e+-48|0)>>>0>9)if(!(c[i>>2]|0)){f=-2147483648;e=0}else{c[h>>2]=(c[h>>2]|0)+-1;f=-2147483648;e=0}else{g=0;do{g=e+-48+(g*10|0)|0;e=c[h>>2]|0;if(e>>>0<(c[i>>2]|0)>>>0){c[h>>2]=e+1;e=d[e>>0]|0}else e=cK(a)|0}while((e+-48|0)>>>0<10&(g|0)<214748364);b=((g|0)<0)<<31>>31;if((e+-48|0)>>>0<10)do{b=GN(g|0,b|0,10,0)|0;g=z;e=HN(e|0,((e|0)<0)<<31>>31|0,-48,-1)|0;g=HN(e|0,z|0,b|0,g|0)|0;b=z;e=c[h>>2]|0;if(e>>>0<(c[i>>2]|0)>>>0){c[h>>2]=e+1;e=d[e>>0]|0}else e=cK(a)|0}while((e+-48|0)>>>0<10&((b|0)<21474836|(b|0)==21474836&g>>>0<2061584302));if((e+-48|0)>>>0<10)do{e=c[h>>2]|0;if(e>>>0<(c[i>>2]|0)>>>0){c[h>>2]=e+1;e=d[e>>0]|0}else e=cK(a)|0}while((e+-48|0)>>>0<10);if(c[i>>2]|0)c[h>>2]=(c[h>>2]|0)+-1;i=(f|0)!=0;e=IN(0,0,g|0,b|0)|0;f=i?z:b;e=i?e:g}z=f;return e|0}function nM(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0;e=a+84|0;g=c[e>>2]|0;h=d+256|0;f=ZJ(g,0,h)|0;f=(f|0)==0?h:f-g|0;d=f>>>0>>0?f:d;TN(b|0,g|0,d|0)|0;c[a+4>>2]=g+d;b=g+f|0;c[a+8>>2]=b;c[e>>2]=b;return d|0}function oM(a,b,c){a=a|0;b=b|0;c=c|0;return pM(a,b,c)|0}function pM(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;if((c[a+76>>2]|0)>-1){e=(OK(a)|0)==0;b=qM(a,b,d)|0;if(!e)PK(a)}else b=qM(a,b,d)|0;return b|0}function qM(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;if((d|0)==1)b=b-(c[a+8>>2]|0)+(c[a+4>>2]|0)|0;e=a+20|0;f=a+28|0;if((c[e>>2]|0)>>>0>(c[f>>2]|0)>>>0?(bb[c[a+36>>2]&31](a,0,0)|0,(c[e>>2]|0)==0):0)b=-1;else{c[a+16>>2]=0;c[f>>2]=0;c[e>>2]=0;if((bb[c[a+40>>2]&31](a,b,d)|0)<0)b=-1;else{c[a+8>>2]=0;c[a+4>>2]=0;c[a>>2]=c[a>>2]&-17;b=0}}return b|0}function rM(b){b=b|0;var c=0,d=0,e=0,f=0,g=0;while(1){e=b+1|0;if(!(XJ(a[b>>0]|0)|0))break;else b=e}d=a[b>>0]|0;switch(d<<24>>24|0){case 45:{b=1;f=5;break}case 43:{b=0;f=5;break}default:{g=0;c=b;b=d}}if((f|0)==5){g=b;c=e;b=a[e>>0]|0}if(!(_J(b<<24>>24)|0))b=0;else{b=0;do{b=(b*10|0)+48-(a[c>>0]|0)|0;c=c+1|0}while((_J(a[c>>0]|0)|0)!=0)}return (g|0?b:0-b|0)|0}function sM(a){a=a|0;return +(+tM(a,0))}function tM(a,b){a=a|0;b=b|0;return +(+uM(a,b,1))}function uM(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0,g=0,h=0,i=0;i=l;l=l+128|0;h=i;f=h;g=f+124|0;do{c[f>>2]=0;f=f+4|0}while((f|0)<(g|0));f=h+4|0;c[f>>2]=a;g=h+8|0;c[g>>2]=-1;c[h+44>>2]=a;c[h+76>>2]=-1;aK(h,0);e=+jM(h,d,1);d=(c[f>>2]|0)-(c[g>>2]|0)+(c[h+108>>2]|0)|0;if(b|0)c[b>>2]=d|0?a+d|0:a;l=i;return +e}function vM(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0;a:do if(!c)b=0;else{h=b;while(1){g=c>>>1;b=h+(O(g,d)|0)|0;f=ab[e&63](a,b)|0;if(!f)break a;if((c|0)==1){b=0;break a}f=(f|0)<0;c=f?g:c-g|0;if(!c){b=0;break}else h=f?h:b}}while(0);return b|0}function wM(a,c){a=a|0;c=c|0;var d=0,f=0,g=0;g=a+2|0;f=a+4|0;d=GN((e[c+2>>1]|0)<<16|(e[c>>1]|0)|0,e[c+4>>1]|0|0,(e[g>>1]|0)<<16|(e[a>>1]|0)|0,e[f>>1]|0|0)|0;c=HN(d|0,z|0,e[c+6>>1]|0|0,0)|0;d=z;b[a>>1]=c;a=NN(c|0,d|0,16)|0;b[g>>1]=a;b[f>>1]=d;z=d&65535;return c|0}function xM(a){a=a|0;TN(173876,58668,6)|0;TN(58668,a|0,6)|0;return 173876}function yM(a){a=a|0;var c=0,d=0;c=l;l=l+16|0;d=c;b[d>>1]=13070;b[d+2>>1]=a;b[d+4>>1]=a>>>16;xM(d)|0;l=c;return}function zM(a){a=a|0;var b=0;b=wM(a,58674)|0;b=ON(b|0,z|0,4)|0;a=z|1072693248;c[j>>2]=b;c[j+4>>2]=a;return +(+h[j>>3]+-1.0)}function AM(){return +(+zM(58668))}function BM(a,b){a=a|0;b=b|0;if(!a)b=$I(1,24)|0;else VN(b|0,0,24)|0;return b|0}function CM(a){a=a|0;var b=0,d=0;b=c[a>>2]|0;if(b|0)do{_I(c[b>>2]|0);d=b;b=c[b+4>>2]|0;_I(d)}while((b|0)!=0);_I(a);return}function DM(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0;h=a+16|0;a:do if(!(c[h>>2]|0)){k=a+12|0;g=c[k>>2]|0;if(g>>>0>>0){do if(b)if(!d){c[h>>2]=1;b=0;break a}else{h=a+8|0;c[h>>2]=d;g=1024;b=d;break}else{g=f<<3;g=g>>>0>1024?g:1024;j=ZI(8)|0;if(!j){c[h>>2]=1;b=0;break a}b=ZI(g)|0;c[j>>2]=b;d=b;if(!b){_I(j);c[h>>2]=1;b=0;break a}c[j+4>>2]=0;h=a+4|0;i=c[h>>2]|0;if(i|0)c[i+4>>2]=j;if(!(c[a>>2]|0))c[a>>2]=j;c[h>>2]=j;h=a+8|0;c[h>>2]=d}while(0);c[k>>2]=g}else{h=a+8|0;b=c[h>>2]|0;d=b}d=d+f&3;d=((d|0)==0?0:4-d|0)+f|0;c[h>>2]=b+d;c[k>>2]=g-d;if(e)VN(b|0,0,d|0)|0}else b=0;while(0);return b|0}function EM(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;v=l;l=l+48|0;h=v;t=FM()|0;a:do if(!t)b=12;else{u=BM(0,0)|0;if(!u){GM(t);b=12;break}VN(h|0,0,36)|0;c[h>>2]=u;c[h+4>>2]=t;c[h+16>>2]=b;c[h+32>>2]=d;e=h+28|0;c[e>>2]=-1;b=HM(h)|0;b:do if(!b){g=h+20|0;r=c[g>>2]|0;c[a>>2]=r+-1;i=c[h+8>>2]|0;if((c[e>>2]|0)<(r|0)){r=$I(1,68)|0;if(r){q=(c[e>>2]|0)>>>31^1;c[r+60>>2]=q;c[r+64>>2]=0;c[r+28>>2]=c[g>>2];if((d&8|0)==0|(q|0)!=0){b=IM(0,t,i,r)|0;if(b|0){g=r;h=0;i=0;f=0;e=0;break}e=r+40|0;b=c[e>>2]|0;if((b|0)>0){b=ZI((b<<2)+4|0)|0;if(!b){g=r;h=0;i=0;b=12;f=0;e=0;break}c[r+32>>2]=b;VN(b|0,-1,(c[e>>2]<<2)+4|0)|0;f=b;b=c[e>>2]|0}else f=0;q=$I(b<<1|1,4)|0;c[r+36>>2]=q;if(!q){g=r;h=0;i=0;b=12;f=0;e=0;break}b=$I(c[g>>2]|0,12)|0;if(!b){g=r;h=0;i=0;b=12;f=0;e=0;break}c[r+16>>2]=b;b=IM(u,t,i,r)|0;if(!b)b=f;else{g=r;h=0;i=0;f=0;e=0;break}}else b=0;p=h+24|0;b=JM(u,t,i,p,b)|0;if(!b){b=c[p>>2]|0;c[p>>2]=b+1;b=KM(u,0,0,b)|0;if((b|0)!=0?(s=LM(u,i,b)|0,(s|0)!=0):0){b=MM(u,t,s)|0;if(!b){o=ZI(c[p>>2]<<2)|0;if(o){q=ZI(c[p>>2]<<2)|0;if(q){b=c[p>>2]|0;if((b|0)>0)VN(o|0,0,b<<2|0)|0;NM(s,0,o,0)|0;f=c[p>>2]|0;if((f|0)>0){b=0;e=0;do{c[q+(e<<2)>>2]=b;n=o+(e<<2)|0;b=b+1+(c[n>>2]|0)|0;c[n>>2]=0;e=e+1|0}while((e|0)<(f|0));k=b}else k=0;m=$I(k+1|0,32)|0;if(m){c[r>>2]=m;n=r+4|0;c[n>>2]=k;b=NM(s,m,o,q)|0;if(!b){c[r+20>>2]=0;f=s+24|0;b=c[f>>2]|0;e=0;while(1){e=e+1|0;if((c[b>>2]|0)<=-1)break;else b=b+32|0}j=$I(e,32)|0;if(!j){g=r;h=o;i=q;b=12;f=o;e=q}else{c[r+8>>2]=j;f=c[f>>2]|0;e=c[f>>2]|0;if((e|0)>-1){b=0;do{c[j+(b<<5)+8>>2]=m+(c[q+(e<<2)>>2]<<5);c[j+(b<<5)+12>>2]=e;h=j+(b<<5)+16|0;c[h>>2]=0;i=f+12|0;g=c[i>>2]|0;if(g|0){e=0;do{w=e;e=e+1|0}while((c[g+(w<<2)>>2]|0)>-1);e=e<<2;g=ZI(e)|0;c[h>>2]=g;if(!g){g=r;h=o;i=q;b=12;f=o;e=q;break b}TN(g|0,c[i>>2]|0,e|0)|0}c[j+(b<<5)+20>>2]=c[f+16>>2];b=b+1|0;f=f+32|0;e=c[f>>2]|0}while((e|0)>-1)}else b=0;c[j+(b<<5)+8>>2]=0;c[n>>2]=k;c[r+12>>2]=m+(c[q+(c[c[s+28>>2]>>2]<<2)>>2]<<5);c[r+52>>2]=c[p>>2];c[r+56>>2]=d;CM(u);GM(t);_I(o);_I(q);c[a+4>>2]=r;b=0;break a}}else{g=r;h=o;i=q;f=o;e=q}}else{g=r;h=o;i=q;b=12;f=o;e=q}}else{g=r;h=o;i=q;b=12;f=o;e=0}}else{g=r;h=o;i=0;b=12;f=0;e=0}}else{g=r;h=0;i=0;f=0;e=0}}else{g=r;h=0;i=0;b=12;f=0;e=0}}else{g=r;h=0;i=0;f=0;e=0}}else{g=r;h=0;i=0;b=12;f=0;e=0}}else{g=0;h=0;i=0;b=6;f=0;e=0}}else{g=0;h=0;i=0;f=0;e=0}while(0);CM(u);GM(t);if(h|0)_I(f);if(i|0)_I(e);c[a+4>>2]=g;OM(a)}while(0);l=v;return b|0}function FM(){var a=0,b=0;a=ZI(20)|0;do if(a){b=ZI(2048)|0;c[a+16>>2]=b;if(!b){_I(a);a=0;break}else{c[a>>2]=512;c[a+4>>2]=1024e3;c[a+8>>2]=128;c[a+12>>2]=0;break}}while(0);return a|0}function GM(a){a=a|0;_I(c[a+16>>2]|0);_I(a);return}function HM(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;u=l;l=l+16|0;p=u+4|0;q=u;r=c[b+32>>2]&1;s=b+16|0;e=c[s>>2]|0;t=c[b+4>>2]|0;d=SM(t,0)|0;a:do if(!d){m=(r|0)!=0;n=b+8|0;o=b+12|0;d=0;k=1;b:while(1){g=0;h=d;f=0;c:while(1){d=a[e>>0]|0;if(m){if(d<<24>>24==40)break;if((h|0)!=0&d<<24>>24==41)j=13;else j=14}else if(d<<24>>24==92)switch(a[e+1>>0]|0){case 40:break c;case 41:{j=13;break}default:j=14}else j=14;if((j|0)==13){j=0;i=KM(c[b>>2]|0,-1,-1,-1)|0;c[n>>2]=i;if(!i){d=12;break a}else i=f}else if((j|0)==14){j=0;d=fN(b,e)|0;if(d|0)break a;i=f;e=c[o>>2]|0}d:while(1){e:while(1){d=a[e>>0]|0;switch(d<<24>>24){case 42:case 92:break;default:{if(!m)break e;switch(d<<24>>24){case 123:case 63:case 43:break;default:break e}}}d=d<<24>>24==92;if(m&d)break;f=e+1|0;if(d)switch(a[f>>0]|0){case 123:case 63:case 43:break;default:break e}e=d?f:e;if((!m?(e|0)==((c[s>>2]|0)+1|0):0)?(a[e+-1>>0]|0)==94:0)break;if((a[e>>0]|0)==123){e=gN(e+1|0,r,p,q)|0;if(!e){j=28;break b}d=c[q>>2]|0;f=c[b>>2]|0;if(!d)d=KM(f,-1,-1,-1)|0;else j=36}else{c[p>>2]=0;c[q>>2]=-1;d=a[e>>0]|0;if(d<<24>>24==43){c[p>>2]=1;d=a[e>>0]|0}if(d<<24>>24==63){c[q>>2]=1;d=1}else d=-1;e=e+1|0;f=c[b>>2]|0;j=36}if((j|0)==36){j=0;d=aN(f,c[n>>2]|0,c[p>>2]|0,d,0)|0}c[n>>2]=d;if(!d){d=12;break a}}d=LM(c[b>>2]|0,g,c[n>>2]|0)|0;f=a[e>>0]|0;f:do if(m){if(f<<24>>24==124){j=40;break d}if((h|0)!=0&f<<24>>24==41|f<<24>>24==0)j=47;else{g=d;f=i;continue c}}else{switch(f<<24>>24){case 0:{j=47;break f}case 92:break;default:{g=d;f=i;continue c}}switch(a[e+1>>0]|0){case 124:case 41:break;default:{g=d;f=i;continue c}}d=bN(c[b>>2]|0,i,d)|0;if((a[e+1>>0]|0)==124){f=2;break d}if(!h){d=8;break a}e=e+2|0;f=92}while(0);if((j|0)==47){j=0;d=bN(c[b>>2]|0,i,d)|0;e=f<<24>>24==41?e+1|0:e}d=hN(b,d,TM(t)|0)|0;if(d|0)break a;d=f<<24>>24==0;f=(h|0)<1;if(f&d){j=50;break b}if(f|d){d=8;break a}g=UM(t)|0;h=h+-1|0;i=UM(t)|0}if((j|0)==40){f=1;d=bN(c[b>>2]|0,i,d)|0}g=0;e=e+f|0;f=d}d=RM(t,f)|0;if(d|0)break a;d=RM(t,g)|0;if(d|0)break a;d=SM(t,k)|0;if(d|0)break a;d=h+1|0;k=k+1|0;e=m?e+1|0:e+2|0}if((j|0)==28){d=10;break}else if((j|0)==50){c[b+20>>2]=k;d=0;break}}while(0);l=u;return d|0}function IM(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0;x=QM(d)|0;y=(b|0)==0|(f|0)==0;if(!y){c[f+48>>2]=0;c[c[f+36>>2]>>2]=-1}g=f+28|0;z=ZI((c[g>>2]<<3)+8|0)|0;do if(!z)g=12;else{c[z>>2]=-1;A=ZI((c[g>>2]<<2)+4|0)|0;if(!A){_I(z);g=12;break}c[A>>2]=-1;B=ZI((c[g>>2]<<3)+8|0)|0;if(!B){_I(z);_I(A);g=12;break}h=c[g>>2]|0;g=0;do{c[B+(g<<3)>>2]=-1;g=g+1|0}while(g>>>0<=h>>>0);RM(d,e)|0;g=SM(d,0)|0;a:do if((g|0)!=0|(QM(d)|0)<=(x|0)){e=z;n=0;h=0;m=0;l=-1}else{u=f+32|0;v=f+36|0;w=f+16|0;e=z;n=0;h=0;m=0;t=1;l=-1;s=0;while(1){b:do switch(TM(d)|0){case 6:{i=TM(d)|0;g=0;do{j=e+(g<<2)|0;g=g+1|0}while((c[j>>2]|0)>-1);c[j>>2]=i<<1|1;c[e+(g<<2)>>2]=-1;g=0;while(1)if((c[A+(g<<2)>>2]|0)>-1)g=g+1|0;else break;c[A+(g+-1<<2)>>2]=-1;g=0;j=t;i=s;break}case 0:{q=UM(d)|0;r=q+12|0;j=c[r>>2]|0;if((j|0)>-1){g=0;do{i=e+(g<<2)|0;g=g+1|0}while((c[i>>2]|0)>-1);c[i>>2]=j<<1;c[e+(g<<2)>>2]=-1;if(!y){g=0;while(1)if((c[A+(g<<2)>>2]|0)>-1)g=g+1|0;else break;c[(c[w>>2]|0)+(j*12|0)+8>>2]=0;if((g|0)>0){g=ZI((g<<2)+4|0)|0;if(!g){g=12;j=t;i=s;break b}c[(c[w>>2]|0)+(j*12|0)+8>>2]=g;i=c[A>>2]|0;if((i|0)>-1){k=0;j=g;do{c[j>>2]=i;k=k+1|0;i=c[A+(k<<2)>>2]|0;j=g+(k<<2)|0}while((i|0)>-1);g=j}c[g>>2]=-1}}g=SM(d,c[r>>2]|0)|0;if(g|0){j=t;i=s;break b}g=SM(d,6)|0;if(g|0){j=t;i=s;break b}}c:do switch(c[q>>2]|0){case 0:{p=c[c[q+4>>2]>>2]|0;if((p|0)>-1|(p|0)==-4?(c[e>>2]|0)>-1:0){if(y){c[q+20>>2]=1;g=0}else{g=cN(b,q,m)|0;c[(c[u>>2]|0)+(m<<2)>>2]=s;if((l|0)>-1){j=c[v>>2]|0;i=0;while(1){k=j+(i<<2)|0;o=i+1|0;if((c[k>>2]|0)>-1)i=o;else break}c[k>>2]=m;c[j+(o<<2)>>2]=l;c[j+(i+2<<2)>>2]=-1;h=h+1|0;l=-1}dN(e,f,m)}c[e>>2]=-1;p=t+1|0;o=s;n=n+1|0;m=t}else{p=t;g=0;o=s}break}case 1:{j=c[q+4>>2]|0;k=c[j>>2]|0;j=c[j+4>>2]|0;g=RM(d,q)|0;if(!g){g=SM(d,5)|0;if(!g){g=RM(d,j)|0;if(!g){g=SM(d,0)|0;if(!g){i=k+20|0;g=SM(d,(c[i>>2]|0)+t|0)|0;if(!g){if((c[i>>2]|0)>0){i=(c[j+20>>2]|0)>0;g=i?t:-1;i=t+(i&1)|0}else{g=-1;i=t}g=SM(d,g)|0;if(!g){g=SM(d,4)|0;if(!g){g=RM(d,k)|0;if(!g){p=i;g=SM(d,0)|0;o=s}else{p=i;o=s}}else{p=i;o=s}}else{p=i;o=s}}else{p=t;o=s}}else{p=t;o=s}}else{p=t;o=s}}else{p=t;o=s}}else{p=t;o=s}break}case 2:{i=c[q+4>>2]|0;if(y){if((c[e>>2]|0)>-1)g=1;else g=(a[i+12>>0]&1)!=0;g=SM(d,g&1)|0;if(g|0){p=t;o=s;break c}}else{g=SM(d,m)|0;if(g|0){p=t;o=s;break c}g=SM(d,a[i+12>>0]&1)|0;if(g|0){p=t;o=s;break c}}g=RM(d,q)|0;if(!g){g=SM(d,1)|0;if(!g){g=RM(d,c[i>>2]|0)|0;if(!g){g=SM(d,0)|0;if(!g){if((c[e>>2]|0)<=-1?(a[i+12>>0]&1)==0:0){p=t;g=0;o=0;break c}if(y)g=0;else{g=cN(b,q,m)|0;c[(c[u>>2]|0)+(m<<2)>>2]=(a[i+12>>0]&1)==0?s:1;if((l|0)>-1){j=c[v>>2]|0;i=0;while(1){k=j+(i<<2)|0;o=i+1|0;if((c[k>>2]|0)>-1)i=o;else break}c[k>>2]=m;c[j+(o<<2)>>2]=l;c[j+(i+2<<2)>>2]=-1;h=h+1|0;l=-1}dN(e,f,m)}c[e>>2]=-1;p=t+1|0;o=0;n=n+1|0;m=t}else{p=t;o=s}}else{p=t;o=s}}else{p=t;o=s}}else{p=t;o=s}break}case 3:{j=c[q+4>>2]|0;k=c[j>>2]|0;j=c[j+4>>2]|0;i=(c[e>>2]|0)>-1;p=t+1|0;g=SM(d,i?p:t)|0;if(!g){g=SM(d,i?t:m)|0;if(!g){g=RM(d,e)|0;if(!g){g=SM(d,(c[e>>2]|0)>>>31^1)|0;if(!g){g=RM(d,q)|0;if(!g){g=RM(d,j)|0;if(!g){g=RM(d,k)|0;if(!g){g=SM(d,3)|0;if(!g){g=RM(d,j)|0;if(!g){g=SM(d,0)|0;if(g|0){p=t;o=s;break c}g=SM(d,2)|0;if(g|0){p=t;o=s;break c}g=RM(d,k)|0;if(g|0){p=t;o=s;break c}g=SM(d,0)|0;if(g|0){p=t;o=s;break c}if((c[e>>2]|0)>-1){if(y)g=0;else{g=cN(b,q,m)|0;c[(c[u>>2]|0)+(m<<2)>>2]=s;if((l|0)>-1){j=c[v>>2]|0;i=0;while(1){k=j+(i<<2)|0;o=i+1|0;if((c[k>>2]|0)>-1)i=o;else break}c[k>>2]=m;c[j+(o<<2)>>2]=l;c[j+(i+2<<2)>>2]=-1;h=h+1|0;l=-1}dN(e,f,m)}c[e>>2]=-1;n=n+1|0;m=t;i=p}else{g=0;i=t}t=(c[q+16>>2]|0)>0;p=t?i+2|0:i;o=s;m=t?i+1|0:m}else{p=t;o=s}}else{p=t;o=s}}else{p=t;o=s}}else{p=t;o=s}}else{p=t;o=s}}else{p=t;o=s}}else{p=t;o=s}}else{p=t;o=s}}else{p=t;o=s}break}default:{p=t;g=0;o=s}}while(0);j=c[r>>2]|0;if((j|0)>-1){i=0;do{k=A+(i<<2)|0;i=i+1|0}while((c[k>>2]|0)>-1);c[k>>2]=j;c[A+(i<<2)>>2]=-1;j=p;i=o}else{j=p;i=o}break}case 1:{g=UM(d)|0;if(y){i=c[(c[c[g+4>>2]>>2]|0)+20>>2]|0;c[g+20>>2]=(TM(d)|0)+i;i=0;l=-1}else{q=TM(d)|0;r=TM(d)|0;i=q;l=(q|0)==0?l:r}g=0;j=t;i=y?s:(i|0)==0&1;break}case 4:{i=TM(d)|0;j=TM(d)|0;g=0;m=(i|0)>-1?i:m;i=s;break}case 5:{g=UM(d)|0;if(y){j=c[g+4>>2]|0;c[g+20>>2]=(c[(c[j+4>>2]|0)+20>>2]|0)+(c[(c[j>>2]|0)+20>>2]|0);g=0;j=t;i=s}else{g=0;j=t;i=s}break}case 2:{while(1)if((c[e>>2]|0)>-1)e=e+4|0;else{g=0;j=t;i=s;break}break}case 3:{j=UM(d)|0;o=UM(d)|0;g=UM(d)|0;e=TM(d)|0;if(y){r=c[g+4>>2]|0;s=g+16|0;c[g+20>>2]=(c[(c[r>>2]|0)+20>>2]|0)+e+(c[(c[r+4>>2]|0)+20>>2]|0)+((c[s>>2]|0)>0?2:0);g=s}else g=g+16|0;e=UM(d)|0;i=TM(d)|0;k=TM(d)|0;if((c[g>>2]|0)>0){if(y)g=0;else{g=eN(b,j,i)|0;c[(c[u>>2]|0)+(i<<2)>>2]=1;if(!g)g=eN(b,o,k)|0;c[(c[u>>2]|0)+(k<<2)>>2]=1}n=n+2|0;j=t;i=1}else{g=0;j=t;i=1}break}default:{g=0;j=t;i=s}}while(0);if((g|0)!=0|(QM(d)|0)<=(x|0))break a;else{t=j;s=i}}}while(0);if(!y?(dN(e,f,m),(l|0)>-1):0){i=c[f+36>>2]|0;e=0;while(1){j=i+(e<<2)|0;k=e+1|0;if((c[j>>2]|0)>-1)e=k;else break}c[j>>2]=m;c[i+(k<<2)>>2]=l;c[i+(e+2<<2)>>2]=-1;h=h+1|0}c[f+48>>2]=n;c[f+40>>2]=n;c[f+44>>2]=h;_I(z);_I(A);_I(B)}while(0);return g|0}function JM(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;y=l;l=l+16|0;t=y+12|0;x=y+8|0;u=y+4|0;v=y;w=QM(b)|0;c[t>>2]=0;c[x>>2]=0;d=RM(b,d)|0;a:do if(!d){d=SM(b,0)|0;if(!d){b:do if((QM(b)|0)>(w|0)){g=0;i=0;j=0;c:while(1){q=TM(b)|0;r=UM(b)|0;d:do switch(q|0){case 0:{switch(c[r>>2]|0){case 0:{d=c[r+4>>2]|0;r=c[d>>2]|0;if(!((r|0)>-1|(r|0)==-4)){d=j;break d}r=d+8|0;d=(c[r>>2]|0)+j|0;c[r>>2]=d;if((d|0)<=(c[x>>2]|0)){d=j;break d}c[x>>2]=d;d=j;break d}case 3:{h=c[r+4>>2]|0;d=RM(b,c[h+4>>2]|0)|0;if(d|0)break b;d=SM(b,0)|0;if(d|0)break b;d=RM(b,c[h>>2]|0)|0;if(d|0)break b;break}case 1:{h=c[r+4>>2]|0;d=RM(b,c[h+4>>2]|0)|0;if(d|0)break b;d=SM(b,0)|0;if(d|0)break b;d=RM(b,c[h>>2]|0)|0;if(d|0)break b;break}case 2:{h=c[r+4>>2]|0;d=SM(b,j)|0;if(d|0)break b;d=RM(b,r)|0;if(d|0)break b;d=SM(b,1)|0;if(d|0)break b;d=RM(b,c[h>>2]|0)|0;if(d|0)break b;d=SM(b,0)|0;if(d|0)break b;if((c[h+4>>2]|0)<=1?(c[h+8>>2]|0)<=1:0)d=j;else{c[t>>2]=0;d=0}i=i+1|0;break d}default:{d=j;break d}}d=SM(b,0)|0;if(!d)d=j;else break b;break}case 1:{p=r+4|0;o=c[p>>2]|0;q=TM(b)|0;c[t>>2]=q;n=o+4|0;j=c[n>>2]|0;if((j|0)<=1)if((c[o+8>>2]|0)>1){c[u>>2]=0;if((j|0)>0)s=30;else{d=q;h=0;s=37}}else d=q;else{c[u>>2]=0;s=30}e:do if((s|0)==30){d=$M(a,b,c[o>>2]|0,(j|0)>1?1:2,t,f,v,x)|0;if(!d){h=0;k=q;m=1}else{s=34;break c}while(1){d=c[v>>2]|0;if(!h)h=d;else h=LM(a,h,d)|0;if(!h){d=12;s=34;break c}j=c[n>>2]|0;if((m|0)>=(j|0)){d=k;s=37;break e}k=c[t>>2]|0;m=m+1|0;d=$M(a,b,c[o>>2]|0,(m|0)<(j|0)?1:2,t,f,v,x)|0;if(d|0){s=34;break c}}}while(0);if((s|0)==37){s=0;n=o+8|0;k=c[n>>2]|0;if((k|0)==-1){k=c[t>>2]|0;d=$M(a,b,c[o>>2]|0,0,t,0,u,x)|0;if(d|0)break c;j=aN(a,c[u>>2]|0,0,-1,0)|0;c[u>>2]=j;if(!j){d=12;break c}else d=k}else if((j|0)<(k|0)){k=j;j=0;while(1){m=c[t>>2]|0;d=$M(a,b,c[o>>2]|0,0,t,0,v,x)|0;if(d|0){s=49;break c}if(!j){d=c[v>>2]|0;c[u>>2]=d}else{d=LM(a,c[v>>2]|0,j)|0;c[u>>2]=d}if(!d){d=12;s=49;break c}j=KM(a,-1,-1,-1)|0;if(!j){d=12;s=49;break c}j=bN(a,j,d)|0;c[u>>2]=j;if(!j){d=12;s=49;break c}k=k+1|0;if((k|0)>=(c[n>>2]|0)){d=m;break}}}else j=0;c[t>>2]=d;if(h){if(j){h=LM(a,h,j)|0;s=54}}else{h=j;s=54}if((s|0)==54){s=0;if(!h){d=12;break c}}c[p>>2]=c[h+4>>2];c[r>>2]=c[h>>2]}i=i+-1|0;h=d-q+g|0;if(!i){c[t>>2]=h;g=h;i=0;d=h}else g=h;break}default:d=j}while(0);if((QM(b)|0)>(w|0))j=d;else{d=0;break b}}break a}else{d=0;g=0}while(0);w=(c[e>>2]|0)+g|0;x=c[x>>2]|0;c[e>>2]=(x|0)>(w|0)?x:w}}while(0);l=y;return d|0}function KM(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=DM(a,0,0,1,20)|0;a=_M(a,0,f)|0;if(!a)a=0;else{c[f>>2]=b;c[f+4>>2]=d;c[f+8>>2]=e}return a|0}function LM(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;if(b){e=DM(a,0,0,1,8)|0;a=_M(a,1,e)|0;if(!a)d=0;else{c[e>>2]=b;c[e+4>>2]=d;c[a+16>>2]=(c[d+16>>2]|0)+(c[b+16>>2]|0);d=a}}return d|0}function MM(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0;o=l;l=l+16|0;j=o+4|0;k=o;m=QM(b)|0;d=RM(b,d)|0;a:do if(!d){d=SM(b,0)|0;if(!d)if((QM(b)|0)>(m|0)){b:while(1){h=TM(b)|0;i=UM(b)|0;c:do switch(h|0){case 0:switch(c[i>>2]|0){case 0:{g=c[i+4>>2]|0;f=c[g>>2]|0;if((f|0)==-4){c[i+8>>2]=0;d=g+8|0;h=VM(a,c[d>>2]|0,0,1114111,0,0,-1)|0;c[i+24>>2]=h;if(!h){d=12;break a}h=VM(a,c[d>>2]|0,0,1114111,0,0,c[g+4>>2]|0)|0;c[i+28>>2]=h;if(!h){d=12;break a}else break c}d=i+8|0;if((f|0)<0){c[d>>2]=1;h=WM(a)|0;c[i+24>>2]=h;if(!h){d=12;break a}h=WM(a)|0;c[i+28>>2]=h;if(!h){d=12;break a}else break c}else{c[d>>2]=0;d=g+8|0;e=g+4|0;h=VM(a,c[d>>2]|0,f,c[e>>2]|0,0,0,-1)|0;c[i+24>>2]=h;if(!h){d=12;break a}h=VM(a,c[d>>2]|0,c[g>>2]|0,c[e>>2]|0,c[g+12>>2]|0,c[g+16>>2]|0,-1)|0;c[i+28>>2]=h;if(!h){d=12;break a}else break c}}case 3:{d=RM(b,i)|0;if(d|0)break a;d=SM(b,1)|0;if(d|0)break a;e=i+4|0;d=RM(b,c[(c[e>>2]|0)+4>>2]|0)|0;if(d|0)break a;d=SM(b,0)|0;if(d|0)break a;d=RM(b,c[c[e>>2]>>2]|0)|0;if(d|0)break a;d=SM(b,0)|0;if(!d)break c;else break a}case 1:{d=RM(b,i)|0;if(d|0)break a;d=SM(b,2)|0;if(d|0)break a;e=i+4|0;d=RM(b,c[(c[e>>2]|0)+4>>2]|0)|0;if(d|0)break a;d=SM(b,0)|0;if(d|0)break a;d=RM(b,c[c[e>>2]>>2]|0)|0;if(d|0)break a;d=SM(b,0)|0;if(!d)break c;else break a}case 2:{d=RM(b,i)|0;if(d|0)break a;d=SM(b,3)|0;if(d|0)break a;d=RM(b,c[c[i+4>>2]>>2]|0)|0;if(d|0)break a;d=SM(b,0)|0;if(!d)break c;else break a}default:break c}case 1:{d=c[i+4>>2]|0;e=c[d>>2]|0;f=d+4|0;g=c[f>>2]|0;if(!(c[e+8>>2]|0))h=(c[g+8>>2]|0)!=0;else h=1;c[i+8>>2]=h&1;h=XM(a,c[e+24>>2]|0,c[g+24>>2]|0,0,0)|0;c[i+24>>2]=h;if(!h){d=12;break a}h=XM(a,c[(c[d>>2]|0)+28>>2]|0,c[(c[f>>2]|0)+28>>2]|0,0,0)|0;c[i+28>>2]=h;if(!h){d=12;break a}break}case 3:{h=c[i+4>>2]|0;d=c[h>>2]|0;if(!(c[h+4>>2]|0))e=1;else e=(c[d+8>>2]|0)!=0&1;c[i+8>>2]=e;c[i+24>>2]=c[d+24>>2];c[i+28>>2]=c[d+28>>2];break}case 2:{g=c[i+4>>2]|0;d=c[g>>2]|0;e=d+8|0;if(!(c[e>>2]|0))f=0;else f=(c[(c[g+4>>2]|0)+8>>2]|0)!=0;c[i+8>>2]=f&1;if(c[e>>2]|0){d=YM(b,d,0,0,j)|0;if(d|0)break b;e=ZI((c[j>>2]<<2)+4|0)|0;if(!e){d=12;break b}c[e>>2]=-1;c[k>>2]=0;d=YM(b,c[g>>2]|0,e,k,0)|0;if(d|0){n=45;break b}d=g+4|0;h=i+24|0;c[h>>2]=XM(a,c[(c[d>>2]|0)+24>>2]|0,c[(c[g>>2]|0)+24>>2]|0,e,c[k>>2]|0)|0;_I(e);if(!(c[h>>2]|0)){d=12;break b}else f=d}else{c[i+24>>2]=c[d+24>>2];f=g+4|0}d=c[f>>2]|0;if(c[d+8>>2]|0){d=YM(b,d,0,0,j)|0;if(d|0)break b;e=ZI((c[j>>2]<<2)+4|0)|0;if(!e){d=12;break b}c[e>>2]=-1;c[k>>2]=0;d=YM(b,c[f>>2]|0,e,k,0)|0;if(d|0){n=52;break b}i=i+28|0;c[i>>2]=XM(a,c[(c[g>>2]|0)+28>>2]|0,c[(c[f>>2]|0)+28>>2]|0,e,c[k>>2]|0)|0;_I(e);if(!(c[i>>2]|0)){d=12;break b}}else c[i+28>>2]=c[d+28>>2];break}default:{}}while(0);if((QM(b)|0)<=(m|0)){d=0;break a}}if((n|0)==45)_I(e);else if((n|0)==52)_I(e)}else d=0}while(0);l=o;return d|0}function NM(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;a:while(1){switch(c[a>>2]|0){case 2:{a=c[a+4>>2]|0;if((c[a+8>>2]|0)==-1?(h=c[a>>2]|0,h=PM(c[h+28>>2]|0,c[h+24>>2]|0,b,d,e)|0,(h|0)!=0):0){a=h;break a}break}case 3:{f=c[a+4>>2]|0;a=NM(c[f>>2]|0,b,d,e)|0;if(a|0)break a;a=f+4|0;break}case 1:{f=c[a+4>>2]|0;g=f+4|0;a=PM(c[(c[f>>2]|0)+28>>2]|0,c[(c[g>>2]|0)+24>>2]|0,b,d,e)|0;if(a|0)break a;a=NM(c[f>>2]|0,b,d,e)|0;if(!a)a=g;else break a;break}default:{a=0;break a}}a=c[a>>2]|0}return a|0}function OM(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0;h=c[a+4>>2]|0;if(h|0){e=h+4|0;a=c[h>>2]|0;if(c[e>>2]|0){d=0;do{if(c[a+(d<<5)+8>>2]|0){b=c[a+(d<<5)+16>>2]|0;if(b){_I(b);a=c[h>>2]|0}b=c[a+(d<<5)+28>>2]|0;if(b){_I(b);a=c[h>>2]|0}}d=d+1|0}while(d>>>0<(c[e>>2]|0)>>>0)}if(a|0)_I(a);d=h+8|0;a=c[d>>2]|0;if(a|0){if(c[a+8>>2]|0){while(1){b=c[a+16>>2]|0;if(b|0)_I(b);if(!(c[a+40>>2]|0))break;else a=a+32|0}a=c[d>>2]|0}_I(a)}f=h+16|0;a=c[f>>2]|0;if(a|0){g=h+28|0;b=c[g>>2]|0;if(b){e=0;do{d=c[a+(e*12|0)+8>>2]|0;if(d){_I(d);b=c[g>>2]|0;a=c[f>>2]|0}e=e+1|0}while(e>>>0>>0)}_I(a)}a=c[h+32>>2]|0;if(a|0)_I(a);a=c[h+20>>2]|0;if(a|0)_I(a);a=c[h+36>>2]|0;if(a|0)_I(a);_I(h)}return}function PM(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;g=c[a>>2]|0;h=(g|0)>-1;a:do if(!d)if(h){h=b+32|0;do{if((c[b>>2]|0)>-1?(y=e+(g<<2)|0,c[y>>2]=(c[y>>2]|0)+1,(c[h>>2]|0)>-1):0){g=h;do{y=e+(c[a>>2]<<2)|0;c[y>>2]=(c[y>>2]|0)+1;g=g+32|0}while((c[g>>2]|0)>-1)}a=a+32|0;g=c[a>>2]|0}while((g|0)>-1);g=0}else g=0;else if(h)while(1){h=c[b>>2]|0;b:do if((h|0)>-1){p=a+4|0;q=a+8|0;r=a+16|0;s=a+20|0;t=a+24|0;u=a+28|0;v=a+12|0;e=-1;g=b;while(1){o=h;while(1){if((o|0)!=(e|0))break;g=g+32|0;h=c[g>>2]|0;if((h|0)>-1)o=h;else break b}l=d+(c[f+(c[a>>2]<<2)>>2]<<5)|0;while(1){h=l+8|0;if(!(c[h>>2]|0))break;else l=l+32|0}c[l+40>>2]=0;c[l>>2]=c[p>>2];c[l+4>>2]=c[q>>2];c[h>>2]=d+(c[f+(o<<2)>>2]<<5);c[l+12>>2]=o;h=c[s>>2]|0;e=c[g+16>>2]|c[r>>2]|(h|0?4:0)|(c[t>>2]|0?8:0);i=l+20|0;c[i>>2]=e;j=c[u>>2]|0;if((j|0)>-1){c[i>>2]=e|256;h=j}c[l+24>>2]=h;e=c[t>>2]|0;if(!e)c[l+28>>2]=0;else{h=0;do{n=h;h=h+1|0}while((c[e+(n<<2)>>2]|0)!=0);h=ZI(h<<2)|0;c[l+28>>2]=h;if(!h){g=12;break a}k=c[t>>2]|0;e=c[k>>2]|0;if(e){j=0;i=h;do{c[i>>2]=e;j=j+1|0;e=c[k+(j<<2)>>2]|0;i=h+(j<<2)|0}while((e|0)!=0);h=i}c[h>>2]=0}e=c[v>>2]|0;if(!e)h=0;else{h=0;while(1)if((c[e+(h<<2)>>2]|0)>-1)h=h+1|0;else break}k=g+12|0;i=c[k>>2]|0;if(!i)e=0;else{e=0;while(1)if((c[i+(e<<2)>>2]|0)>-1)e=e+1|0;else break}j=l+16|0;i=c[j>>2]|0;if(i|0)_I(i);c[j>>2]=0;h=e+h|0;if((h|0)>0){n=ZI((h<<2)+4|0)|0;c[j>>2]=n;if(!n){g=12;break a}e=c[v>>2]|0;if((e|0)!=0?(w=c[e>>2]|0,(w|0)>-1):0){h=0;i=w;do{c[n+(h<<2)>>2]=i;h=h+1|0;i=c[e+(h<<2)>>2]|0}while((i|0)>-1);m=h}else m=0;j=c[k>>2]|0;if((j|0)!=0?(x=c[j>>2]|0,(x|0)>-1):0){k=(m|0)>0;h=m;i=0;l=x;do{c:do if(k){e=0;while(1){if((c[n+(e<<2)>>2]|0)==(l|0))break c;e=e+1|0;if((e|0)>=(m|0)){y=39;break}}}else y=39;while(0);if((y|0)==39){y=0;c[n+(h<<2)>>2]=l;h=h+1|0}i=i+1|0;l=c[j+(i<<2)>>2]|0}while((l|0)>-1)}else h=m;c[n+(h<<2)>>2]=-1}g=g+32|0;h=c[g>>2]|0;if((h|0)<=-1)break;else e=o}}while(0);a=a+32|0;if((c[a>>2]|0)<=-1){g=0;break}}else g=0;while(0);return g|0}function QM(a){a=a|0;return c[a+12>>2]|0}function RM(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=l;l=l+16|0;e=d+4|0;f=d;c[f>>2]=b;c[e>>2]=c[f>>2];b=ZM(a,e)|0;l=d;return b|0}function SM(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=l;l=l+16|0;e=d+4|0;f=d;c[f>>2]=b;c[e>>2]=c[f>>2];b=ZM(a,e)|0;l=d;return b|0}function TM(a){a=a|0;var b=0,d=0;b=c[a+16>>2]|0;d=a+12|0;a=(c[d>>2]|0)+-1|0;c[d>>2]=a;return c[b+(a<<2)>>2]|0}function UM(a){a=a|0;var b=0,d=0;b=c[a+16>>2]|0;d=a+12|0;a=(c[d>>2]|0)+-1|0;c[d>>2]=a;return c[b+(a<<2)>>2]|0}function VM(a,b,d,e,f,g,h){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;a=DM(a,0,0,1,64)|0;if(!a)a=0;else{c[a>>2]=b;c[a+4>>2]=d;c[a+8>>2]=e;c[a+20>>2]=f;c[a+24>>2]=g;c[a+28>>2]=h;c[a+32>>2]=-1;c[a+36>>2]=-1;c[a+40>>2]=-1}return a|0}function WM(a){a=a|0;a=DM(a,0,0,1,32)|0;if(!a)a=0;else{c[a>>2]=-1;c[a+4>>2]=-1;c[a+8>>2]=-1}return a|0}function XM(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;o=(e|0)==0;if(o)n=0;else{g=0;while(1)if((c[e+(g<<2)>>2]|0)>-1)g=g+1|0;else{n=g;break}}h=0;while(1)if((c[b+(h<<5)>>2]|0)>-1)h=h+1|0;else{g=0;break}while(1)if((c[d+(g<<5)>>2]|0)>-1)g=g+1|0;else break;g=DM(a,0,0,1,(g+h<<5)+32|0)|0;a:do if(!g)g=0;else{h=c[b>>2]|0;if((h|0)>-1){m=(n|0)>0;i=0;while(1){c[g+(i<<5)>>2]=h;c[g+(i<<5)+4>>2]=c[b+(i<<5)+4>>2];c[g+(i<<5)+8>>2]=c[b+(i<<5)+8>>2];c[g+(i<<5)+16>>2]=c[b+(i<<5)+16>>2]|f;c[g+(i<<5)+20>>2]=c[b+(i<<5)+20>>2];c[g+(i<<5)+24>>2]=c[b+(i<<5)+24>>2];c[g+(i<<5)+28>>2]=c[b+(i<<5)+28>>2];l=b+(i<<5)+12|0;j=c[l>>2]|0;h=(j|0)==0;if(o&h)h=0;else{if(h)k=0;else{h=0;while(1)if((c[j+(h<<2)>>2]|0)>-1)h=h+1|0;else{k=h;break}}h=DM(a,0,0,0,(k+n<<2)+4|0)|0;if(!h){g=0;break a}if((k|0)>0){l=c[l>>2]|0;j=0;do{c[h+(j<<2)>>2]=c[l+(j<<2)>>2];j=j+1|0}while((j|0)!=(k|0))}else k=0;if(m){j=0;do{c[h+(j+k<<2)>>2]=c[e+(j<<2)>>2];j=j+1|0}while((j|0)!=(n|0));j=n}else j=0;c[h+(j+k<<2)>>2]=-1}c[g+(i<<5)+12>>2]=h;i=i+1|0;h=c[b+(i<<5)>>2]|0;if((h|0)<=-1){n=i;break}}}else n=0;i=c[d>>2]|0;h=g+(n<<5)|0;if((i|0)>-1){m=0;l=n;do{c[h>>2]=i;c[g+(l<<5)+4>>2]=c[d+(m<<5)+4>>2];c[g+(l<<5)+8>>2]=c[d+(m<<5)+8>>2];c[g+(l<<5)+16>>2]=c[d+(m<<5)+16>>2];c[g+(l<<5)+20>>2]=c[d+(m<<5)+20>>2];c[g+(l<<5)+24>>2]=c[d+(m<<5)+24>>2];c[g+(l<<5)+28>>2]=c[d+(m<<5)+28>>2];j=d+(m<<5)+12|0;h=c[j>>2]|0;if(!h)h=0;else{i=0;while(1)if((c[h+(i<<2)>>2]|0)>-1)i=i+1|0;else break;h=DM(a,0,0,0,(i<<2)+4|0)|0;if(!h){g=0;break a}if((i|0)>0){k=c[j>>2]|0;j=0;do{c[h+(j<<2)>>2]=c[k+(j<<2)>>2];j=j+1|0}while((j|0)!=(i|0))}else i=0;c[h+(i<<2)>>2]=-1}c[g+(l<<5)+12>>2]=h;m=m+1|0;i=c[d+(m<<5)>>2]|0;l=m+n|0;h=g+(l<<5)|0}while((i|0)>-1)}c[h>>2]=-1}while(0);return g|0}function YM(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;o=QM(a)|0;p=(f|0)!=0;if(p)c[f>>2]=0;b=RM(a,b)|0;a:do if(!b){m=(d|0)==0;l=(e|0)==0;if((QM(a)|0)>(o|0))while(1){b=UM(a)|0;b:do switch(c[b>>2]|0){case 0:{b=c[b+4>>2]|0;switch(c[b>>2]|0){case -3:break;case -2:{if(l)break b;c[e>>2]=c[e>>2]|c[b+4>>2];break b}default:break b}h=c[b+4>>2]|0;if((h|0)>-1){c:do if(!m){b=0;while(1){i=d+(b<<2)|0;j=c[i>>2]|0;if((j|0)<=-1)break;if((j|0)==(h|0))break c;else b=b+1|0}c[i>>2]=h;c[d+(b+1<<2)>>2]=-1}while(0);if(p)c[f>>2]=(c[f>>2]|0)+1}break}case 3:{b=c[b+4>>2]|0;h=c[b>>2]|0;if(c[h+8>>2]|0){k=h;n=6;break b}b=c[b+4>>2]|0;if(c[b+8>>2]|0){k=b;n=6}break}case 1:{b=c[b+4>>2]|0;h=RM(a,c[b>>2]|0)|0;if(h|0){g=h;break a}k=c[b+4>>2]|0;n=6;break}case 2:{b=c[c[b+4>>2]>>2]|0;if(c[b+8>>2]|0){k=b;n=6}break}default:{}}while(0);if((n|0)==6?(n=0,g=RM(a,k)|0,g|0):0)break a;if((QM(a)|0)<=(o|0)){g=0;break a}}else g=0}else g=b;while(0);return g|0}function ZM(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;k=l;l=l+16|0;g=k;d=a+12|0;e=c[d>>2]|0;j=c[a>>2]|0;if((e|0)>=(j|0)){d=c[a+4>>2]|0;if((j|0)<(d|0)?(f=(c[a+8>>2]|0)+j|0,f=(f|0)>(d|0)?d:f,h=a+16|0,i=aJ(c[h>>2]|0,f<<2)|0,(i|0)!=0):0){c[a>>2]=f;c[h>>2]=i;c[g>>2]=c[b>>2];ZM(a,g)|0;d=0}else d=12}else{c[(c[a+16>>2]|0)+(e<<2)>>2]=c[b>>2];c[d>>2]=(c[d>>2]|0)+1;d=0}l=k;return d|0}function _M(a,b,d){a=a|0;b=b|0;d=d|0;a=DM(a,0,0,1,32)|0;if((d|0)!=0&(a|0)!=0){c[a+4>>2]=d;c[a>>2]=b;c[a+8>>2]=-1;c[a+12>>2]=-1}else a=0;return a|0}function $M(b,d,e,f,g,h,i,j){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;r=QM(d)|0;RM(d,e)|0;e=SM(d,0)|0;a:do if(!e){q=(f&1|0)==0;p=(f&2|0)!=0;o=0;l=1;e=i;while(1){if((QM(d)|0)>(r|0))n=e;else{f=o;e=0;break a}b:while(1){c:while(1){switch(TM(d)|0){case 1:{i=7;break c}case 0:{e=UM(d)|0;switch(c[e>>2]|0){case 0:{i=9;break b}case 3:{i=19;break b}case 1:{i=26;break b}case 2:{i=33;break c}default:{}}break}default:{}}if((QM(d)|0)<=(r|0)){f=o;e=0;break a}}if((i|0)==7)e=UM(d)|0;else if((i|0)==33){f=c[e+4>>2]|0;e=RM(d,c[f>>2]|0)|0;if(e|0){f=o;break a}e=SM(d,0)|0;if(e|0){f=o;break a}e=aN(b,c[f>>2]|0,c[f+4>>2]|0,c[f+8>>2]|0,a[f+12>>0]&1)|0;c[n>>2]=e;if(!e){f=o;e=12;break a}e=c[e+4>>2]|0}if((QM(d)|0)>(r|0))n=e;else{f=o;e=0;break a}}if((i|0)==9){m=c[e+4>>2]|0;i=c[m+8>>2]|0;f=c[m>>2]|0;e=c[m+4>>2]|0;if(!((f|0)>-1|(f|0)==-4))if(q|(f|0)!=-3)if((f|0)==-3)if(p&(l|0)!=0){c[h+(e<<2)>>2]=1;f=-3;k=o;l=0}else{f=-3;k=o}else k=o;else{e=-1;f=-1;i=-1;k=o}else{i=(c[g>>2]|0)+i|0;k=o+1|0}e=KM(b,f,e,i)|0;c[n>>2]=e;if(!e)e=12;else{e=c[e+4>>2]|0;c[e+12>>2]=c[m+12>>2];c[e+16>>2]=c[m+16>>2];e=0}if((i|0)>(c[j>>2]|0)){c[j>>2]=i;f=n}else f=n}else if((i|0)==19){i=c[e+4>>2]|0;f=i+4|0;e=bN(b,c[i>>2]|0,c[f>>2]|0)|0;c[n>>2]=e;if(!e){f=o;e=12;break a}m=c[e+4>>2]|0;e=RM(d,c[f>>2]|0)|0;if(e|0){f=o;break a}e=SM(d,0)|0;if(e|0){f=o;break a}e=RM(d,m+4|0)|0;if(e|0){f=o;break a}e=SM(d,1)|0;if(e|0){f=o;break a}e=RM(d,c[i>>2]|0)|0;if(e|0){f=o;break a}k=o;f=m;e=SM(d,0)|0}else if((i|0)==26){m=c[e+4>>2]|0;i=m+4|0;e=LM(b,c[m>>2]|0,c[i>>2]|0)|0;c[n>>2]=e;if(!e){f=o;e=12;break a}f=c[e+4>>2]|0;c[f>>2]=0;k=f+4|0;c[k>>2]=0;e=RM(d,c[i>>2]|0)|0;if(e|0){f=o;break a}e=SM(d,0)|0;if(e|0){f=o;break a}e=RM(d,k)|0;if(e|0){f=o;break a}e=SM(d,1)|0;if(e|0){f=o;break a}e=RM(d,c[m>>2]|0)|0;if(e|0){f=o;break a}k=o;e=SM(d,0)|0}if(!e){o=k;e=f}else{f=k;break}}}else f=0;while(0);c[g>>2]=(c[g>>2]|0)+f;return e|0}function aN(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0;h=DM(b,0,0,1,16)|0;b=_M(b,2,h)|0;if(!b)b=0;else{c[h>>2]=d;c[h+4>>2]=e;c[h+8>>2]=f;h=h+12|0;a[h>>0]=a[h>>0]&-2|g&1;c[b+16>>2]=c[d+16>>2]}return b|0}function bN(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;if(b){e=DM(a,0,0,1,8)|0;a=_M(a,3,e)|0;if((d|0)!=0&(a|0)!=0){c[e>>2]=b;c[e+4>>2]=d;c[a+16>>2]=(c[d+16>>2]|0)+(c[b+16>>2]|0);d=a}else d=0}return d|0}function cN(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=DM(a,0,0,0,8)|0;if(((e|0)!=0?(d=KM(a,-3,d,-1)|0,c[e>>2]=d,(d|0)!=0):0)?(f=DM(a,0,0,0,32)|0,c[e+4>>2]=f,(f|0)!=0):0){a=b+4|0;c[f+4>>2]=c[a>>2];c[f>>2]=c[b>>2];c[f+8>>2]=-1;c[f+12>>2]=-1;f=f+16|0;c[f>>2]=0;c[f+4>>2]=0;c[f+8>>2]=0;c[f+12>>2]=0;c[a>>2]=e;c[b>>2]=1;a=0}else a=12;return a|0}function dN(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;f=c[a>>2]|0;if((f|0)>-1){g=c[b+16>>2]|0;e=0;b=f;do{f=b>>>1;c[((b&1|0)==0?g+(f*12|0)|0:g+(f*12|0)+4|0)>>2]=d;e=e+1|0;b=c[a+(e<<2)>>2]|0}while((b|0)>-1)}c[a>>2]=-1;return}function eN(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=DM(a,0,0,0,8)|0;if(((e|0)!=0?(d=KM(a,-3,d,-1)|0,c[e+4>>2]=d,(d|0)!=0):0)?(f=DM(a,0,0,0,32)|0,c[e>>2]=f,(f|0)!=0):0){a=b+4|0;c[f+4>>2]=c[a>>2];c[f>>2]=c[b>>2];c[f+8>>2]=-1;c[f+12>>2]=-1;f=f+16|0;c[f>>2]=0;c[f+4>>2]=0;c[f+8>>2]=0;c[f+12>>2]=0;c[a>>2]=e;c[b>>2]=1;a=0}else a=12;return a|0}function fN(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0;m=l;l=l+16|0;j=m;i=b+32|0;h=c[i>>2]|0;g=h&1;a:do switch(a[d>>0]|0){case 91:{e=jN(b,d+1|0)|0;break}case 92:{e=d+1|0;f=kN(e)|0;if(f|0){e=fN(b,f)|0;c[b+12>>2]=d+2;break a}f=a[e>>0]|0;switch(f|0){case 0:{e=5;break a}case 98:{f=KM(c[b>>2]|0,-2,64,-1)|0;break}case 66:{f=KM(c[b>>2]|0,-2,128,-1)|0;break}case 60:{f=KM(c[b>>2]|0,-2,16,-1)|0;break}case 62:{f=KM(c[b>>2]|0,-2,32,-1)|0;break}case 120:{h=d+2|0;i=(a[h>>0]|0)==123;g=i?8:2;h=i?d+3|0:h;e=0;f=0;do{d=lN(a[h+e>>0]|0)|0;if((d|0)<0)break;f=d+(f<<4)|0;e=e+1|0}while((f|0)<1114112&(e|0)<(g|0));e=h+e|0;if(i){if((a[e>>0]|0)!=125){e=9;break a}e=e+1|0}j=c[b>>2]|0;i=b+24|0;k=c[i>>2]|0;c[i>>2]=k+1;f=KM(j,f,f,k)|0;e=e+-1|0;break}case 63:case 43:case 123:if(!g){e=13;break a}else{k=37;break a}case 124:{if(g|0){k=37;break a}e=KM(c[b>>2]|0,-1,-1,-1)|0;k=45;break a}default:{if(!((g|0)==0&(f+-49|0)>>>0<9)){k=37;break a}j=f+-48|0;k=c[b>>2]|0;i=b+24|0;f=c[i>>2]|0;c[i>>2]=f+1;f=KM(k,-4,j,f)|0;k=b+28|0;i=c[k>>2]|0;c[k>>2]=(j|0)<(i|0)?i:j}}d=e+1|0;e=f;k=45;break}case 46:{e=c[b>>2]|0;g=b+24|0;f=c[g>>2]|0;c[g>>2]=f+1;if(h&4){f=KM(e,0,9,f)|0;k=c[b>>2]|0;e=c[g>>2]|0;c[g>>2]=e+1;e=KM(k,11,1114111,e)|0;if((f|0)!=0&(e|0)!=0)e=bN(c[b>>2]|0,f,e)|0;else e=0}else e=KM(e,0,1114111,f)|0;d=d+1|0;k=45;break}case 94:{if((g|0)==0?(c[b+16>>2]|0)!=(d|0):0){e=d;k=37;break a}d=d+1|0;e=KM(c[b>>2]|0,-2,1,-1)|0;k=45;break}case 36:{e=d+1|0;if((g|0)==0?a[e>>0]|0:0){e=d;k=37;break a}d=e;e=KM(c[b>>2]|0,-2,2,-1)|0;k=45;break}case 63:case 43:case 123:case 42:{if(!g){e=d;k=37}else e=13;break}case 124:{if(!g){e=d;k=37}else k=36;break}case 0:{k=36;break}default:{e=d;k=37}}while(0);if((k|0)==36){e=KM(c[b>>2]|0,-1,-1,-1)|0;k=45}else if((k|0)==37){h=UL(j,e,-1)|0;if((h|0)<0)e=2;else{do if(c[i>>2]&2){if((IK(c[j>>2]|0)|0)==0?(HK(c[j>>2]|0)|0)==0:0){k=43;break}i=c[b>>2]|0;n=lK(c[j>>2]|0)|0;g=lK(c[j>>2]|0)|0;f=b+24|0;g=KM(i,n,g,c[f>>2]|0)|0;n=c[b>>2]|0;i=KK(c[j>>2]|0)|0;d=KK(c[j>>2]|0)|0;d=KM(n,i,d,c[f>>2]|0)|0;if((g|0)!=0&(d|0)!=0)g=bN(c[b>>2]|0,g,d)|0;else g=0}else k=43;while(0);if((k|0)==43){g=c[j>>2]|0;f=b+24|0;g=KM(c[b>>2]|0,g,g,c[f>>2]|0)|0}c[f>>2]=(c[f>>2]|0)+1;d=e+h|0;e=g;k=45}}if((k|0)==45)if(!e)e=12;else{c[b+8>>2]=e;c[b+12>>2]=d;e=0}l=m;return e|0}function gN(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0;j=l;l=l+16|0;i=j+4|0;g=j;b=iN(b,i)|0;if((a[b>>0]|0)==44){b=iN(b+1|0,g)|0;h=c[g>>2]|0;g=c[i>>2]|0}else{i=c[i>>2]|0;c[g>>2]=i;h=i;g=i}do if(!(g>>>0>255|((h|0)>255|(h|0)>-1&(h|0)<(g|0)))){if(!d)if((a[b>>0]|0)==92)b=b+1|0;else{b=0;break}if((a[b>>0]|0)==125){c[e>>2]=g;c[f>>2]=h;b=b+1|0}else b=0}else b=0;while(0);l=j;return b|0}function hN(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;if((c[b+12>>2]|0)>-1){e=KM(c[a>>2]|0,-1,-1,-1)|0;if((e|0)!=0?(f=LM(c[a>>2]|0,e,b)|0,(f|0)!=0):0){e=c[b+16>>2]|0;c[f+16>>2]=e;g=6}else e=12}else{f=b;e=c[b+16>>2]|0;g=6}if((g|0)==6){c[f+12>>2]=d;c[f+16>>2]=e+1;c[a+8>>2]=f;e=0}return e|0}function iN(b,d){b=b|0;d=d|0;var e=0;c[d>>2]=-1;a:do if(_J(a[b>>0]|0)|0){c[d>>2]=0;e=0;do{c[d>>2]=(e*10|0)+-48+(a[b>>0]|0);b=b+1|0;if(!(_J(a[b>>0]|0)|0))break a;e=c[d>>2]|0}while((e|0)<=255)}while(0);return b|0}function jN(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;s=l;l=l+288|0;e=s+264|0;g=s;c[e>>2]=c[b>>2];h=e+8|0;c[h>>2]=0;c[e+12>>2]=32;p=ZI(128)|0;r=e+4|0;c[r>>2]=p;if(!p)d=12;else{f=g+4|0;c[f>>2]=0;p=(a[d>>0]|0)==94;c[g>>2]=p&1;d=mN(b,p?d+1|0:d,e,g)|0;a:do if(!d){p=(c[g>>2]|0)==0;if(!p){rL(c[r>>2]|0,c[h>>2]|0,4,41);d=oN(e)|0;if(!d){d=12;e=0;break}c[d>>2]=1114112;c[d+4>>2]=1114112;c[d+8>>2]=-1;d=c[f>>2]|0;if(d){e=d<<2;f=DM(c[b>>2]|0,0,0,0,e+4|0)|0;if(!f){d=12;e=0;break}TN(f|0,g+8|0,e|0)|0;c[f+(d<<2)>>2]=0}else f=0}else f=0;m=c[h>>2]|0;if((m|0)>0){n=c[r>>2]|0;o=b+24|0;e=0;d=0;k=0;while(1){j=c[n+(k<<2)>>2]|0;g=c[j>>2]|0;h=j+4|0;i=c[h>>2]|0;do if(!p)if((g|0)>(d|0)){c[j>>2]=d;c[h>>2]=g+-1;d=i+1|0;q=14;break}else{j=i+1|0;d=(j|0)>=(d|0)?j:d;break}else q=14;while(0);if((q|0)==14){q=0;c[j+8>>2]=c[o>>2];c[j+16>>2]=f;j=_M(c[b>>2]|0,0,j)|0;e=bN(c[b>>2]|0,e,j)|0;if(!e){d=12;e=0;break a}}k=k+1|0;if((k|0)>=(m|0)){d=0;break}}}else{d=0;e=0}}else e=0;while(0);_I(c[r>>2]|0);r=b+24|0;c[r>>2]=(c[r>>2]|0)+1;c[b+8>>2]=e}l=s;return d|0}function kN(b){b=b|0;var d=0;d=a[b>>0]|0;b=0;while(1){if((a[56576+(b<<3)>>0]|0)==d<<24>>24)break;b=b+1|0;if((b|0)==12){b=12;break}}return c[56576+(b<<3)+4>>2]|0}function lN(a){a=a|0;var b=0;b=a+-48|0;if(b>>>0<10)return b|0;else{b=a|32;return ((b+-97|0)>>>0<6?b+-87|0:-1)|0}return 0}function mN(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;t=l;l=l+32|0;o=t;q=t+4|0;i=UL(o,d,-1)|0;g=a[d>>0]|0;a:do if((i|0)>=1){r=f+4|0;n=b+32|0;h=d;j=i;b:while(1){i=(h|0)==(d|0);if(!(i|g<<24>>24!=93)){s=5;break}c:do if(!(i|g<<24>>24!=45)){switch(a[h+1>>0]|0){case 93:break c;case 45:break;default:{g=11;break a}}if((a[h+2>>0]|0)==93){g=11;break a}}while(0);d:do if(g<<24>>24==91){switch(a[h+1>>0]|0){case 61:case 46:{g=3;break a}case 58:break;default:{s=17;break d}}i=h+2|0;g=0;e:while(1){switch(a[i+g>>0]|0){case 0:{s=16;break b}case 58:break e;default:{}}if((g|0)<13)g=g+1|0;else{s=16;break b}}TN(q|0,i|0,g|0)|0;a[q+g>>0]=0;j=aL(q)|0;if(!j){s=16;break b}h=i+(g+2)|0;if((a[i+(g+1)>>0]|0)!=93){s=16;break b}if(!(c[f>>2]|0)){g=1114111;m=0;k=1;s=25}else{g=c[r>>2]|0;if((g|0)>63){g=12;break a}c[r>>2]=g+1;c[f+8+(g<<2)>>2]=j}}else s=17;while(0);if((s|0)==17){s=0;i=c[o>>2]|0;h=h+j|0;if((a[h>>0]|0)==45?(p=h+1|0,(a[p>>0]|0)!=93):0){h=UL(o,p,-1)|0;g=c[o>>2]|0;if((h|0)<1|(i|0)>(g|0)){g=11;break a}j=0;m=i;h=p+h|0;k=0;s=25}else{j=0;g=i;m=i;k=0;s=25}}if((s|0)==25){s=0;i=oN(e)|0;if(!i){g=12;break a}c[i>>2]=m;c[i+4>>2]=g;c[i+12>>2]=j;c[i+8>>2]=-1;if(!(k|(c[n>>2]&2|0)==0)?(pN(e,m,g)|0)!=0:0){g=12;break a}}j=UL(o,h,-1)|0;g=a[h>>0]|0;if((j|0)<1){s=3;break a}}if((s|0)==5){c[b+12>>2]=h+1;g=0;break}else if((s|0)==16){g=4;break}}else s=3;while(0);if((s|0)==3)g=g<<24>>24?2:7;l=t;return g|0}function nN(a,b){a=a|0;b=b|0;return (c[c[a>>2]>>2]|0)-(c[c[b>>2]>>2]|0)|0}function oN(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0;h=a+8|0;d=c[h>>2]|0;e=a+12|0;f=c[e>>2]|0;if((d|0)>=(f|0))if((f|0)<=32767?(c[e>>2]=f<<1,g=a+4|0,b=aJ(c[g>>2]|0,f<<3)|0,(b|0)!=0):0){c[g>>2]=b;d=c[h>>2]|0;i=6}else b=0;else{b=c[a+4>>2]|0;i=6}if((i|0)==6){c[h>>2]=d+1;i=DM(c[a>>2]|0,0,0,1,20)|0;c[b+(d<<2)>>2]=i;b=i}return b|0}function pN(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0;a:do if((b|0)>(d|0))b=0;else while(1){b:do if(!(HK(b)|0)){if(!(IK(b)|0)){b=b+1|0;break}f=KK(b)|0;e=f;while(1){g=b+1|0;e=e+1|0;if((b|0)>=(d|0)){h=f;b=g;g=12;break b}if((KK(g)|0)==(e|0))b=g;else{h=f;b=g;g=12;break}}}else{f=lK(b)|0;e=f;while(1){g=b+1|0;e=e+1|0;if((b|0)>=(d|0)){h=f;b=g;g=12;break b}if((lK(g)|0)==(e|0))b=g;else{h=f;b=g;g=12;break}}}while(0);if((g|0)==12){g=0;f=oN(a)|0;if(!f){b=-1;break a}c[f>>2]=h;c[f+4>>2]=e+-1;c[f+8>>2]=-1}if((b|0)>(d|0)){b=0;break}}while(0);return b|0}function qN(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,m=0,n=0;n=l;l=l+16|0;k=n;i=c[a+4>>2]|0;j=i+56|0;h=(c[j>>2]&8|0)==0?d:0;a=c[i+40>>2]|0;if((a|0)>0&(h|0)!=0){a=ZI(a<<2)|0;if(!a)a=12;else{g=a;d=a;m=3}}else{g=0;d=0;m=3}if((m|0)==3){if(!(c[i+60>>2]|0))a=sN(i,b,g,f,k)|0;else a=rN(i,b,g,f,k)|0;if(!a)tN(h,e,c[j>>2]|0,i,g,c[k>>2]|0);if(g)_I(d)}l=n;return a|0}function rN(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0;V=l;l=l+16|0;T=V;c[T>>2]=0;o=e&1;R=e&2;S=a+56|0;n=c[S>>2]&4;U=BM(0,0)|0;a:do if(U){p=DM(U,0,0,0,32)|0;if(!p){CM(U);e=12;break}c[p+24>>2]=0;c[p+28>>2]=0;Q=a+40|0;e=c[Q>>2]|0;if(e){e=ZI(e<<2)|0;if(!e){m=0;k=0;j=e;e=12;i=0;h=0;g=0}else{j=e;i=e;C=6}}else{j=0;i=0;C=6}b:do if((C|0)==6){e=c[a+28>>2]|0;if(e){e=ZI(e<<3)|0;if(!e){m=e;k=0;e=12;h=0;g=0;break}else{m=e;h=e}}else{m=0;h=0}P=a+52|0;e=c[P>>2]|0;if(e){e=ZI(e<<2)|0;if(!e){k=e;e=12;g=0;break}else{k=e;g=e}}else{k=0;g=0}K=a+8|0;L=a+12|0;M=(d|0)==0;N=(d|0)!=0;O=a+32|0;J=(n|0)!=0;I=(o|0)==0;r=b;e=1;q=-1;v=-1;B=0;c:while(1){n=c[Q>>2]|0;if((n|0)>0){o=0;do{c[j+(o<<2)>>2]=-1;if(!M){c[d+(o<<2)>>2]=-1;n=c[Q>>2]|0}o=o+1|0}while((o|0)<(n|0))}n=c[P>>2]|0;if((n|0)>0)VN(g|0,0,n<<2|0)|0;G=e+q|0;e=UL(T,r,4)|0;if((e|0)<1)if((e|0)<0){e=1;break b}else e=1;F=r+e|0;H=c[T>>2]|0;n=c[K>>2]|0;o=n+8|0;if(c[o>>2]|0){w=(G|0)!=0;x=(B|0)==95;y=(G|0)==0;A=J&(B|0)==10;z=(G|0)<1&I;u=n;n=0;t=0;s=o;while(1){r=u+20|0;o=c[r>>2]|0;d:do if(o)if((o&1|0)==0|z|A){if(o&2|0?(E=c[T>>2]|0,!((E|R|0)==0|J&(E|0)==10)):0){q=t;break}do if(o&16|0){if(x){q=t;break d}if(DK(B)|0){q=t;break d}o=c[T>>2]|0;if((o|0)==95)break;if(!(DK(o)|0)){q=t;break d}}while(0);o=c[r>>2]|0;if(o&32){if(x){o=c[T>>2]|0;if((o|0)==95){q=t;break}}else{E=(DK(B)|0)==0;o=c[T>>2]|0;if(E|(o|0)==95){q=t;break}}if(DK(o)|0){q=t;break}o=c[r>>2]|0}q=c[T>>2]|0;do if((q|0)!=0&(w&(o&64|0)!=0)){if(x)o=1;else{o=(DK(B)|0)!=0;q=c[T>>2]|0}if((q|0)==95)if(o){q=t;break d}else break;else if(o^(DK(q)|0)!=0)break;else{q=t;break d}}while(0);if(!(c[r>>2]&128)){C=49;break}o=c[T>>2]|0;if(y|(o|0)==0){q=t;break}if(x)q=1;else{q=(DK(B)|0)!=0;o=c[T>>2]|0}if((o|0)==95)if(q){C=49;break}else{q=t;break}else if(q^(DK(o)|0)!=0){q=t;break}else{C=49;break}}else q=t;else C=49;while(0);do if((C|0)==49){C=0;if(!t){n=c[u+16>>2]|0;q=c[s>>2]|0;break}q=p+28|0;o=c[q>>2]|0;if(!o){o=DM(U,0,0,0,32)|0;if(!o){C=53;break c}c[o+24>>2]=p;c[o+28>>2]=0;E=DM(U,0,0,0,c[Q>>2]<<2)|0;c[o+20>>2]=E;if(!E){C=60;break c}c[q>>2]=o;p=o}else p=o;c[p>>2]=G;c[p+4>>2]=F;c[p+8>>2]=c[s>>2];c[p+12>>2]=c[u+12>>2];c[p+16>>2]=c[T>>2];if((c[Q>>2]|0)>0){q=c[p+20>>2]|0;o=0;do{c[q+(o<<2)>>2]=c[j+(o<<2)>>2];o=o+1|0}while((o|0)<(c[Q>>2]|0))}o=c[u+16>>2]|0;if(!o)q=t;else{q=c[o>>2]|0;if((q|0)<=-1){q=t;break}r=c[p+20>>2]|0;do{o=o+4|0;c[r+(q<<2)>>2]=G;q=c[o>>2]|0}while((q|0)>-1);q=t}}while(0);s=u+40|0;if(!(c[s>>2]|0))break;else{u=u+32|0;t=q}}if(n){o=c[n>>2]|0;if((o|0)>-1)do{c[j+(o<<2)>>2]=G;n=n+4|0;o=c[n>>2]|0}while((o|0)>-1)}else n=0;if(!q)C=171;else{s=G;r=F;w=q;x=n;C=79}}else{n=0;C=171}e:while(1){if((C|0)==79){if((w|0)==(c[L>>2]|0)){if((v|0)>=(s|0)){if(!(N&(v|0)==(s|0))){n=x;C=171;continue}n=c[Q>>2]|0;if(!(vN(n,c[O>>2]|0,j,d)|0)){n=x;C=171;continue}}else{if(M){v=s;n=x;C=171;continue}n=c[Q>>2]|0}if((n|0)>0)n=0;else{v=s;n=x;C=171;continue}while(1){c[d+(n<<2)>>2]=c[j+(n<<2)>>2];n=n+1|0;if((n|0)>=(c[Q>>2]|0)){v=s;n=x;C=171;continue e}}}u=w+8|0;if((c[u>>2]|0)!=0?(c[w+20>>2]&256|0)!=0:0){o=c[w+24>>2]|0;tN(o+1|0,m,c[S>>2]&-9,a,j,s);E=c[m+(o<<3)>>2]|0;o=(c[m+(o<<3)+4>>2]|0)-E|0;if(VJ(b+E|0,r+-1|0,o)|0){n=x;C=171;continue}E=(o|0)==0;n=E&1;q=c[w+12>>2]|0;if(E?c[k+(q<<2)>>2]|0:0){n=x;C=171;continue}c[k+(q<<2)>>2]=n;o=o+-1|0;r=r+o|0;o=o+s|0;q=c[T>>2]|0;n=UL(T,r,4)|0;if((n|0)<1)if((n|0)<0){e=1;break b}else n=1;D=r+n|0;E=n}else{q=c[T>>2]|0;if(!q){n=x;C=171;continue}n=UL(T,r,4)|0;if((n|0)<1)if((n|0)<0){e=1;break b}else n=1;o=s;D=r+n|0;E=n}s=o+e|0;if(!(c[u>>2]|0)){e=E;n=x;C=171;continue}y=(s|0)!=0;z=(q|0)==95;A=(s|0)==0;C=J&(q|0)==10;B=(s|0)<1&I;t=0;n=x;while(1){f:do if((c[w>>2]|0)>>>0<=q>>>0){if((c[w+4>>2]|0)>>>0>>0)break;r=w+20|0;e=c[r>>2]|0;do if(e|0){if(!((e&1|0)==0|B|C))break f;if(e&2|0?(x=c[T>>2]|0,!((x|R|0)==0|J&(x|0)==10)):0)break f;do if(e&16|0){if(z)break f;if(DK(q)|0)break f;e=c[T>>2]|0;if((e|0)==95)break;if(!(DK(e)|0))break f}while(0);e=c[r>>2]|0;if(e&32){if(z){e=c[T>>2]|0;if((e|0)==95)break f}else{x=(DK(q)|0)==0;e=c[T>>2]|0;if(x|(e|0)==95)break f}if(DK(e)|0)break f;e=c[r>>2]|0}o=c[T>>2]|0;do if((o|0)!=0&(y&(e&64|0)!=0)){if(z)e=1;else{e=(DK(q)|0)!=0;o=c[T>>2]|0}if((o|0)==95)if(e)break f;else break;else if(e^(DK(o)|0)!=0)break;else break f}while(0);do if(c[r>>2]&128|0){e=c[T>>2]|0;if(A|(e|0)==0)break f;if(z)o=1;else{o=(DK(q)|0)!=0;e=c[T>>2]|0}if((e|0)==95)if(o)break;else break f;else if(o^(DK(e)|0)!=0)break f;else break}while(0);e=c[r>>2]|0;do if(e&4){if(c[S>>2]&2|0)break;if(!(CK(q,c[w+24>>2]|0)|0))break f;e=c[r>>2]|0}while(0);do if(e&4|0){if(!(c[S>>2]&2))break;x=KK(q)|0;e=w+24|0;if(CK(x,c[e>>2]|0)|0)break;x=lK(q)|0;if(!(CK(x,c[e>>2]|0)|0))break f}while(0);if(!(c[r>>2]&8))break;if(uN(c[w+28>>2]|0,q,c[S>>2]&2)|0)break f}while(0);if(!t){t=c[u>>2]|0;n=c[w+16>>2]|0;break}o=p+28|0;e=c[o>>2]|0;if(!e){e=DM(U,0,0,0,32)|0;if(!e){C=145;break c}c[e+24>>2]=p;c[e+28>>2]=0;x=DM(U,0,0,0,c[Q>>2]<<2)|0;c[e+20>>2]=x;if(!x){C=152;break c}c[o>>2]=e;p=e}else p=e;c[p>>2]=s;c[p+4>>2]=D;c[p+8>>2]=c[u>>2];c[p+12>>2]=c[w+12>>2];c[p+16>>2]=c[T>>2];if((c[Q>>2]|0)>0){o=c[p+20>>2]|0;e=0;do{c[o+(e<<2)>>2]=c[j+(e<<2)>>2];e=e+1|0}while((e|0)<(c[Q>>2]|0))}e=c[w+16>>2]|0;if(!e)break;o=c[e>>2]|0;if((o|0)<=-1)break;r=c[p+20>>2]|0;do{c[r+(o<<2)>>2]=s;e=e+4|0;o=c[e>>2]|0}while((o|0)>-1)}while(0);u=w+40|0;if(!(c[u>>2]|0))break;else w=w+32|0}if(!t){e=E;C=171;continue}if(n){e=c[n>>2]|0;if((e|0)>-1){do{n=n+4|0;c[j+(e<<2)>>2]=s;e=c[n>>2]|0}while((e|0)>-1);q=v;o=D;e=E}else{q=v;o=D;e=E}}else{q=v;o=D;e=E;n=0}}else if((C|0)==171){C=0;r=c[p+24>>2]|0;if(!r)break;t=c[p+8>>2]|0;if(c[t+20>>2]&256|0)c[k+(c[p+12>>2]<<2)>>2]=0;s=c[p>>2]|0;u=c[p+4>>2]|0;c[T>>2]=c[p+16>>2];q=c[Q>>2]|0;if((q|0)>0){p=c[p+20>>2]|0;o=0;do{c[j+(o<<2)>>2]=c[p+(o<<2)>>2];o=o+1|0}while((o|0)<(q|0));p=r;q=v;o=u}else{p=r;q=v;o=u}}r=o;v=q;w=t;x=n;C=79}n=(v|0)>-1;if(n|(c[T>>2]|0)==0){C=180;break}c[T>>2]=H;r=F;q=G;B=H}if((C|0)==53){CM(U);if(j|0)_I(i);if(m|0)_I(h);if(!k){e=12;break a}_I(g);e=12;break a}else if((C|0)==60){CM(U);if(j|0)_I(i);if(m|0)_I(h);if(!k){e=12;break a}_I(g);e=12;break a}else if((C|0)==145){CM(U);if(j|0)_I(i);if(m|0)_I(h);if(!k){e=12;break a}_I(g);e=12;break a}else if((C|0)==152){CM(U);if(j|0)_I(i);if(m|0)_I(h);if(!k){e=12;break a}_I(g);e=12;break a}else if((C|0)==180){c[f>>2]=v;e=(n^1)&1;break}}while(0);CM(U);if(j|0)_I(i);if(m|0)_I(h);if(k)_I(g)}else e=12;while(0);l=V;return e|0} +function sN(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0;W=l;l=l+16|0;T=W;c[T>>2]=0;k=e&1;Q=e&2;R=a+56|0;j=c[R>>2]&4;if(!d)N=0;else N=c[a+40>>2]|0;P=N<<2;i=a+52|0;e=c[i>>2]|0;h=e<<3;g=h+8|0;e=P+12+h+(g+(O(P,e)|0)<<1)|0;U=ZI(e)|0;if(!U)e=12;else{VN(U|0,0,e|0)|0;e=U+P|0;m=e&3;m=e+((m|0)==0?0:4-m|0)|0;e=m+g|0;n=e&3;n=e+((n|0)==0?0:4-n|0)|0;e=n+g|0;M=e&3;M=e+((M|0)==0?0:4-M|0)|0;e=M+h|0;g=e&3;i=c[i>>2]|0;h=(i|0)>0;if(h){e=e+((g|0)==0?0:4-g|0)|0;g=0;while(1){c[n+(g<<3)+4>>2]=e;e=e+P|0;c[m+(g<<3)+4>>2]=e;g=g+1|0;if((g|0)>=(i|0))break;else e=e+P|0}if(h){e=0;do{c[M+(e<<3)>>2]=-1;e=e+1|0}while((e|0)<(i|0))}}e=UL(T,b,4)|0;if((e|0)<1)if((e|0)<0)e=1;else{i=1;V=11}else{i=e;V=11}a:do if((V|0)==11){L=a+8|0;K=(j|0)!=0;E=(k|0)==0;F=(N|0)>0;G=a+12|0;H=(N|0)<1;I=a+44|0;J=a+32|0;C=a+36|0;D=(N|0)==0;h=0;v=b+i|0;u=0;j=0;e=-1;g=m;A=U;x=m;w=n;while(1){if((e|0)<0){a=c[L>>2]|0;k=a+8|0;b:do if(c[k>>2]|0){p=(u|0)!=0;q=(h|0)==95;r=(u|0)==0;t=K&(h|0)==10;s=(u|0)<1&E;while(1){c:while(1){o=a+12|0;if((c[M+(c[o>>2]<<3)>>2]|0)>=(u|0))break;n=a+20|0;b=c[n>>2]|0;if(!b){V=46;break}d:do if((b&1|0)==0|s|t){if(b&2|0?(B=c[T>>2]|0,!((B|Q|0)==0|K&(B|0)==10)):0)break;do if(b&16|0){if(q)break d;if(DK(h)|0)break d;b=c[T>>2]|0;if((b|0)==95)break;if(!(DK(b)|0))break d}while(0);b=c[n>>2]|0;if(b&32){if(q){b=c[T>>2]|0;if((b|0)==95)break}else{B=(DK(h)|0)==0;b=c[T>>2]|0;if(B|(b|0)==95)break}if(DK(b)|0)break;b=c[n>>2]|0}m=c[T>>2]|0;do if((m|0)!=0&(p&(b&64|0)!=0)){if(q)b=1;else{b=(DK(h)|0)!=0;m=c[T>>2]|0}if((m|0)==95)if(b)break d;else break;else if(b^(DK(m)|0)!=0)break;else break d}while(0);if(!(c[n>>2]&128)){V=46;break c}b=c[T>>2]|0;if(r|(b|0)==0)break;if(q)m=1;else{m=(DK(h)|0)!=0;b=c[T>>2]|0}if((b|0)==95)if(m){V=46;break c}else break;else if(m^(DK(b)|0)!=0)break;else{V=46;break c}}while(0);k=a+40|0;if(!(c[k>>2]|0))break b;else a=a+32|0}if((V|0)==46){V=0;c[g>>2]=c[k>>2];if(F)VN(c[g+4>>2]|0,-1,P|0)|0;k=c[a+16>>2]|0;if(k|0?(S=c[k>>2]|0,(S|0)>-1):0){m=g+4|0;b=S;do{if((b|0)<(N|0))c[(c[m>>2]|0)+(b<<2)>>2]=u;k=k+4|0;b=c[k>>2]|0}while((b|0)>-1)}k=(c[g>>2]|0)!=(c[G>>2]|0);if(k|H){j=k?j:1;e=k?e:u;k=g+4|0}else{k=g+4|0;j=c[k>>2]|0;e=0;do{c[d+(e<<2)>>2]=c[j+(e<<2)>>2];e=e+1|0}while((e|0)!=(N|0));j=1;e=u}B=c[o>>2]|0;c[M+(B<<3)>>2]=u;c[M+(B<<3)+4>>2]=k;g=g+8|0}k=a+40|0;if(!(c[k>>2]|0))break;else a=a+32|0}}while(0);c[g>>2]=0;g=c[T>>2]|0;if(!g)break;else h=g}else{if(D)break;h=c[T>>2]|0;if(!((g|0)!=(x|0)&(h|0)!=0))break}B=u+i|0;g=UL(T,v,4)|0;if((g|0)<1)if((g|0)<0){e=1;break a}else i=1;else i=g;z=v+i|0;if((j|0)!=0&(c[I>>2]|0)!=0){if(!(c[x>>2]|0))g=w;else{o=c[C>>2]|0;p=c[o>>2]|0;q=(p|0)>-1;n=x;g=w;do{m=n+4|0;e:do if(q){k=0;b=p;do{a=c[o+((k|1)<<2)>>2]|0;if((b|0)>=(N|0))break e;j=c[m>>2]|0;if((c[j+(a<<2)>>2]|0)==(c[d+(a<<2)>>2]|0)?(c[j+(b<<2)>>2]|0)<(c[d+(b<<2)>>2]|0):0)break e;k=k+2|0;b=c[o+(k<<2)>>2]|0}while((b|0)>-1);k=m;V=75}else{k=m;j=c[m>>2]|0;V=75}while(0);if((V|0)==75){V=0;c[g>>2]=c[n>>2];v=g+4|0;y=c[v>>2]|0;c[v>>2]=j;c[k>>2]=y;g=g+8|0}n=n+8|0}while((c[n>>2]|0)!=0)}c[g>>2]=0;y=x;j=0}else{y=w;w=x}k=c[w>>2]|0;if(!k){k=A;g=y}else{r=(B|0)!=0;s=(h|0)==95;t=(B|0)==0;v=K&(h|0)==10;u=(B|0)<1&E;q=w;a=A;g=y;while(1){b=k+8|0;if(c[b>>2]|0){p=q+4|0;o=a;n=b;while(1){f:do if((c[k>>2]|0)>>>0<=h>>>0?(c[k+4>>2]|0)>>>0>=h>>>0:0){m=k+20|0;a=c[m>>2]|0;do if(a|0){if(!((a&1|0)==0|u|v)){a=o;break f}if(a&2|0?(A=c[T>>2]|0,!((A|Q|0)==0|K&(A|0)==10)):0){a=o;break f}do if(a&16|0){if(s){a=o;break f}if(DK(h)|0){a=o;break f}a=c[T>>2]|0;if((a|0)==95)break;if(!(DK(a)|0)){a=o;break f}}while(0);a=c[m>>2]|0;if(a&32){if(s){a=c[T>>2]|0;if((a|0)==95){a=o;break f}}else{A=(DK(h)|0)==0;a=c[T>>2]|0;if(A|(a|0)==95){a=o;break f}}if(DK(a)|0){a=o;break f}a=c[m>>2]|0}b=c[T>>2]|0;do if((b|0)!=0&(r&(a&64|0)!=0)){if(s)a=1;else{a=(DK(h)|0)!=0;b=c[T>>2]|0}if((b|0)==95)if(a){a=o;break f}else break;else if(a^(DK(b)|0)!=0)break;else{a=o;break f}}while(0);do if(c[m>>2]&128|0){a=c[T>>2]|0;if(t|(a|0)==0){a=o;break f}if(s)b=1;else{b=(DK(h)|0)!=0;a=c[T>>2]|0}if((a|0)==95)if(b)break;else{a=o;break f}else if(b^(DK(a)|0)!=0){a=o;break f}else break}while(0);a=c[m>>2]|0;do if(a&4){if(c[R>>2]&2|0)break;if(!(CK(h,c[k+24>>2]|0)|0)){a=o;break f}a=c[m>>2]|0}while(0);do if(a&4|0){if(!(c[R>>2]&2))break;A=KK(h)|0;a=k+24|0;if(CK(A,c[a>>2]|0)|0)break;A=lK(h)|0;if(!(CK(A,c[a>>2]|0)|0)){a=o;break f}}while(0);if(!(c[m>>2]&8))break;if(uN(c[k+28>>2]|0,h,c[R>>2]&2)|0){a=o;break f}}while(0);if(F){b=c[p>>2]|0;a=0;do{c[o+(a<<2)>>2]=c[b+(a<<2)>>2];a=a+1|0}while((a|0)!=(N|0))}a=c[k+16>>2]|0;do if(a|0){b=c[a>>2]|0;if((b|0)<=-1)break;do{if((b|0)<(N|0))c[o+(b<<2)>>2]=B;a=a+4|0;b=c[a>>2]|0}while((b|0)>-1)}while(0);a=c[k+12>>2]|0;b=M+(a<<3)|0;if((c[b>>2]|0)>=(B|0)){a=c[M+(a<<3)+4>>2]|0;b=c[a>>2]|0;if(!(vN(N,c[J>>2]|0,o,b)|0)){a=o;break}c[a>>2]=o;if((c[n>>2]|0)!=(c[G>>2]|0)){a=b;break}if(F)e=0;else{j=1;a=b;e=B;break}while(1){c[d+(e<<2)>>2]=c[o+(e<<2)>>2];e=e+1|0;if((e|0)==(N|0)){j=1;a=b;e=B;break f}}}A=c[n>>2]|0;c[g>>2]=A;x=g+4|0;m=c[x>>2]|0;c[x>>2]=o;c[b>>2]=B;c[M+(a<<3)+4>>2]=x;do if((c[G>>2]|0)==(A|0)){if((e|0)==-1)if(F)e=0;else{e=B;j=1;break}else{if(!F)break;if((c[o>>2]|0)>(c[d>>2]|0))break;else e=0}do{c[d+(e<<2)>>2]=c[o+(e<<2)>>2];e=e+1|0}while((e|0)<(N|0));e=B;j=1}while(0);a=m;g=g+8|0}else a=o;while(0);n=k+40|0;if(!(c[n>>2]|0))break;else{k=k+32|0;o=a}}}q=q+8|0;k=c[q>>2]|0;if(!k){k=a;break}}}c[g>>2]=0;v=z;u=B;A=k;x=y}c[f>>2]=e;e=e>>>31}while(0);_I(U)}l=W;return e|0}function tN(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;if((d&8|0)==0&(g|0)>-1?(m=c[e+16>>2]|0,n=c[e+28>>2]|0,l=(a|0)!=0&(n|0)!=0,l):0){k=c[e+48>>2]|0;j=0;do{d=c[m+(j*12|0)>>2]|0;if((d|0)==(k|0))i=g;else i=c[f+(d<<2)>>2]|0;h=b+(j<<3)|0;c[h>>2]=i;d=c[m+(j*12|0)+4>>2]|0;if((d|0)==(k|0))d=g;else d=c[f+(d<<2)>>2]|0;e=b+(j<<3)+4|0;c[e>>2]=d;if((d|0)==-1|(i|0)==-1){c[e>>2]=-1;c[h>>2]=-1}j=j+1|0}while(j>>>0>>0&j>>>0>>0);if(l){d=0;do{i=b+(d<<3)+4|0;j=c[m+(d*12|0)+8>>2]|0;if(j|0?(o=c[j>>2]|0,(o|0)>-1):0){k=b+(d<<3)|0;h=0;f=o;e=c[k>>2]|0;do{if(!((e|0)>=(c[b+(f<<3)>>2]|0)?(c[i>>2]|0)<=(c[b+(f<<3)+4>>2]|0):0)){c[i>>2]=-1;c[k>>2]=-1;e=-1}h=h+1|0;f=c[j+(h<<2)>>2]|0}while((f|0)>-1)}d=d+1|0}while(d>>>0>>0&d>>>0>>0)}else d=0}else d=0;if(d>>>0>>0)VN(b+(d<<3)|0,-1,a-d<<3|0)|0;return}function uN(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=c[a>>2]|0;a:do if(!e)d=0;else{f=(d|0)==0;d=e;while(1){if(f){if(CK(b,d)|0){d=1;break a}}else{e=lK(b)|0;if(CK(e,c[a>>2]|0)|0){d=1;break a}e=KK(b)|0;if(CK(e,c[a>>2]|0)|0){d=1;break a}}a=a+4|0;d=c[a>>2]|0;if(!d){d=0;break}}}while(0);return d|0}function vN(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;a:do if((a|0)>0){f=0;while(1){h=c[d+(f<<2)>>2]|0;g=c[e+(f<<2)>>2]|0;if(!(c[b+(f<<2)>>2]|0)){if((h|0)<(g|0)){f=1;break a}if((h|0)>(g|0)){f=0;break a}}else{if((h|0)>(g|0)){f=1;break a}if((h|0)<(g|0)){f=0;break a}}f=f+1|0;if((f|0)>=(a|0)){f=0;break}}}else f=0;while(0);return f|0}function wN(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0;k=O(e,d)|0;e=(d|0)==0?0:e;if((c[f+76>>2]|0)>-1)j=OK(f)|0;else j=0;g=f+74|0;h=a[g>>0]|0;a[g>>0]=h+255|h;g=f+4|0;h=c[g>>2]|0;i=(c[f+8>>2]|0)-h|0;if((i|0)>0){i=i>>>0>>0?i:k;TN(b|0,h|0,i|0)|0;c[g>>2]=(c[g>>2]|0)+i;g=k-i|0;b=b+i|0}else g=k;a:do if(!g)l=13;else{i=f+32|0;while(1){if(eK(f)|0)break;h=bb[c[i>>2]&31](f,b,g)|0;if((h+1|0)>>>0<2)break;g=g-h|0;if(!g){l=13;break a}else b=b+h|0}if(j|0)PK(f);e=((k-g|0)>>>0)/(d>>>0)|0}while(0);if((l|0)==13)if(j)PK(f);return e|0}function xN(a){a=a|0;var b=0;if((c[a+76>>2]|0)>-1){b=(OK(a)|0)==0;a=yN(a)|0}else a=yN(a)|0;return a|0}function yN(a){a=a|0;var b=0;if(!(c[a>>2]&128))b=1;else b=(c[a+20>>2]|0)>>>0>(c[a+28>>2]|0)>>>0?2:1;b=bb[c[a+40>>2]&31](a,0,b)|0;if((b|0)>=0)b=b-(c[a+8>>2]|0)+(c[a+4>>2]|0)+(c[a+20>>2]|0)-(c[a+28>>2]|0)|0;return b|0}function zN(a){a=a|0;(c[a+76>>2]|0)>-1?OK(a)|0:0;return c[a+60>>2]|0}function AN(){var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;k=l;l=l+48|0;i=k+24|0;h=k+16|0;g=k;d=k+28|0;b=d;e=134988;f=b+20|0;do{a[b>>0]=a[e>>0]|0;b=b+1|0;e=e+1|0}while((b|0)<(f|0));e=d+13|0;b=0;while(1){AL(e)|0;c[g>>2]=d;c[g+4>>2]=32962;c[g+8>>2]=384;f=iJ(Ba(5,g|0)|0)|0;if((f|0)>-1){j=4;break}if((b|0)<99)b=b+1|0;else{b=0;break}}if((j|0)==4){c[h>>2]=d;sa(10,h|0)|0;b=SL(f,135008)|0;if(!b){c[i>>2]=f;Da(6,i|0)|0;b=0}}l=k;return b|0}function BN(a){a=a|0;var b=0,e=0,f=0;if((c[a+76>>2]|0)>=0?(OK(a)|0)!=0:0){b=a+4|0;e=c[b>>2]|0;if(e>>>0<(c[a+8>>2]|0)>>>0){c[b>>2]=e+1;b=d[e>>0]|0}else b=dK(a)|0}else f=3;do if((f|0)==3){b=a+4|0;e=c[b>>2]|0;if(e>>>0<(c[a+8>>2]|0)>>>0){c[b>>2]=e+1;b=d[e>>0]|0;break}else{b=dK(a)|0;break}}while(0);return b|0}function CN(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0;if((c[d+76>>2]|0)>=0?(OK(d)|0)!=0:0){f=b&255;e=b&255;if((e|0)!=(a[d+75>>0]|0)?(i=d+20|0,j=c[i>>2]|0,j>>>0<(c[d+16>>2]|0)>>>0):0){c[i>>2]=j+1;a[j>>0]=f}else e=YL(d,b)|0;PK(d)}else k=3;do if((k|0)==3){f=b&255;e=b&255;if((e|0)!=(a[d+75>>0]|0)?(g=d+20|0,h=c[g>>2]|0,h>>>0<(c[d+16>>2]|0)>>>0):0){c[g>>2]=h+1;a[h>>0]=f;break}e=YL(d,b)|0}while(0);return e|0}function DN(a){a=a|0;return xN(a)|0}function EN(){}function FN(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;f=a&65535;e=b&65535;c=O(e,f)|0;d=a>>>16;a=(c>>>16)+(O(e,d)|0)|0;e=b>>>16;b=O(e,f)|0;return (z=(a>>>16)+(O(e,d)|0)+(((a&65535)+b|0)>>>16)|0,a+b<<16|c&65535|0)|0}function GN(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;e=a;f=c;c=FN(e,f)|0;a=z;return (z=(O(b,f)|0)+(O(d,e)|0)+a|a&0,c|0|0)|0}function HN(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;c=a+c>>>0;return (z=b+d+(c>>>0>>0|0)>>>0,c|0)|0}function IN(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;d=b-d-(c>>>0>a>>>0|0)>>>0;return (z=d,a-c>>>0|0)|0}function JN(b){b=b|0;var c=0;c=a[n+(b&255)>>0]|0;if((c|0)<8)return c|0;c=a[n+(b>>8&255)>>0]|0;if((c|0)<8)return c+8|0;c=a[n+(b>>16&255)>>0]|0;if((c|0)<8)return c+16|0;return (a[n+(b>>>24)>>0]|0)+24|0}function KN(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;l=a;j=b;k=j;h=d;n=e;i=n;if(!k){g=(f|0)!=0;if(!i){if(g){c[f>>2]=(l>>>0)%(h>>>0);c[f+4>>2]=0}n=0;f=(l>>>0)/(h>>>0)>>>0;return (z=n,f)|0}else{if(!g){n=0;f=0;return (z=n,f)|0}c[f>>2]=a|0;c[f+4>>2]=b&0;n=0;f=0;return (z=n,f)|0}}g=(i|0)==0;do if(h){if(!g){g=(R(i|0)|0)-(R(k|0)|0)|0;if(g>>>0<=31){m=g+1|0;i=31-g|0;b=g-31>>31;h=m;a=l>>>(m>>>0)&b|k<>>(m>>>0)&b;g=0;i=l<>2]=a|0;c[f+4>>2]=j|b&0;n=0;f=0;return (z=n,f)|0}g=h-1|0;if(g&h|0){i=(R(h|0)|0)+33-(R(k|0)|0)|0;p=64-i|0;m=32-i|0;j=m>>31;o=i-32|0;b=o>>31;h=i;a=m-1>>31&k>>>(o>>>0)|(k<>>(i>>>0))&b;b=b&k>>>(i>>>0);g=l<>>(o>>>0))&j|l<>31;break}if(f|0){c[f>>2]=g&l;c[f+4>>2]=0}if((h|0)==1){o=j|b&0;p=a|0|0;return (z=o,p)|0}else{p=JN(h|0)|0;o=k>>>(p>>>0)|0;p=k<<32-p|l>>>(p>>>0)|0;return (z=o,p)|0}}else{if(g){if(f|0){c[f>>2]=(k>>>0)%(h>>>0);c[f+4>>2]=0}o=0;p=(k>>>0)/(h>>>0)>>>0;return (z=o,p)|0}if(!l){if(f|0){c[f>>2]=0;c[f+4>>2]=(k>>>0)%(i>>>0)}o=0;p=(k>>>0)/(i>>>0)>>>0;return (z=o,p)|0}g=i-1|0;if(!(g&i)){if(f|0){c[f>>2]=a|0;c[f+4>>2]=g&k|b&0}o=0;p=k>>>((JN(i|0)|0)>>>0);return (z=o,p)|0}g=(R(i|0)|0)-(R(k|0)|0)|0;if(g>>>0<=30){b=g+1|0;i=31-g|0;h=b;a=k<>>(b>>>0);b=k>>>(b>>>0);g=0;i=l<>2]=a|0;c[f+4>>2]=j|b&0;o=0;p=0;return (z=o,p)|0}while(0);if(!h){k=i;j=0;i=0}else{m=d|0|0;l=n|e&0;k=HN(m|0,l|0,-1,-1)|0;d=z;j=i;i=0;do{e=j;j=g>>>31|j<<1;g=i|g<<1;e=a<<1|e>>>31|0;n=a>>>31|b<<1|0;IN(k|0,d|0,e|0,n|0)|0;p=z;o=p>>31|((p|0)<0?-1:0)<<1;i=o&1;a=IN(e|0,n|0,o&m|0,(((p|0)<0?-1:0)>>31|((p|0)<0?-1:0)<<1)&l|0)|0;b=z;h=h-1|0}while((h|0)!=0);k=j;j=0}h=0;if(f|0){c[f>>2]=a;c[f+4>>2]=b}o=(g|0)>>>31|(k|h)<<1|(h<<1|g>>>31)&0|j;p=(g<<1|0>>>31)&-2|i;return (z=o,p)|0}function LN(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return KN(a,b,c,d,0)|0}function MN(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;g=l;l=l+16|0;f=g|0;KN(a,b,d,e,f)|0;l=g;return (z=c[f+4>>2]|0,c[f>>2]|0)|0}function NN(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){z=b>>>c;return a>>>c|(b&(1<>>c-32|0}function ON(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){z=b<>>32-c;return a<>8&255|0}function QN(a){a=a|0;return (a&255)<<24|(a>>8&255)<<16|(a>>16&255)<<8|a>>>24|0}function RN(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;q=q+1|0;c[a>>2]=q;while((f|0)<(e|0)){if(!(c[d+(f<<3)>>2]|0)){c[d+(f<<3)>>2]=q;c[d+((f<<3)+4)>>2]=b;c[d+((f<<3)+8)>>2]=0;z=e;return d|0}f=f+1|0}e=e*2|0;d=aJ(d|0,8*(e+1|0)|0)|0;d=RN(a|0,b|0,d|0,e|0)|0;z=e;return d|0}function SN(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;while((f|0)<(d|0)){e=c[b+(f<<3)>>2]|0;if(!e)break;if((e|0)==(a|0))return c[b+((f<<3)+4)>>2]|0;f=f+1|0}return 0}function TN(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;if((e|0)>=8192)return La(b|0,d|0,e|0)|0;h=b|0;g=b+e|0;if((b&3)==(d&3)){while(b&3){if(!e)return h|0;a[b>>0]=a[d>>0]|0;b=b+1|0;d=d+1|0;e=e-1|0}e=g&-4|0;f=e-64|0;while((b|0)<=(f|0)){c[b>>2]=c[d>>2];c[b+4>>2]=c[d+4>>2];c[b+8>>2]=c[d+8>>2];c[b+12>>2]=c[d+12>>2];c[b+16>>2]=c[d+16>>2];c[b+20>>2]=c[d+20>>2];c[b+24>>2]=c[d+24>>2];c[b+28>>2]=c[d+28>>2];c[b+32>>2]=c[d+32>>2];c[b+36>>2]=c[d+36>>2];c[b+40>>2]=c[d+40>>2];c[b+44>>2]=c[d+44>>2];c[b+48>>2]=c[d+48>>2];c[b+52>>2]=c[d+52>>2];c[b+56>>2]=c[d+56>>2];c[b+60>>2]=c[d+60>>2];b=b+64|0;d=d+64|0}while((b|0)<(e|0)){c[b>>2]=c[d>>2];b=b+4|0;d=d+4|0}}else{e=g-4|0;while((b|0)<(e|0)){a[b>>0]=a[d>>0]|0;a[b+1>>0]=a[d+1>>0]|0;a[b+2>>0]=a[d+2>>0]|0;a[b+3>>0]=a[d+3>>0]|0;b=b+4|0;d=d+4|0}}while((b|0)<(g|0)){a[b>>0]=a[d>>0]|0;b=b+1|0;d=d+1|0}return h|0}function UN(b,c,d){b=b|0;c=c|0;d=d|0;var e=0;if((c|0)<(b|0)&(b|0)<(c+d|0)){e=b;c=c+d|0;b=b+d|0;while((d|0)>0){b=b-1|0;c=c-1|0;d=d-1|0;a[b>>0]=a[c>>0]|0}b=e}else TN(b,c,d)|0;return b|0}function VN(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;h=b+e|0;d=d&255;if((e|0)>=67){while(b&3){a[b>>0]=d;b=b+1|0}f=h&-4|0;g=f-64|0;i=d|d<<8|d<<16|d<<24;while((b|0)<=(g|0)){c[b>>2]=i;c[b+4>>2]=i;c[b+8>>2]=i;c[b+12>>2]=i;c[b+16>>2]=i;c[b+20>>2]=i;c[b+24>>2]=i;c[b+28>>2]=i;c[b+32>>2]=i;c[b+36>>2]=i;c[b+40>>2]=i;c[b+44>>2]=i;c[b+48>>2]=i;c[b+52>>2]=i;c[b+56>>2]=i;c[b+60>>2]=i;b=b+64|0}while((b|0)<(f|0)){c[b>>2]=i;b=b+4|0}}while((b|0)<(h|0)){a[b>>0]=d;b=b+1|0}return h-e|0}function WN(a){a=a|0;var b=0,d=0;d=c[i>>2]|0;b=d+a|0;if((a|0)>0&(b|0)<(d|0)|(b|0)<0){W()|0;ra(12);return -1}c[i>>2]=b;if((b|0)>(V()|0)?(U()|0)==0:0){c[i>>2]=d;ra(12);return -1}return d|0}function XN(a){a=a|0;return +Ya[a&1]()}function YN(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;return +Za[a&7](+b,+c,+d)}function ZN(a){a=a|0;return _a[a&3]()|0}function _N(a,b){a=a|0;b=b|0;return $a[a&31](b|0)|0}function $N(a,b,c){a=a|0;b=b|0;c=c|0;return ab[a&63](b|0,c|0)|0}function aO(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return bb[a&31](b|0,c|0,d|0)|0}function bO(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return cb[a&31](b|0,c|0,d|0,e|0)|0}function cO(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return db[a&3](b|0,c|0,d|0,e|0,f|0)|0}function dO(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;return eb[a&1](b|0,c|0,d|0,e|0,f|0,g|0)|0}function eO(a){a=a|0;fb[a&15]()}function fO(a,b){a=a|0;b=b|0;gb[a&127](b|0)}function gO(a,b,c){a=a|0;b=b|0;c=c|0;hb[a&31](b|0,c|0)}function hO(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ib[a&127](b|0,c|0,d|0)}function iO(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;f=+f;g=g|0;jb[a&15](b|0,c|0,d|0,+e,+f,g|0)}function jO(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;kb[a&31](b|0,c|0,d|0,e|0)}function kO(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;lb[a&7](b|0,c|0,d|0,e|0,f|0)}function lO(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;mb[a&15](b|0,c|0,d|0,e|0,f|0,g|0)}function mO(){S(0);return 0.0}function nO(a,b,c){a=+a;b=+b;c=+c;S(1);return 0.0}function oO(){S(2);return 0}function pO(a){a=a|0;S(3);return 0}function qO(a,b){a=a|0;b=b|0;S(4);return 0}function rO(a,b,c){a=a|0;b=b|0;c=c|0;S(5);return 0}function sO(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;S(6);return 0}function tO(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;S(7);return 0}function uO(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;S(8);return 0}function vO(){S(9)}function wO(a){a=a|0;S(10)}function xO(a,b){a=a|0;b=b|0;S(11)}function yO(a,b,c){a=a|0;b=b|0;c=c|0;S(12)}function zO(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=+d;e=+e;f=f|0;S(13)}function AO(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;S(14)}function BO(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;S(15)}function CO(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;S(16)} + +// EMSCRIPTEN_END_FUNCS +var Ya=[mO,yA];var Za=[nO,Uu,Tu,Vu,Wu,nO,nO,nO];var _a=[oO,Fw,wx,oO];var $a=[pO,Rg,kg,Rn,Un,$B,aC,RD,SD,TD,UD,VD,WD,XD,YD,fJ,ub,or,ll,ol,Bw,Gw,nn,ww,co,NB,vw,SB,TB,NI,pO,pO];var ab=[qO,tn,Qn,Vn,yz,zz,qz,mz,Wy,mr,ag,Qg,rh,Vh,li,wk,uk,ml,pl,zq,yq,xq,Ds,Ts,Os,Ps,Ot,WL,CN,sA,uB,Im,wG,Pm,Rm,eo,OB,xJ,XE,JI,KI,nN,qO,qO,qO,qO,qO,qO,qO,qO,qO,qO,qO,qO,qO,qO,qO,qO,qO,qO,qO,qO,qO,qO];var bb=[rO,Pl,Vl,Pn,Tn,gG,gJ,hJ,lJ,mJ,$K,_l,Xl,zL,uA,Ex,$C,GI,eM,rO,rO,rO,rO,rO,rO,rO,rO,rO,rO,rO,rO,rO];var cb=[sO,Nm,Np,Om,fn,vn,xn,In,Hn,Wn,_n,ao,yx,CC,AC,wE,iG,EG,DG,Ml,wA,sO,sO,sO,sO,sO,sO,sO,sO,sO,sO,sO];var db=[tO,un,Xy,rz];var eb=[uO,kI];var fb=[vO,xA,Cw,Dw,Ew,Iw,Jw,Kw,mG,vO,vO,vO,vO,vO,vO,vO];var gb=[wO,zb,Ab,Eb,Fb,Gb,_b,$b,xc,yc,zc,Ac,Bc,Cc,Dc,Pc,Qc,Tc,Uc,Vc,Wc,Xc,Yc,Zc,jd,kd,ld,nd,od,pd,qd,rd,sd,td,ud,Fd,Gd,Hd,Jd,Kd,Ld,Md,Nd,Od,Pd,Qd,Rd,Td,ee,fe,ge,he,se,te,ue,we,Je,Ke,Le,Ne,Oe,Pe,Qe,Re,Se,Te,Ue,Ve,cf,df,ef,ff,Jf,Ef,yn,Cy,Uy,Ey,Dy,oz,ay,dy,ZD,cE,xf,ql,lm,lG,UC,VB,zx,_I,FG,jI,EI,FI,LI,wO,wO,wO,wO,wO,wO,wO,wO,wO,wO,wO,wO,wO,wO,wO,wO,wO,wO,wO,wO,wO,wO,wO,wO,wO,wO,wO,wO,wO,wO,wO];var hb=[xO,Fc,Kc,$c,ed,Bd,Zd,ne,Ce,$e,mf,Xn,Yy,Az,sz,nz,Sy,Ty,wz,xz,aE,eE,bm,rs,Hw,MB,iI,HI,II,MI,OI,xO];var ib=[yO,Hb,Ib,Lb,wc,Ec,Gc,Jc,_c,ad,dd,wd,xd,Ad,Ud,Vd,Yd,ie,je,me,xe,ye,Be,We,Xe,_e,gf,hf,lf,bk,ck,dk,im,zn,$n,Jo,Op,js,Ev,xx,cy,mB,BC,zC,_D,$D,bE,dE,fE,hG,WH,VH,Bm,bn,oo,Ro,Uo,Aw,vA,Cx,QB,UB,XH,ZH,_H,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO,yO];var jb=[zO,Ft,Gt,Ht,It,Jt,Kt,Lt,Mt,zO,zO,zO,zO,zO,zO,zO];var kb=[AO,Jb,Hc,bd,md,yd,Id,Wd,ke,ze,Me,Ye,jf,Af,zf,yf,wf,vf,uf,Zb,tf,sf,wn,Vy,pz,rL,PB,RB,AO,AO,AO,AO];var lb=[BO,Rc,vd,Cd,Sd,ve,nl,WB];var mb=[CO,Kb,Ic,cd,zd,Xd,le,Ae,Ze,kf,XB,CO,CO,CO,CO,CO];return{___errno_location:jJ,___muldi3:GN,___udivdi3:LN,___uremdi3:MN,_bitshift64Lshr:NN,_bitshift64Shl:ON,_dtdisc:Ll,_dtextract:Nl,_dtopen:Ql,_free:_I,_htons:eL,_i64Add:HN,_i64Subtract:IN,_llvm_bswap_i16:PN,_llvm_bswap_i32:QN,_malloc:ZI,_memalign:dJ,_memcpy:TN,_memmove:UN,_memset:VN,_realloc:aJ,_saveSetjmp:RN,_sbrk:WN,_testSetjmp:SN,_vizCreateFile:wb,_vizLastErrorMessage:vb,_vizRenderFromString:yb,_vizSetY_invert:xb,dynCall_d:XN,dynCall_dddd:YN,dynCall_i:ZN,dynCall_ii:_N,dynCall_iii:$N,dynCall_iiii:aO,dynCall_iiiii:bO,dynCall_iiiiii:cO,dynCall_iiiiiii:dO,dynCall_v:eO,dynCall_vi:fO,dynCall_vii:gO,dynCall_viii:hO,dynCall_viiiddi:iO,dynCall_viiii:jO,dynCall_viiiii:kO,dynCall_viiiiii:lO,establishStackSpace:qb,getTempRet0:tb,runPostSets:EN,setTempRet0:sb,setThrew:rb,stackAlloc:nb,stackRestore:pb,stackSave:ob}}) + + +// EMSCRIPTEN_END_ASM +(Module.asmGlobalArg,Module.asmLibraryArg,buffer);var ___errno_location=Module["___errno_location"]=asm["___errno_location"];var ___muldi3=Module["___muldi3"]=asm["___muldi3"];var ___udivdi3=Module["___udivdi3"]=asm["___udivdi3"];var ___uremdi3=Module["___uremdi3"]=asm["___uremdi3"];var _bitshift64Lshr=Module["_bitshift64Lshr"]=asm["_bitshift64Lshr"];var _bitshift64Shl=Module["_bitshift64Shl"]=asm["_bitshift64Shl"];var _dtdisc=Module["_dtdisc"]=asm["_dtdisc"];var _dtextract=Module["_dtextract"]=asm["_dtextract"];var _dtopen=Module["_dtopen"]=asm["_dtopen"];var _free=Module["_free"]=asm["_free"];var _htons=Module["_htons"]=asm["_htons"];var _i64Add=Module["_i64Add"]=asm["_i64Add"];var _i64Subtract=Module["_i64Subtract"]=asm["_i64Subtract"];var _llvm_bswap_i16=Module["_llvm_bswap_i16"]=asm["_llvm_bswap_i16"];var _llvm_bswap_i32=Module["_llvm_bswap_i32"]=asm["_llvm_bswap_i32"];var _malloc=Module["_malloc"]=asm["_malloc"];var _memalign=Module["_memalign"]=asm["_memalign"];var _memcpy=Module["_memcpy"]=asm["_memcpy"];var _memmove=Module["_memmove"]=asm["_memmove"];var _memset=Module["_memset"]=asm["_memset"];var _realloc=Module["_realloc"]=asm["_realloc"];var _saveSetjmp=Module["_saveSetjmp"]=asm["_saveSetjmp"];var _sbrk=Module["_sbrk"]=asm["_sbrk"];var _testSetjmp=Module["_testSetjmp"]=asm["_testSetjmp"];var _vizCreateFile=Module["_vizCreateFile"]=asm["_vizCreateFile"];var _vizLastErrorMessage=Module["_vizLastErrorMessage"]=asm["_vizLastErrorMessage"];var _vizRenderFromString=Module["_vizRenderFromString"]=asm["_vizRenderFromString"];var _vizSetY_invert=Module["_vizSetY_invert"]=asm["_vizSetY_invert"];var establishStackSpace=Module["establishStackSpace"]=asm["establishStackSpace"];var getTempRet0=Module["getTempRet0"]=asm["getTempRet0"];var runPostSets=Module["runPostSets"]=asm["runPostSets"];var setTempRet0=Module["setTempRet0"]=asm["setTempRet0"];var setThrew=Module["setThrew"]=asm["setThrew"];var stackAlloc=Module["stackAlloc"]=asm["stackAlloc"];var stackRestore=Module["stackRestore"]=asm["stackRestore"];var stackSave=Module["stackSave"]=asm["stackSave"];var dynCall_d=Module["dynCall_d"]=asm["dynCall_d"];var dynCall_dddd=Module["dynCall_dddd"]=asm["dynCall_dddd"];var dynCall_i=Module["dynCall_i"]=asm["dynCall_i"];var dynCall_ii=Module["dynCall_ii"]=asm["dynCall_ii"];var dynCall_iii=Module["dynCall_iii"]=asm["dynCall_iii"];var dynCall_iiii=Module["dynCall_iiii"]=asm["dynCall_iiii"];var dynCall_iiiii=Module["dynCall_iiiii"]=asm["dynCall_iiiii"];var dynCall_iiiiii=Module["dynCall_iiiiii"]=asm["dynCall_iiiiii"];var dynCall_iiiiiii=Module["dynCall_iiiiiii"]=asm["dynCall_iiiiiii"];var dynCall_v=Module["dynCall_v"]=asm["dynCall_v"];var dynCall_vi=Module["dynCall_vi"]=asm["dynCall_vi"];var dynCall_vii=Module["dynCall_vii"]=asm["dynCall_vii"];var dynCall_viii=Module["dynCall_viii"]=asm["dynCall_viii"];var dynCall_viiiddi=Module["dynCall_viiiddi"]=asm["dynCall_viiiddi"];var dynCall_viiii=Module["dynCall_viiii"]=asm["dynCall_viiii"];var dynCall_viiiii=Module["dynCall_viiiii"]=asm["dynCall_viiiii"];var dynCall_viiiiii=Module["dynCall_viiiiii"]=asm["dynCall_viiiiii"];Module["asm"]=asm;Module["ccall"]=ccall;Module["Pointer_stringify"]=Pointer_stringify;Module["UTF8ToString"]=UTF8ToString;if(memoryInitializer){if(!isDataURI(memoryInitializer)){if(typeof Module["locateFile"]==="function"){memoryInitializer=Module["locateFile"](memoryInitializer)}else if(Module["memoryInitializerPrefixURL"]){memoryInitializer=Module["memoryInitializerPrefixURL"]+memoryInitializer}}if(ENVIRONMENT_IS_NODE||ENVIRONMENT_IS_SHELL){var data=Module["readBinary"](memoryInitializer);HEAPU8.set(data,GLOBAL_BASE)}else{addRunDependency("memory initializer");var applyMemoryInitializer=(function(data){if(data.byteLength)data=new Uint8Array(data);HEAPU8.set(data,GLOBAL_BASE);if(Module["memoryInitializerRequest"])delete Module["memoryInitializerRequest"].response;removeRunDependency("memory initializer")});function doBrowserLoad(){Module["readAsync"](memoryInitializer,applyMemoryInitializer,(function(){throw"could not load memory initializer "+memoryInitializer}))}var memoryInitializerBytes=tryParseAsDataURI(memoryInitializer);if(memoryInitializerBytes){applyMemoryInitializer(memoryInitializerBytes.buffer)}else if(Module["memoryInitializerRequest"]){function useRequest(){var request=Module["memoryInitializerRequest"];var response=request.response;if(request.status!==200&&request.status!==0){var data=tryParseAsDataURI(Module["memoryInitializerRequestURL"]);if(data){response=data.buffer}else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+request.status+", retrying "+memoryInitializer);doBrowserLoad();return}}applyMemoryInitializer(response)}if(Module["memoryInitializerRequest"].response){setTimeout(useRequest,0)}else{Module["memoryInitializerRequest"].addEventListener("load",useRequest)}}else{doBrowserLoad()}}}function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}ExitStatus.prototype=new Error;ExitStatus.prototype.constructor=ExitStatus;var initialStackTop;dependenciesFulfilled=function runCaller(){if(!Module["calledRun"])run();if(!Module["calledRun"])dependenciesFulfilled=runCaller};function run(args){args=args||Module["arguments"];if(runDependencies>0){return}preRun();if(runDependencies>0)return;if(Module["calledRun"])return;function doRun(){if(Module["calledRun"])return;Module["calledRun"]=true;if(ABORT)return;ensureInitRuntime();preMain();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout((function(){setTimeout((function(){Module["setStatus"]("")}),1);doRun()}),1)}else{doRun()}}Module["run"]=run;function exit(status,implicit){if(implicit&&Module["noExitRuntime"]&&status===0){return}if(Module["noExitRuntime"]){}else{ABORT=true;EXITSTATUS=status;STACKTOP=initialStackTop;exitRuntime();if(Module["onExit"])Module["onExit"](status)}if(ENVIRONMENT_IS_NODE){process["exit"](status)}Module["quit"](status,new ExitStatus(status))}Module["exit"]=exit;function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}if(what!==undefined){Module.print(what);Module.printErr(what);what=JSON.stringify(what)}else{what=""}ABORT=true;EXITSTATUS=1;throw"abort("+what+"). Build with -s ASSERTIONS=1 for more info."}Module["abort"]=abort;if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}Module["noExitRuntime"]=true;run() + + + + + return Module; +}; + +function render(instance, src, options) { + var i; + for (i = 0; i < options.files.length; i++) { + instance['ccall']('vizCreateFile', 'number', ['string', 'string'], [options.files[i].path, options.files[i].data]); + } + + instance['ccall']('vizSetY_invert', 'number', ['number'], [options.yInvert ? 1 : 0]); + + var resultPointer = instance['ccall']('vizRenderFromString', 'number', ['string', 'string', 'string'], [src, options.format, options.engine]); + var resultString = instance['Pointer_stringify'](resultPointer); + instance['ccall']('free', 'number', ['number'], [resultPointer]); + + var errorMessagePointer = instance['ccall']('vizLastErrorMessage', 'number', [], []); + var errorMessageString = instance['Pointer_stringify'](errorMessagePointer); + instance['ccall']('free', 'number', ['number'], [errorMessagePointer]); + + if (errorMessageString != '') { + throw new Error(errorMessageString); + } + + return resultString; +} + +if (typeof importScripts === "function") { + var instance = Module(); + + onmessage = function(event) { + var id = event.data.id; + var src = event.data.src; + var options = event.data.options; + + try { + var result = render(instance, src, options); + postMessage({ id: id, result: result }); + } catch (error) { + postMessage({ id: id, error: { message: error.message, fileName: error.fileName, lineNumber: error.lineNumber } }); + } + } +} + +if (typeof exports === 'object' && typeof module !== 'undefined') { + module.exports = { render: render, Module: Module }; +} else if (typeof define === 'function' && define.amd) { + define(function() { return { render: render, Module: Module }; }); +} + +if (typeof global.Viz !== 'undefined') { + global.Viz.render = render; + global.Viz.Module = Module; +} + +})(typeof self !== 'undefined' ? self : this); + +/*! jQuery v3.3.1 | (c) JS Foundation and other contributors | jquery.org/license */ +!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){"use strict";var n=[],r=e.document,i=Object.getPrototypeOf,o=n.slice,a=n.concat,s=n.push,u=n.indexOf,l={},c=l.toString,f=l.hasOwnProperty,p=f.toString,d=p.call(Object),h={},g=function e(t){return"function"==typeof t&&"number"!=typeof t.nodeType},y=function e(t){return null!=t&&t===t.window},v={type:!0,src:!0,noModule:!0};function m(e,t,n){var i,o=(t=t||r).createElement("script");if(o.text=e,n)for(i in v)n[i]&&(o[i]=n[i]);t.head.appendChild(o).parentNode.removeChild(o)}function x(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[c.call(e)]||"object":typeof e}var b="3.3.1",w=function(e,t){return new w.fn.init(e,t)},T=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;w.fn=w.prototype={jquery:"3.3.1",constructor:w,length:0,toArray:function(){return o.call(this)},get:function(e){return null==e?o.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=w.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return w.each(this,e)},map:function(e){return this.pushStack(w.map(this,function(t,n){return e.call(t,n,t)}))},slice:function(){return this.pushStack(o.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(n>=0&&n0&&t-1 in e)}var E=function(e){var t,n,r,i,o,a,s,u,l,c,f,p,d,h,g,y,v,m,x,b="sizzle"+1*new Date,w=e.document,T=0,C=0,E=ae(),k=ae(),S=ae(),D=function(e,t){return e===t&&(f=!0),0},N={}.hasOwnProperty,A=[],j=A.pop,q=A.push,L=A.push,H=A.slice,O=function(e,t){for(var n=0,r=e.length;n+~]|"+M+")"+M+"*"),z=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),X=new RegExp(W),U=new RegExp("^"+R+"$"),V={ID:new RegExp("^#("+R+")"),CLASS:new RegExp("^\\.("+R+")"),TAG:new RegExp("^("+R+"|[*])"),ATTR:new RegExp("^"+I),PSEUDO:new RegExp("^"+W),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+P+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},G=/^(?:input|select|textarea|button)$/i,Y=/^h\d$/i,Q=/^[^{]+\{\s*\[native \w/,J=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,K=/[+~]/,Z=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),ee=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},te=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ne=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},re=function(){p()},ie=me(function(e){return!0===e.disabled&&("form"in e||"label"in e)},{dir:"parentNode",next:"legend"});try{L.apply(A=H.call(w.childNodes),w.childNodes),A[w.childNodes.length].nodeType}catch(e){L={apply:A.length?function(e,t){q.apply(e,H.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function oe(e,t,r,i){var o,s,l,c,f,h,v,m=t&&t.ownerDocument,T=t?t.nodeType:9;if(r=r||[],"string"!=typeof e||!e||1!==T&&9!==T&&11!==T)return r;if(!i&&((t?t.ownerDocument||t:w)!==d&&p(t),t=t||d,g)){if(11!==T&&(f=J.exec(e)))if(o=f[1]){if(9===T){if(!(l=t.getElementById(o)))return r;if(l.id===o)return r.push(l),r}else if(m&&(l=m.getElementById(o))&&x(t,l)&&l.id===o)return r.push(l),r}else{if(f[2])return L.apply(r,t.getElementsByTagName(e)),r;if((o=f[3])&&n.getElementsByClassName&&t.getElementsByClassName)return L.apply(r,t.getElementsByClassName(o)),r}if(n.qsa&&!S[e+" "]&&(!y||!y.test(e))){if(1!==T)m=t,v=e;else if("object"!==t.nodeName.toLowerCase()){(c=t.getAttribute("id"))?c=c.replace(te,ne):t.setAttribute("id",c=b),s=(h=a(e)).length;while(s--)h[s]="#"+c+" "+ve(h[s]);v=h.join(","),m=K.test(e)&&ge(t.parentNode)||t}if(v)try{return L.apply(r,m.querySelectorAll(v)),r}catch(e){}finally{c===b&&t.removeAttribute("id")}}}return u(e.replace(B,"$1"),t,r,i)}function ae(){var e=[];function t(n,i){return e.push(n+" ")>r.cacheLength&&delete t[e.shift()],t[n+" "]=i}return t}function se(e){return e[b]=!0,e}function ue(e){var t=d.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function le(e,t){var n=e.split("|"),i=n.length;while(i--)r.attrHandle[n[i]]=t}function ce(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function fe(e){return function(t){return"input"===t.nodeName.toLowerCase()&&t.type===e}}function pe(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function de(e){return function(t){return"form"in t?t.parentNode&&!1===t.disabled?"label"in t?"label"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&ie(t)===e:t.disabled===e:"label"in t&&t.disabled===e}}function he(e){return se(function(t){return t=+t,se(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function ge(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}n=oe.support={},o=oe.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&"HTML"!==t.nodeName},p=oe.setDocument=function(e){var t,i,a=e?e.ownerDocument||e:w;return a!==d&&9===a.nodeType&&a.documentElement?(d=a,h=d.documentElement,g=!o(d),w!==d&&(i=d.defaultView)&&i.top!==i&&(i.addEventListener?i.addEventListener("unload",re,!1):i.attachEvent&&i.attachEvent("onunload",re)),n.attributes=ue(function(e){return e.className="i",!e.getAttribute("className")}),n.getElementsByTagName=ue(function(e){return e.appendChild(d.createComment("")),!e.getElementsByTagName("*").length}),n.getElementsByClassName=Q.test(d.getElementsByClassName),n.getById=ue(function(e){return h.appendChild(e).id=b,!d.getElementsByName||!d.getElementsByName(b).length}),n.getById?(r.filter.ID=function(e){var t=e.replace(Z,ee);return function(e){return e.getAttribute("id")===t}},r.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&g){var n=t.getElementById(e);return n?[n]:[]}}):(r.filter.ID=function(e){var t=e.replace(Z,ee);return function(e){var n="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return n&&n.value===t}},r.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&g){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),r.find.TAG=n.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):n.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},r.find.CLASS=n.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&g)return t.getElementsByClassName(e)},v=[],y=[],(n.qsa=Q.test(d.querySelectorAll))&&(ue(function(e){h.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&y.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||y.push("\\["+M+"*(?:value|"+P+")"),e.querySelectorAll("[id~="+b+"-]").length||y.push("~="),e.querySelectorAll(":checked").length||y.push(":checked"),e.querySelectorAll("a#"+b+"+*").length||y.push(".#.+[+~]")}),ue(function(e){e.innerHTML="";var t=d.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&y.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&y.push(":enabled",":disabled"),h.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&y.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),y.push(",.*:")})),(n.matchesSelector=Q.test(m=h.matches||h.webkitMatchesSelector||h.mozMatchesSelector||h.oMatchesSelector||h.msMatchesSelector))&&ue(function(e){n.disconnectedMatch=m.call(e,"*"),m.call(e,"[s!='']:x"),v.push("!=",W)}),y=y.length&&new RegExp(y.join("|")),v=v.length&&new RegExp(v.join("|")),t=Q.test(h.compareDocumentPosition),x=t||Q.test(h.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},D=t?function(e,t){if(e===t)return f=!0,0;var r=!e.compareDocumentPosition-!t.compareDocumentPosition;return r||(1&(r=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!n.sortDetached&&t.compareDocumentPosition(e)===r?e===d||e.ownerDocument===w&&x(w,e)?-1:t===d||t.ownerDocument===w&&x(w,t)?1:c?O(c,e)-O(c,t):0:4&r?-1:1)}:function(e,t){if(e===t)return f=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e===d?-1:t===d?1:i?-1:o?1:c?O(c,e)-O(c,t):0;if(i===o)return ce(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?ce(a[r],s[r]):a[r]===w?-1:s[r]===w?1:0},d):d},oe.matches=function(e,t){return oe(e,null,null,t)},oe.matchesSelector=function(e,t){if((e.ownerDocument||e)!==d&&p(e),t=t.replace(z,"='$1']"),n.matchesSelector&&g&&!S[t+" "]&&(!v||!v.test(t))&&(!y||!y.test(t)))try{var r=m.call(e,t);if(r||n.disconnectedMatch||e.document&&11!==e.document.nodeType)return r}catch(e){}return oe(t,d,null,[e]).length>0},oe.contains=function(e,t){return(e.ownerDocument||e)!==d&&p(e),x(e,t)},oe.attr=function(e,t){(e.ownerDocument||e)!==d&&p(e);var i=r.attrHandle[t.toLowerCase()],o=i&&N.call(r.attrHandle,t.toLowerCase())?i(e,t,!g):void 0;return void 0!==o?o:n.attributes||!g?e.getAttribute(t):(o=e.getAttributeNode(t))&&o.specified?o.value:null},oe.escape=function(e){return(e+"").replace(te,ne)},oe.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},oe.uniqueSort=function(e){var t,r=[],i=0,o=0;if(f=!n.detectDuplicates,c=!n.sortStable&&e.slice(0),e.sort(D),f){while(t=e[o++])t===e[o]&&(i=r.push(o));while(i--)e.splice(r[i],1)}return c=null,e},i=oe.getText=function(e){var t,n="",r=0,o=e.nodeType;if(o){if(1===o||9===o||11===o){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=i(e)}else if(3===o||4===o)return e.nodeValue}else while(t=e[r++])n+=i(t);return n},(r=oe.selectors={cacheLength:50,createPseudo:se,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(Z,ee),e[3]=(e[3]||e[4]||e[5]||"").replace(Z,ee),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||oe.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&oe.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return V.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=a(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(Z,ee).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=E[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&E(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=oe.attr(r,e);return null==i?"!="===t:!t||(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i.replace($," ")+" ").indexOf(n)>-1:"|="===t&&(i===n||i.slice(0,n.length+1)===n+"-"))}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,f,p,d,h,g=o!==a?"nextSibling":"previousSibling",y=t.parentNode,v=s&&t.nodeName.toLowerCase(),m=!u&&!s,x=!1;if(y){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===v:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?y.firstChild:y.lastChild],a&&m){x=(d=(l=(c=(f=(p=y)[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]||[])[0]===T&&l[1])&&l[2],p=d&&y.childNodes[d];while(p=++d&&p&&p[g]||(x=d=0)||h.pop())if(1===p.nodeType&&++x&&p===t){c[e]=[T,d,x];break}}else if(m&&(x=d=(l=(c=(f=(p=t)[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]||[])[0]===T&&l[1]),!1===x)while(p=++d&&p&&p[g]||(x=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===v:1===p.nodeType)&&++x&&(m&&((c=(f=p[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]=[T,x]),p===t))break;return(x-=i)===r||x%r==0&&x/r>=0}}},PSEUDO:function(e,t){var n,i=r.pseudos[e]||r.setFilters[e.toLowerCase()]||oe.error("unsupported pseudo: "+e);return i[b]?i(t):i.length>1?(n=[e,e,"",t],r.setFilters.hasOwnProperty(e.toLowerCase())?se(function(e,n){var r,o=i(e,t),a=o.length;while(a--)e[r=O(e,o[a])]=!(n[r]=o[a])}):function(e){return i(e,0,n)}):i}},pseudos:{not:se(function(e){var t=[],n=[],r=s(e.replace(B,"$1"));return r[b]?se(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),t[0]=null,!n.pop()}}),has:se(function(e){return function(t){return oe(e,t).length>0}}),contains:se(function(e){return e=e.replace(Z,ee),function(t){return(t.textContent||t.innerText||i(t)).indexOf(e)>-1}}),lang:se(function(e){return U.test(e||"")||oe.error("unsupported lang: "+e),e=e.replace(Z,ee).toLowerCase(),function(t){var n;do{if(n=g?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return(n=n.toLowerCase())===e||0===n.indexOf(e+"-")}while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===h},focus:function(e){return e===d.activeElement&&(!d.hasFocus||d.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:de(!1),disabled:de(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!r.pseudos.empty(e)},header:function(e){return Y.test(e.nodeName)},input:function(e){return G.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:he(function(){return[0]}),last:he(function(e,t){return[t-1]}),eq:he(function(e,t,n){return[n<0?n+t:n]}),even:he(function(e,t){for(var n=0;n=0;)e.push(r);return e}),gt:he(function(e,t,n){for(var r=n<0?n+t:n;++r1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function be(e,t,n){for(var r=0,i=t.length;r-1&&(o[l]=!(a[l]=f))}}else v=we(v===a?v.splice(h,v.length):v),i?i(null,a,v,u):L.apply(a,v)})}function Ce(e){for(var t,n,i,o=e.length,a=r.relative[e[0].type],s=a||r.relative[" "],u=a?1:0,c=me(function(e){return e===t},s,!0),f=me(function(e){return O(t,e)>-1},s,!0),p=[function(e,n,r){var i=!a&&(r||n!==l)||((t=n).nodeType?c(e,n,r):f(e,n,r));return t=null,i}];u1&&xe(p),u>1&&ve(e.slice(0,u-1).concat({value:" "===e[u-2].type?"*":""})).replace(B,"$1"),n,u0,i=e.length>0,o=function(o,a,s,u,c){var f,h,y,v=0,m="0",x=o&&[],b=[],w=l,C=o||i&&r.find.TAG("*",c),E=T+=null==w?1:Math.random()||.1,k=C.length;for(c&&(l=a===d||a||c);m!==k&&null!=(f=C[m]);m++){if(i&&f){h=0,a||f.ownerDocument===d||(p(f),s=!g);while(y=e[h++])if(y(f,a||d,s)){u.push(f);break}c&&(T=E)}n&&((f=!y&&f)&&v--,o&&x.push(f))}if(v+=m,n&&m!==v){h=0;while(y=t[h++])y(x,b,a,s);if(o){if(v>0)while(m--)x[m]||b[m]||(b[m]=j.call(u));b=we(b)}L.apply(u,b),c&&!o&&b.length>0&&v+t.length>1&&oe.uniqueSort(u)}return c&&(T=E,l=w),x};return n?se(o):o}return s=oe.compile=function(e,t){var n,r=[],i=[],o=S[e+" "];if(!o){t||(t=a(e)),n=t.length;while(n--)(o=Ce(t[n]))[b]?r.push(o):i.push(o);(o=S(e,Ee(i,r))).selector=e}return o},u=oe.select=function(e,t,n,i){var o,u,l,c,f,p="function"==typeof e&&e,d=!i&&a(e=p.selector||e);if(n=n||[],1===d.length){if((u=d[0]=d[0].slice(0)).length>2&&"ID"===(l=u[0]).type&&9===t.nodeType&&g&&r.relative[u[1].type]){if(!(t=(r.find.ID(l.matches[0].replace(Z,ee),t)||[])[0]))return n;p&&(t=t.parentNode),e=e.slice(u.shift().value.length)}o=V.needsContext.test(e)?0:u.length;while(o--){if(l=u[o],r.relative[c=l.type])break;if((f=r.find[c])&&(i=f(l.matches[0].replace(Z,ee),K.test(u[0].type)&&ge(t.parentNode)||t))){if(u.splice(o,1),!(e=i.length&&ve(u)))return L.apply(n,i),n;break}}}return(p||s(e,d))(i,t,!g,n,!t||K.test(e)&&ge(t.parentNode)||t),n},n.sortStable=b.split("").sort(D).join("")===b,n.detectDuplicates=!!f,p(),n.sortDetached=ue(function(e){return 1&e.compareDocumentPosition(d.createElement("fieldset"))}),ue(function(e){return e.innerHTML="","#"===e.firstChild.getAttribute("href")})||le("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),n.attributes&&ue(function(e){return e.innerHTML="",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||le("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),ue(function(e){return null==e.getAttribute("disabled")})||le(P,function(e,t,n){var r;if(!n)return!0===e[t]?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),oe}(e);w.find=E,w.expr=E.selectors,w.expr[":"]=w.expr.pseudos,w.uniqueSort=w.unique=E.uniqueSort,w.text=E.getText,w.isXMLDoc=E.isXML,w.contains=E.contains,w.escapeSelector=E.escape;var k=function(e,t,n){var r=[],i=void 0!==n;while((e=e[t])&&9!==e.nodeType)if(1===e.nodeType){if(i&&w(e).is(n))break;r.push(e)}return r},S=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},D=w.expr.match.needsContext;function N(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}var A=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,t,n){return g(t)?w.grep(e,function(e,r){return!!t.call(e,r,e)!==n}):t.nodeType?w.grep(e,function(e){return e===t!==n}):"string"!=typeof t?w.grep(e,function(e){return u.call(t,e)>-1!==n}):w.filter(t,e,n)}w.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?w.find.matchesSelector(r,e)?[r]:[]:w.find.matches(e,w.grep(t,function(e){return 1===e.nodeType}))},w.fn.extend({find:function(e){var t,n,r=this.length,i=this;if("string"!=typeof e)return this.pushStack(w(e).filter(function(){for(t=0;t1?w.uniqueSort(n):n},filter:function(e){return this.pushStack(j(this,e||[],!1))},not:function(e){return this.pushStack(j(this,e||[],!0))},is:function(e){return!!j(this,"string"==typeof e&&D.test(e)?w(e):e||[],!1).length}});var q,L=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(w.fn.init=function(e,t,n){var i,o;if(!e)return this;if(n=n||q,"string"==typeof e){if(!(i="<"===e[0]&&">"===e[e.length-1]&&e.length>=3?[null,e,null]:L.exec(e))||!i[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(i[1]){if(t=t instanceof w?t[0]:t,w.merge(this,w.parseHTML(i[1],t&&t.nodeType?t.ownerDocument||t:r,!0)),A.test(i[1])&&w.isPlainObject(t))for(i in t)g(this[i])?this[i](t[i]):this.attr(i,t[i]);return this}return(o=r.getElementById(i[2]))&&(this[0]=o,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):g(e)?void 0!==n.ready?n.ready(e):e(w):w.makeArray(e,this)}).prototype=w.fn,q=w(r);var H=/^(?:parents|prev(?:Until|All))/,O={children:!0,contents:!0,next:!0,prev:!0};w.fn.extend({has:function(e){var t=w(e,this),n=t.length;return this.filter(function(){for(var e=0;e-1:1===n.nodeType&&w.find.matchesSelector(n,e))){o.push(n);break}return this.pushStack(o.length>1?w.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?u.call(w(e),this[0]):u.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(w.uniqueSort(w.merge(this.get(),w(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}});function P(e,t){while((e=e[t])&&1!==e.nodeType);return e}w.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return k(e,"parentNode")},parentsUntil:function(e,t,n){return k(e,"parentNode",n)},next:function(e){return P(e,"nextSibling")},prev:function(e){return P(e,"previousSibling")},nextAll:function(e){return k(e,"nextSibling")},prevAll:function(e){return k(e,"previousSibling")},nextUntil:function(e,t,n){return k(e,"nextSibling",n)},prevUntil:function(e,t,n){return k(e,"previousSibling",n)},siblings:function(e){return S((e.parentNode||{}).firstChild,e)},children:function(e){return S(e.firstChild)},contents:function(e){return N(e,"iframe")?e.contentDocument:(N(e,"template")&&(e=e.content||e),w.merge([],e.childNodes))}},function(e,t){w.fn[e]=function(n,r){var i=w.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=w.filter(r,i)),this.length>1&&(O[e]||w.uniqueSort(i),H.test(e)&&i.reverse()),this.pushStack(i)}});var M=/[^\x20\t\r\n\f]+/g;function R(e){var t={};return w.each(e.match(M)||[],function(e,n){t[n]=!0}),t}w.Callbacks=function(e){e="string"==typeof e?R(e):w.extend({},e);var t,n,r,i,o=[],a=[],s=-1,u=function(){for(i=i||e.once,r=t=!0;a.length;s=-1){n=a.shift();while(++s-1)o.splice(n,1),n<=s&&s--}),this},has:function(e){return e?w.inArray(e,o)>-1:o.length>0},empty:function(){return o&&(o=[]),this},disable:function(){return i=a=[],o=n="",this},disabled:function(){return!o},lock:function(){return i=a=[],n||t||(o=n=""),this},locked:function(){return!!i},fireWith:function(e,n){return i||(n=[e,(n=n||[]).slice?n.slice():n],a.push(n),t||u()),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!r}};return l};function I(e){return e}function W(e){throw e}function $(e,t,n,r){var i;try{e&&g(i=e.promise)?i.call(e).done(t).fail(n):e&&g(i=e.then)?i.call(e,t,n):t.apply(void 0,[e].slice(r))}catch(e){n.apply(void 0,[e])}}w.extend({Deferred:function(t){var n=[["notify","progress",w.Callbacks("memory"),w.Callbacks("memory"),2],["resolve","done",w.Callbacks("once memory"),w.Callbacks("once memory"),0,"resolved"],["reject","fail",w.Callbacks("once memory"),w.Callbacks("once memory"),1,"rejected"]],r="pending",i={state:function(){return r},always:function(){return o.done(arguments).fail(arguments),this},"catch":function(e){return i.then(null,e)},pipe:function(){var e=arguments;return w.Deferred(function(t){w.each(n,function(n,r){var i=g(e[r[4]])&&e[r[4]];o[r[1]](function(){var e=i&&i.apply(this,arguments);e&&g(e.promise)?e.promise().progress(t.notify).done(t.resolve).fail(t.reject):t[r[0]+"With"](this,i?[e]:arguments)})}),e=null}).promise()},then:function(t,r,i){var o=0;function a(t,n,r,i){return function(){var s=this,u=arguments,l=function(){var e,l;if(!(t=o&&(r!==W&&(s=void 0,u=[e]),n.rejectWith(s,u))}};t?c():(w.Deferred.getStackHook&&(c.stackTrace=w.Deferred.getStackHook()),e.setTimeout(c))}}return w.Deferred(function(e){n[0][3].add(a(0,e,g(i)?i:I,e.notifyWith)),n[1][3].add(a(0,e,g(t)?t:I)),n[2][3].add(a(0,e,g(r)?r:W))}).promise()},promise:function(e){return null!=e?w.extend(e,i):i}},o={};return w.each(n,function(e,t){var a=t[2],s=t[5];i[t[1]]=a.add,s&&a.add(function(){r=s},n[3-e][2].disable,n[3-e][3].disable,n[0][2].lock,n[0][3].lock),a.add(t[3].fire),o[t[0]]=function(){return o[t[0]+"With"](this===o?void 0:this,arguments),this},o[t[0]+"With"]=a.fireWith}),i.promise(o),t&&t.call(o,o),o},when:function(e){var t=arguments.length,n=t,r=Array(n),i=o.call(arguments),a=w.Deferred(),s=function(e){return function(n){r[e]=this,i[e]=arguments.length>1?o.call(arguments):n,--t||a.resolveWith(r,i)}};if(t<=1&&($(e,a.done(s(n)).resolve,a.reject,!t),"pending"===a.state()||g(i[n]&&i[n].then)))return a.then();while(n--)$(i[n],s(n),a.reject);return a.promise()}});var B=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;w.Deferred.exceptionHook=function(t,n){e.console&&e.console.warn&&t&&B.test(t.name)&&e.console.warn("jQuery.Deferred exception: "+t.message,t.stack,n)},w.readyException=function(t){e.setTimeout(function(){throw t})};var F=w.Deferred();w.fn.ready=function(e){return F.then(e)["catch"](function(e){w.readyException(e)}),this},w.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--w.readyWait:w.isReady)||(w.isReady=!0,!0!==e&&--w.readyWait>0||F.resolveWith(r,[w]))}}),w.ready.then=F.then;function _(){r.removeEventListener("DOMContentLoaded",_),e.removeEventListener("load",_),w.ready()}"complete"===r.readyState||"loading"!==r.readyState&&!r.documentElement.doScroll?e.setTimeout(w.ready):(r.addEventListener("DOMContentLoaded",_),e.addEventListener("load",_));var z=function(e,t,n,r,i,o,a){var s=0,u=e.length,l=null==n;if("object"===x(n)){i=!0;for(s in n)z(e,t,s,n[s],!0,o,a)}else if(void 0!==r&&(i=!0,g(r)||(a=!0),l&&(a?(t.call(e,r),t=null):(l=t,t=function(e,t,n){return l.call(w(e),n)})),t))for(;s1,null,!0)},removeData:function(e){return this.each(function(){K.remove(this,e)})}}),w.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=J.get(e,t),n&&(!r||Array.isArray(n)?r=J.access(e,t,w.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=w.queue(e,t),r=n.length,i=n.shift(),o=w._queueHooks(e,t),a=function(){w.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return J.get(e,n)||J.access(e,n,{empty:w.Callbacks("once memory").add(function(){J.remove(e,[t+"queue",n])})})}}),w.fn.extend({queue:function(e,t){var n=2;return"string"!=typeof e&&(t=e,e="fx",n--),arguments.length\x20\t\r\n\f]+)/i,he=/^$|^module$|\/(?:java|ecma)script/i,ge={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};ge.optgroup=ge.option,ge.tbody=ge.tfoot=ge.colgroup=ge.caption=ge.thead,ge.th=ge.td;function ye(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&N(e,t)?w.merge([e],n):n}function ve(e,t){for(var n=0,r=e.length;n-1)i&&i.push(o);else if(l=w.contains(o.ownerDocument,o),a=ye(f.appendChild(o),"script"),l&&ve(a),n){c=0;while(o=a[c++])he.test(o.type||"")&&n.push(o)}return f}!function(){var e=r.createDocumentFragment().appendChild(r.createElement("div")),t=r.createElement("input");t.setAttribute("type","radio"),t.setAttribute("checked","checked"),t.setAttribute("name","t"),e.appendChild(t),h.checkClone=e.cloneNode(!0).cloneNode(!0).lastChild.checked,e.innerHTML="",h.noCloneChecked=!!e.cloneNode(!0).lastChild.defaultValue}();var be=r.documentElement,we=/^key/,Te=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Ce=/^([^.]*)(?:\.(.+)|)/;function Ee(){return!0}function ke(){return!1}function Se(){try{return r.activeElement}catch(e){}}function De(e,t,n,r,i,o){var a,s;if("object"==typeof t){"string"!=typeof n&&(r=r||n,n=void 0);for(s in t)De(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=ke;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return w().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=w.guid++)),e.each(function(){w.event.add(this,t,i,r,n)})}w.event={global:{},add:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=J.get(e);if(y){n.handler&&(n=(o=n).handler,i=o.selector),i&&w.find.matchesSelector(be,i),n.guid||(n.guid=w.guid++),(u=y.events)||(u=y.events={}),(a=y.handle)||(a=y.handle=function(t){return"undefined"!=typeof w&&w.event.triggered!==t.type?w.event.dispatch.apply(e,arguments):void 0}),l=(t=(t||"").match(M)||[""]).length;while(l--)d=g=(s=Ce.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=w.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=w.event.special[d]||{},c=w.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&w.expr.match.needsContext.test(i),namespace:h.join(".")},o),(p=u[d])||((p=u[d]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(e,r,h,a)||e.addEventListener&&e.addEventListener(d,a)),f.add&&(f.add.call(e,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),w.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=J.hasData(e)&&J.get(e);if(y&&(u=y.events)){l=(t=(t||"").match(M)||[""]).length;while(l--)if(s=Ce.exec(t[l])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){f=w.event.special[d]||{},p=u[d=(r?f.delegateType:f.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&!1!==f.teardown.call(e,h,y.handle)||w.removeEvent(e,d,y.handle),delete u[d])}else for(d in u)w.event.remove(e,d+t[l],n,r,!0);w.isEmptyObject(u)&&J.remove(e,"handle events")}},dispatch:function(e){var t=w.event.fix(e),n,r,i,o,a,s,u=new Array(arguments.length),l=(J.get(this,"events")||{})[t.type]||[],c=w.event.special[t.type]||{};for(u[0]=t,n=1;n=1))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==e.type||!0!==l.disabled)){for(o=[],a={},n=0;n-1:w.find(i,this,null,[l]).length),a[i]&&o.push(r);o.length&&s.push({elem:l,handlers:o})}return l=this,u\x20\t\r\n\f]*)[^>]*)\/>/gi,Ae=/\s*$/g;function Le(e,t){return N(e,"table")&&N(11!==t.nodeType?t:t.firstChild,"tr")?w(e).children("tbody")[0]||e:e}function He(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Oe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Pe(e,t){var n,r,i,o,a,s,u,l;if(1===t.nodeType){if(J.hasData(e)&&(o=J.access(e),a=J.set(t,o),l=o.events)){delete a.handle,a.events={};for(i in l)for(n=0,r=l[i].length;n1&&"string"==typeof y&&!h.checkClone&&je.test(y))return e.each(function(i){var o=e.eq(i);v&&(t[0]=y.call(this,i,o.html())),Re(o,t,n,r)});if(p&&(i=xe(t,e[0].ownerDocument,!1,e,r),o=i.firstChild,1===i.childNodes.length&&(i=o),o||r)){for(u=(s=w.map(ye(i,"script"),He)).length;f")},clone:function(e,t,n){var r,i,o,a,s=e.cloneNode(!0),u=w.contains(e.ownerDocument,e);if(!(h.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||w.isXMLDoc(e)))for(a=ye(s),r=0,i=(o=ye(e)).length;r0&&ve(a,!u&&ye(e,"script")),s},cleanData:function(e){for(var t,n,r,i=w.event.special,o=0;void 0!==(n=e[o]);o++)if(Y(n)){if(t=n[J.expando]){if(t.events)for(r in t.events)i[r]?w.event.remove(n,r):w.removeEvent(n,r,t.handle);n[J.expando]=void 0}n[K.expando]&&(n[K.expando]=void 0)}}}),w.fn.extend({detach:function(e){return Ie(this,e,!0)},remove:function(e){return Ie(this,e)},text:function(e){return z(this,function(e){return void 0===e?w.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return Re(this,arguments,function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||Le(this,e).appendChild(e)})},prepend:function(){return Re(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Le(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return Re(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return Re(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(w.cleanData(ye(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return w.clone(this,e,t)})},html:function(e){return z(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!Ae.test(e)&&!ge[(de.exec(e)||["",""])[1].toLowerCase()]){e=w.htmlPrefilter(e);try{for(;n=0&&(u+=Math.max(0,Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-o-u-s-.5))),u}function et(e,t,n){var r=$e(e),i=Fe(e,t,r),o="border-box"===w.css(e,"boxSizing",!1,r),a=o;if(We.test(i)){if(!n)return i;i="auto"}return a=a&&(h.boxSizingReliable()||i===e.style[t]),("auto"===i||!parseFloat(i)&&"inline"===w.css(e,"display",!1,r))&&(i=e["offset"+t[0].toUpperCase()+t.slice(1)],a=!0),(i=parseFloat(i)||0)+Ze(e,t,n||(o?"border":"content"),a,r,i)+"px"}w.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Fe(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,a,s=G(t),u=Xe.test(t),l=e.style;if(u||(t=Je(s)),a=w.cssHooks[t]||w.cssHooks[s],void 0===n)return a&&"get"in a&&void 0!==(i=a.get(e,!1,r))?i:l[t];"string"==(o=typeof n)&&(i=ie.exec(n))&&i[1]&&(n=ue(e,t,i),o="number"),null!=n&&n===n&&("number"===o&&(n+=i&&i[3]||(w.cssNumber[s]?"":"px")),h.clearCloneStyle||""!==n||0!==t.indexOf("background")||(l[t]="inherit"),a&&"set"in a&&void 0===(n=a.set(e,n,r))||(u?l.setProperty(t,n):l[t]=n))}},css:function(e,t,n,r){var i,o,a,s=G(t);return Xe.test(t)||(t=Je(s)),(a=w.cssHooks[t]||w.cssHooks[s])&&"get"in a&&(i=a.get(e,!0,n)),void 0===i&&(i=Fe(e,t,r)),"normal"===i&&t in Ve&&(i=Ve[t]),""===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),w.each(["height","width"],function(e,t){w.cssHooks[t]={get:function(e,n,r){if(n)return!ze.test(w.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?et(e,t,r):se(e,Ue,function(){return et(e,t,r)})},set:function(e,n,r){var i,o=$e(e),a="border-box"===w.css(e,"boxSizing",!1,o),s=r&&Ze(e,t,r,a,o);return a&&h.scrollboxSize()===o.position&&(s-=Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-parseFloat(o[t])-Ze(e,t,"border",!1,o)-.5)),s&&(i=ie.exec(n))&&"px"!==(i[3]||"px")&&(e.style[t]=n,n=w.css(e,t)),Ke(e,n,s)}}}),w.cssHooks.marginLeft=_e(h.reliableMarginLeft,function(e,t){if(t)return(parseFloat(Fe(e,"marginLeft"))||e.getBoundingClientRect().left-se(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),w.each({margin:"",padding:"",border:"Width"},function(e,t){w.cssHooks[e+t]={expand:function(n){for(var r=0,i={},o="string"==typeof n?n.split(" "):[n];r<4;r++)i[e+oe[r]+t]=o[r]||o[r-2]||o[0];return i}},"margin"!==e&&(w.cssHooks[e+t].set=Ke)}),w.fn.extend({css:function(e,t){return z(this,function(e,t,n){var r,i,o={},a=0;if(Array.isArray(t)){for(r=$e(e),i=t.length;a1)}});function tt(e,t,n,r,i){return new tt.prototype.init(e,t,n,r,i)}w.Tween=tt,tt.prototype={constructor:tt,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||w.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(w.cssNumber[n]?"":"px")},cur:function(){var e=tt.propHooks[this.prop];return e&&e.get?e.get(this):tt.propHooks._default.get(this)},run:function(e){var t,n=tt.propHooks[this.prop];return this.options.duration?this.pos=t=w.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):tt.propHooks._default.set(this),this}},tt.prototype.init.prototype=tt.prototype,tt.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=w.css(e.elem,e.prop,""))&&"auto"!==t?t:0},set:function(e){w.fx.step[e.prop]?w.fx.step[e.prop](e):1!==e.elem.nodeType||null==e.elem.style[w.cssProps[e.prop]]&&!w.cssHooks[e.prop]?e.elem[e.prop]=e.now:w.style(e.elem,e.prop,e.now+e.unit)}}},tt.propHooks.scrollTop=tt.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},w.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},w.fx=tt.prototype.init,w.fx.step={};var nt,rt,it=/^(?:toggle|show|hide)$/,ot=/queueHooks$/;function at(){rt&&(!1===r.hidden&&e.requestAnimationFrame?e.requestAnimationFrame(at):e.setTimeout(at,w.fx.interval),w.fx.tick())}function st(){return e.setTimeout(function(){nt=void 0}),nt=Date.now()}function ut(e,t){var n,r=0,i={height:e};for(t=t?1:0;r<4;r+=2-t)i["margin"+(n=oe[r])]=i["padding"+n]=e;return t&&(i.opacity=i.width=e),i}function lt(e,t,n){for(var r,i=(pt.tweeners[t]||[]).concat(pt.tweeners["*"]),o=0,a=i.length;o1)},removeAttr:function(e){return this.each(function(){w.removeAttr(this,e)})}}),w.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return"undefined"==typeof e.getAttribute?w.prop(e,t,n):(1===o&&w.isXMLDoc(e)||(i=w.attrHooks[t.toLowerCase()]||(w.expr.match.bool.test(t)?dt:void 0)),void 0!==n?null===n?void w.removeAttr(e,t):i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n+""),n):i&&"get"in i&&null!==(r=i.get(e,t))?r:null==(r=w.find.attr(e,t))?void 0:r)},attrHooks:{type:{set:function(e,t){if(!h.radioValue&&"radio"===t&&N(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,r=0,i=t&&t.match(M);if(i&&1===e.nodeType)while(n=i[r++])e.removeAttribute(n)}}),dt={set:function(e,t,n){return!1===t?w.removeAttr(e,n):e.setAttribute(n,n),n}},w.each(w.expr.match.bool.source.match(/\w+/g),function(e,t){var n=ht[t]||w.find.attr;ht[t]=function(e,t,r){var i,o,a=t.toLowerCase();return r||(o=ht[a],ht[a]=i,i=null!=n(e,t,r)?a:null,ht[a]=o),i}});var gt=/^(?:input|select|textarea|button)$/i,yt=/^(?:a|area)$/i;w.fn.extend({prop:function(e,t){return z(this,w.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[w.propFix[e]||e]})}}),w.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&w.isXMLDoc(e)||(t=w.propFix[t]||t,i=w.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=w.find.attr(e,"tabindex");return t?parseInt(t,10):gt.test(e.nodeName)||yt.test(e.nodeName)&&e.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),h.optSelected||(w.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),w.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){w.propFix[this.toLowerCase()]=this});function vt(e){return(e.match(M)||[]).join(" ")}function mt(e){return e.getAttribute&&e.getAttribute("class")||""}function xt(e){return Array.isArray(e)?e:"string"==typeof e?e.match(M)||[]:[]}w.fn.extend({addClass:function(e){var t,n,r,i,o,a,s,u=0;if(g(e))return this.each(function(t){w(this).addClass(e.call(this,t,mt(this)))});if((t=xt(e)).length)while(n=this[u++])if(i=mt(n),r=1===n.nodeType&&" "+vt(i)+" "){a=0;while(o=t[a++])r.indexOf(" "+o+" ")<0&&(r+=o+" ");i!==(s=vt(r))&&n.setAttribute("class",s)}return this},removeClass:function(e){var t,n,r,i,o,a,s,u=0;if(g(e))return this.each(function(t){w(this).removeClass(e.call(this,t,mt(this)))});if(!arguments.length)return this.attr("class","");if((t=xt(e)).length)while(n=this[u++])if(i=mt(n),r=1===n.nodeType&&" "+vt(i)+" "){a=0;while(o=t[a++])while(r.indexOf(" "+o+" ")>-1)r=r.replace(" "+o+" "," ");i!==(s=vt(r))&&n.setAttribute("class",s)}return this},toggleClass:function(e,t){var n=typeof e,r="string"===n||Array.isArray(e);return"boolean"==typeof t&&r?t?this.addClass(e):this.removeClass(e):g(e)?this.each(function(n){w(this).toggleClass(e.call(this,n,mt(this),t),t)}):this.each(function(){var t,i,o,a;if(r){i=0,o=w(this),a=xt(e);while(t=a[i++])o.hasClass(t)?o.removeClass(t):o.addClass(t)}else void 0!==e&&"boolean"!==n||((t=mt(this))&&J.set(this,"__className__",t),this.setAttribute&&this.setAttribute("class",t||!1===e?"":J.get(this,"__className__")||""))})},hasClass:function(e){var t,n,r=0;t=" "+e+" ";while(n=this[r++])if(1===n.nodeType&&(" "+vt(mt(n))+" ").indexOf(t)>-1)return!0;return!1}});var bt=/\r/g;w.fn.extend({val:function(e){var t,n,r,i=this[0];{if(arguments.length)return r=g(e),this.each(function(n){var i;1===this.nodeType&&(null==(i=r?e.call(this,n,w(this).val()):e)?i="":"number"==typeof i?i+="":Array.isArray(i)&&(i=w.map(i,function(e){return null==e?"":e+""})),(t=w.valHooks[this.type]||w.valHooks[this.nodeName.toLowerCase()])&&"set"in t&&void 0!==t.set(this,i,"value")||(this.value=i))});if(i)return(t=w.valHooks[i.type]||w.valHooks[i.nodeName.toLowerCase()])&&"get"in t&&void 0!==(n=t.get(i,"value"))?n:"string"==typeof(n=i.value)?n.replace(bt,""):null==n?"":n}}}),w.extend({valHooks:{option:{get:function(e){var t=w.find.attr(e,"value");return null!=t?t:vt(w.text(e))}},select:{get:function(e){var t,n,r,i=e.options,o=e.selectedIndex,a="select-one"===e.type,s=a?null:[],u=a?o+1:i.length;for(r=o<0?u:a?o:0;r-1)&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),w.each(["radio","checkbox"],function(){w.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=w.inArray(w(e).val(),t)>-1}},h.checkOn||(w.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})}),h.focusin="onfocusin"in e;var wt=/^(?:focusinfocus|focusoutblur)$/,Tt=function(e){e.stopPropagation()};w.extend(w.event,{trigger:function(t,n,i,o){var a,s,u,l,c,p,d,h,v=[i||r],m=f.call(t,"type")?t.type:t,x=f.call(t,"namespace")?t.namespace.split("."):[];if(s=h=u=i=i||r,3!==i.nodeType&&8!==i.nodeType&&!wt.test(m+w.event.triggered)&&(m.indexOf(".")>-1&&(m=(x=m.split(".")).shift(),x.sort()),c=m.indexOf(":")<0&&"on"+m,t=t[w.expando]?t:new w.Event(m,"object"==typeof t&&t),t.isTrigger=o?2:3,t.namespace=x.join("."),t.rnamespace=t.namespace?new RegExp("(^|\\.)"+x.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=void 0,t.target||(t.target=i),n=null==n?[t]:w.makeArray(n,[t]),d=w.event.special[m]||{},o||!d.trigger||!1!==d.trigger.apply(i,n))){if(!o&&!d.noBubble&&!y(i)){for(l=d.delegateType||m,wt.test(l+m)||(s=s.parentNode);s;s=s.parentNode)v.push(s),u=s;u===(i.ownerDocument||r)&&v.push(u.defaultView||u.parentWindow||e)}a=0;while((s=v[a++])&&!t.isPropagationStopped())h=s,t.type=a>1?l:d.bindType||m,(p=(J.get(s,"events")||{})[t.type]&&J.get(s,"handle"))&&p.apply(s,n),(p=c&&s[c])&&p.apply&&Y(s)&&(t.result=p.apply(s,n),!1===t.result&&t.preventDefault());return t.type=m,o||t.isDefaultPrevented()||d._default&&!1!==d._default.apply(v.pop(),n)||!Y(i)||c&&g(i[m])&&!y(i)&&((u=i[c])&&(i[c]=null),w.event.triggered=m,t.isPropagationStopped()&&h.addEventListener(m,Tt),i[m](),t.isPropagationStopped()&&h.removeEventListener(m,Tt),w.event.triggered=void 0,u&&(i[c]=u)),t.result}},simulate:function(e,t,n){var r=w.extend(new w.Event,n,{type:e,isSimulated:!0});w.event.trigger(r,null,t)}}),w.fn.extend({trigger:function(e,t){return this.each(function(){w.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return w.event.trigger(e,t,n,!0)}}),h.focusin||w.each({focus:"focusin",blur:"focusout"},function(e,t){var n=function(e){w.event.simulate(t,e.target,w.event.fix(e))};w.event.special[t]={setup:function(){var r=this.ownerDocument||this,i=J.access(r,t);i||r.addEventListener(e,n,!0),J.access(r,t,(i||0)+1)},teardown:function(){var r=this.ownerDocument||this,i=J.access(r,t)-1;i?J.access(r,t,i):(r.removeEventListener(e,n,!0),J.remove(r,t))}}});var Ct=e.location,Et=Date.now(),kt=/\?/;w.parseXML=function(t){var n;if(!t||"string"!=typeof t)return null;try{n=(new e.DOMParser).parseFromString(t,"text/xml")}catch(e){n=void 0}return n&&!n.getElementsByTagName("parsererror").length||w.error("Invalid XML: "+t),n};var St=/\[\]$/,Dt=/\r?\n/g,Nt=/^(?:submit|button|image|reset|file)$/i,At=/^(?:input|select|textarea|keygen)/i;function jt(e,t,n,r){var i;if(Array.isArray(t))w.each(t,function(t,i){n||St.test(e)?r(e,i):jt(e+"["+("object"==typeof i&&null!=i?t:"")+"]",i,n,r)});else if(n||"object"!==x(t))r(e,t);else for(i in t)jt(e+"["+i+"]",t[i],n,r)}w.param=function(e,t){var n,r=[],i=function(e,t){var n=g(t)?t():t;r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(Array.isArray(e)||e.jquery&&!w.isPlainObject(e))w.each(e,function(){i(this.name,this.value)});else for(n in e)jt(n,e[n],t,i);return r.join("&")},w.fn.extend({serialize:function(){return w.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=w.prop(this,"elements");return e?w.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!w(this).is(":disabled")&&At.test(this.nodeName)&&!Nt.test(e)&&(this.checked||!pe.test(e))}).map(function(e,t){var n=w(this).val();return null==n?null:Array.isArray(n)?w.map(n,function(e){return{name:t.name,value:e.replace(Dt,"\r\n")}}):{name:t.name,value:n.replace(Dt,"\r\n")}}).get()}});var qt=/%20/g,Lt=/#.*$/,Ht=/([?&])_=[^&]*/,Ot=/^(.*?):[ \t]*([^\r\n]*)$/gm,Pt=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Mt=/^(?:GET|HEAD)$/,Rt=/^\/\//,It={},Wt={},$t="*/".concat("*"),Bt=r.createElement("a");Bt.href=Ct.href;function Ft(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(M)||[];if(g(n))while(r=o[i++])"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function _t(e,t,n,r){var i={},o=e===Wt;function a(s){var u;return i[s]=!0,w.each(e[s]||[],function(e,s){var l=s(t,n,r);return"string"!=typeof l||o||i[l]?o?!(u=l):void 0:(t.dataTypes.unshift(l),a(l),!1)}),u}return a(t.dataTypes[0])||!i["*"]&&a("*")}function zt(e,t){var n,r,i=w.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&w.extend(!0,e,r),e}function Xt(e,t,n){var r,i,o,a,s=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),void 0===r&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r)for(i in s)if(s[i]&&s[i].test(r)){u.unshift(i);break}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+" "+u[0]]){o=i;break}a||(a=i)}o=o||a}if(o)return o!==u[0]&&u.unshift(o),n[o]}function Ut(e,t,n,r){var i,o,a,s,u,l={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)l[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift())if("*"===o)o=u;else if("*"!==u&&u!==o){if(!(a=l[u+" "+o]||l["* "+o]))for(i in l)if((s=i.split(" "))[1]===o&&(a=l[u+" "+s[0]]||l["* "+s[0]])){!0===a?a=l[i]:!0!==l[i]&&(o=s[0],c.unshift(s[1]));break}if(!0!==a)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(e){return{state:"parsererror",error:a?e:"No conversion from "+u+" to "+o}}}return{state:"success",data:t}}w.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Ct.href,type:"GET",isLocal:Pt.test(Ct.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":$t,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":w.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?zt(zt(e,w.ajaxSettings),t):zt(w.ajaxSettings,e)},ajaxPrefilter:Ft(It),ajaxTransport:Ft(Wt),ajax:function(t,n){"object"==typeof t&&(n=t,t=void 0),n=n||{};var i,o,a,s,u,l,c,f,p,d,h=w.ajaxSetup({},n),g=h.context||h,y=h.context&&(g.nodeType||g.jquery)?w(g):w.event,v=w.Deferred(),m=w.Callbacks("once memory"),x=h.statusCode||{},b={},T={},C="canceled",E={readyState:0,getResponseHeader:function(e){var t;if(c){if(!s){s={};while(t=Ot.exec(a))s[t[1].toLowerCase()]=t[2]}t=s[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return c?a:null},setRequestHeader:function(e,t){return null==c&&(e=T[e.toLowerCase()]=T[e.toLowerCase()]||e,b[e]=t),this},overrideMimeType:function(e){return null==c&&(h.mimeType=e),this},statusCode:function(e){var t;if(e)if(c)E.always(e[E.status]);else for(t in e)x[t]=[x[t],e[t]];return this},abort:function(e){var t=e||C;return i&&i.abort(t),k(0,t),this}};if(v.promise(E),h.url=((t||h.url||Ct.href)+"").replace(Rt,Ct.protocol+"//"),h.type=n.method||n.type||h.method||h.type,h.dataTypes=(h.dataType||"*").toLowerCase().match(M)||[""],null==h.crossDomain){l=r.createElement("a");try{l.href=h.url,l.href=l.href,h.crossDomain=Bt.protocol+"//"+Bt.host!=l.protocol+"//"+l.host}catch(e){h.crossDomain=!0}}if(h.data&&h.processData&&"string"!=typeof h.data&&(h.data=w.param(h.data,h.traditional)),_t(It,h,n,E),c)return E;(f=w.event&&h.global)&&0==w.active++&&w.event.trigger("ajaxStart"),h.type=h.type.toUpperCase(),h.hasContent=!Mt.test(h.type),o=h.url.replace(Lt,""),h.hasContent?h.data&&h.processData&&0===(h.contentType||"").indexOf("application/x-www-form-urlencoded")&&(h.data=h.data.replace(qt,"+")):(d=h.url.slice(o.length),h.data&&(h.processData||"string"==typeof h.data)&&(o+=(kt.test(o)?"&":"?")+h.data,delete h.data),!1===h.cache&&(o=o.replace(Ht,"$1"),d=(kt.test(o)?"&":"?")+"_="+Et+++d),h.url=o+d),h.ifModified&&(w.lastModified[o]&&E.setRequestHeader("If-Modified-Since",w.lastModified[o]),w.etag[o]&&E.setRequestHeader("If-None-Match",w.etag[o])),(h.data&&h.hasContent&&!1!==h.contentType||n.contentType)&&E.setRequestHeader("Content-Type",h.contentType),E.setRequestHeader("Accept",h.dataTypes[0]&&h.accepts[h.dataTypes[0]]?h.accepts[h.dataTypes[0]]+("*"!==h.dataTypes[0]?", "+$t+"; q=0.01":""):h.accepts["*"]);for(p in h.headers)E.setRequestHeader(p,h.headers[p]);if(h.beforeSend&&(!1===h.beforeSend.call(g,E,h)||c))return E.abort();if(C="abort",m.add(h.complete),E.done(h.success),E.fail(h.error),i=_t(Wt,h,n,E)){if(E.readyState=1,f&&y.trigger("ajaxSend",[E,h]),c)return E;h.async&&h.timeout>0&&(u=e.setTimeout(function(){E.abort("timeout")},h.timeout));try{c=!1,i.send(b,k)}catch(e){if(c)throw e;k(-1,e)}}else k(-1,"No Transport");function k(t,n,r,s){var l,p,d,b,T,C=n;c||(c=!0,u&&e.clearTimeout(u),i=void 0,a=s||"",E.readyState=t>0?4:0,l=t>=200&&t<300||304===t,r&&(b=Xt(h,E,r)),b=Ut(h,b,E,l),l?(h.ifModified&&((T=E.getResponseHeader("Last-Modified"))&&(w.lastModified[o]=T),(T=E.getResponseHeader("etag"))&&(w.etag[o]=T)),204===t||"HEAD"===h.type?C="nocontent":304===t?C="notmodified":(C=b.state,p=b.data,l=!(d=b.error))):(d=C,!t&&C||(C="error",t<0&&(t=0))),E.status=t,E.statusText=(n||C)+"",l?v.resolveWith(g,[p,C,E]):v.rejectWith(g,[E,C,d]),E.statusCode(x),x=void 0,f&&y.trigger(l?"ajaxSuccess":"ajaxError",[E,h,l?p:d]),m.fireWith(g,[E,C]),f&&(y.trigger("ajaxComplete",[E,h]),--w.active||w.event.trigger("ajaxStop")))}return E},getJSON:function(e,t,n){return w.get(e,t,n,"json")},getScript:function(e,t){return w.get(e,void 0,t,"script")}}),w.each(["get","post"],function(e,t){w[t]=function(e,n,r,i){return g(n)&&(i=i||r,r=n,n=void 0),w.ajax(w.extend({url:e,type:t,dataType:i,data:n,success:r},w.isPlainObject(e)&&e))}}),w._evalUrl=function(e){return w.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,"throws":!0})},w.fn.extend({wrapAll:function(e){var t;return this[0]&&(g(e)&&(e=e.call(this[0])),t=w(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstElementChild)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(e){return g(e)?this.each(function(t){w(this).wrapInner(e.call(this,t))}):this.each(function(){var t=w(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=g(e);return this.each(function(n){w(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){w(this).replaceWith(this.childNodes)}),this}}),w.expr.pseudos.hidden=function(e){return!w.expr.pseudos.visible(e)},w.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},w.ajaxSettings.xhr=function(){try{return new e.XMLHttpRequest}catch(e){}};var Vt={0:200,1223:204},Gt=w.ajaxSettings.xhr();h.cors=!!Gt&&"withCredentials"in Gt,h.ajax=Gt=!!Gt,w.ajaxTransport(function(t){var n,r;if(h.cors||Gt&&!t.crossDomain)return{send:function(i,o){var a,s=t.xhr();if(s.open(t.type,t.url,t.async,t.username,t.password),t.xhrFields)for(a in t.xhrFields)s[a]=t.xhrFields[a];t.mimeType&&s.overrideMimeType&&s.overrideMimeType(t.mimeType),t.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");for(a in i)s.setRequestHeader(a,i[a]);n=function(e){return function(){n&&(n=r=s.onload=s.onerror=s.onabort=s.ontimeout=s.onreadystatechange=null,"abort"===e?s.abort():"error"===e?"number"!=typeof s.status?o(0,"error"):o(s.status,s.statusText):o(Vt[s.status]||s.status,s.statusText,"text"!==(s.responseType||"text")||"string"!=typeof s.responseText?{binary:s.response}:{text:s.responseText},s.getAllResponseHeaders()))}},s.onload=n(),r=s.onerror=s.ontimeout=n("error"),void 0!==s.onabort?s.onabort=r:s.onreadystatechange=function(){4===s.readyState&&e.setTimeout(function(){n&&r()})},n=n("abort");try{s.send(t.hasContent&&t.data||null)}catch(e){if(n)throw e}},abort:function(){n&&n()}}}),w.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),w.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return w.globalEval(e),e}}}),w.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),w.ajaxTransport("script",function(e){if(e.crossDomain){var t,n;return{send:function(i,o){t=w("\n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"A behavior is the action to do when a method or an event is called."},"help-components.html":{"_id":"help-components.html","source":"Components are your classes instances. Their states are saved in a store, a JSON object."},"help-logs.html":{"_id":"help-logs.html","source":"You will find here the logs of the running system.

Example of code to send a log:

this
.require('logger')
.info('hello world');
"},"help-models.html":{"_id":"help-models.html","source":"A model is an UML representation of your classes. It is generated from a schema."},"help-schemas.html":{"_id":"help-schemas.html","source":"A schema is the definition of your model. Models are generated based on the schema definition."},"help-system.html":{"_id":"help-system.html","source":"An application is a system. Once you have created one, your next step is to create a schema."},"help-types.html":{"_id":"help-types.html","source":"A type is used in your model to define an enumeration or a structure."},"menu-action-search.html":{"_id":"menu-action-search.html","source":"
\n
\n \n
\n
"},"menu-header.html":{"_id":"menu-header.html","source":"
"},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-guide.html":{"_id":"menu-item-guide.html","source":"Guide"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs0"},"menu-item-message-save.html":{"_id":"menu-item-message-save.html","source":" file saved!"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-quick-start.html":{"_id":"menu-item-quick-start.html","source":"Quick Start"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
{{message}}
"},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
{{message}}
"},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
{{message}}
"},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
{{message}}
"},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
\n
\n
\n
\n

{{title}}

\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n \n
\n
\n
\n {{uninstalled_extensions}}\n
\n
\n
\n
\n
\n \n
\n
\n
\n {{systems}}\n
\n
\n
\n
\n
\n \n
\n
\n
\n {{extensions}}\n
\n
\n
\n
\n
\n
\n
\n \n \n \n
\n
\n
\n
"},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
\n
\n
\n
\n
\n
\n
\n
\n Open\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
"},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
\n
\n
\n
\n

{{title}}

\n
\n
\n {{message}}\n
\n
\n \n \n
\n
\n
\n
"},"message-help.html":{"_id":"message-help.html","source":"
\n
\n {{message}} \n
\n
"},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"},"toolbar-item-diagram.html":{"_id":"toolbar-item-diagram.html","source":""},"menu-item-diagram.html":{"_id":"menu-item-diagram.html","source":"Class diagram"},"toolbar-item-zoomout.html":{"_id":"toolbar-item-zoomout.html","source":""},"toolbar-item-zoomin.html":{"_id":"toolbar-item-zoomin.html","source":""},"toolbar-item-zoominit.html":{"_id":"toolbar-item-zoominit.html","source":""},"toolbar-item-export-diagram.html":{"_id":"toolbar-item-export-diagram.html","source":""}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.0.0","description":"Quick start\n\nThis system is taken from the quick start: https://system-designer.readme.io/docs/quick-start","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n var luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n var result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vador":{"_id":"vador","father":"","firstName":"Dark","lastName":"Vador"},"luke":{"_id":"luke","father":"vador","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"04-send-messages.json":{"_id":"04-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.0.0","description":"Send messages threw a channel\n\n\nYou can send messages from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. In '_Channel' 'send' method, define how to send the message to another channel (webRTC, XHR, ...).\n3. In another system, define how to get the message and send it to the system with: runtime.message().\n4. To send a message: this.require('channel').myevent(param1, param2, ...).\n5. To listen to the message, just add a behavior to the event.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.0.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"type":"css","readOnly":false,"mandatory":false,"default":""},"render":{}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{},"filter":{"type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n var html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n var div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n var items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n var author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
\n \n
\n\n
"}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.0.1","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n var http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"04-create-extension.json":{"_id":"04-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.1.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
\n
\n
\n
\n

{{title}}

\n
\n
\n {{message}}\n
\n
\n \n \n
\n
\n
\n
"}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"05-listen-collection-events.json":{"_id":"05-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.0.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""},"field":{"type":"string","mandatory":true,"default":""},"value":{"type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"document":{"type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179bg":{"_id":"1f8571164c179bg","html":"menu-action-version.html","position":10,"type":"diagram"}},"MenuHeader":{"1fb101b99813a15":{"_id":"1fb101b99813a15","html":"menu-header-schema.html","type":"diagram"}},"MenuItem":{"1f1781882618106":{"_id":"1f1781882618106","name":"diagram","html":"menu-item-diagram.html","position":10,"type":"diagram","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"a1e94f187c412b2a":{"_id":"a1e94f187c412b2a","html":"toolbar-item-copyright.html","position":90,"type":"diagram","platform":"all"},"q189c51d320139d0":{"_id":"q189c51d320139d0","html":"toolbar-item-help.html","platform":"all","position":80,"type":"diagram"},"p15e7513ed512f61":{"_id":"p15e7513ed512f61","html":"toolbar-item-zoomout.html","platform":"all","position":20,"type":"diagram"},"q1da4e1ca6710ca2":{"_id":"q1da4e1ca6710ca2","html":"toolbar-item-zoomin.html","platform":"all","position":30,"type":"diagram"},"c1b63f13c911fcc8":{"_id":"c1b63f13c911fcc8","html":"toolbar-item-zoominit.html","platform":"all","position":10,"type":"diagram"},"q16e321bb2c15a27":{"_id":"q16e321bb2c15a27","html":"toolbar-item-export-diagram.html","platform":"all","position":40,"type":"diagram"}}},"_id":"a1c33618ac01371c"}); \ No newline at end of file diff --git a/designer/scripts/editor-behavior.js b/designer/scripts/editor-behavior.js index 5526b05..366a813 100644 --- a/designer/scripts/editor-behavior.js +++ b/designer/scripts/editor-behavior.js @@ -1,3 +1,3 @@ // System Designer - Copyright 2018 Erwan Carriou // Licensed under the Apache License, Version 2.0 (the "License") -runtime.install({"name":"editor-behavior","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"],"refresh":"method"},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"2.8.3"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"addShortcuts":{"result":"any"}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}]}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":false}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57"},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null;\n \n if (extension.installed) { \n system = extension.source;\n \n try {\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n } catch (e) {\n this.require('message').danger('Can not install an extension.');\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n\n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

' +\n '

v' + library.source().version + '

' +\n '
';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

' + system.name + '

' +\n '

v' + system.version + '

' +\n '
';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').hide();\n }\n } else {\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').show();\n }\n }\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-file').attr('checked', false);\n $('#designer-dialog-import-modal-from-library').attr('checked', true);\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n that.data(JSON.parse(json));\n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

' +\n '

v' + extension.source().version + '

' +\n '
';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

No extension found

';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

' +\n '

v' + extension.source().version + '

' +\n '
';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

No extension found

';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

' +\n '

v' + system.version + '

' +\n '
';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

No extension found

';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').uninstall('ext_' + system._id)\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '
');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

Schema ' + schemas[id]._name + ' ' + numberResult.html + '

' +\n '

...' + showResult(toSearch, index, value) + '...

' +\n '
';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

Model ' + models[id]._name + ' ' + numberResult.html + '

' +\n '

...' + showResult(toSearch, index, value) + '...

' +\n '
';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

Type ' + types[id].name + ' ' + numberResult.html + '

' +\n '

...' + showResult(toSearch, index, value) + '...

' +\n '
';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

';\n } else { \n link = link + '

Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

';\n }\n \n link = link + '

...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

' +\n '
';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

Component ' + components[collection][id]._id + ' ' + numberResult.html + '

' +\n '

...' + showResult(toSearch, index, value) + '...

' +\n '
';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

There is no result for your search

'\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

Schema ' + schemas[id]._name + '

' +\n '
';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

Model ' + models[id]._name + '

' +\n '
';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

Type ' + types[id].name + '

' +\n '
';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

Behavior ' + systemName + '.' + behaviors[id].state + '

';\n } else { \n link = link + '

Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

';\n }\n '
';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

Component ' + components[collection][id]._id + '

' +\n '
';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

There is no result

');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n downloadLink.click();\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n if (system.name === name) {\n result = false;\n break;\n }\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n \n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"snippet\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'snippet' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'snippet' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'snippet' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'snippet' });\n }\n \n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n \n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n \n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n \n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n \n // snippets\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet:'{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'snippet' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n \n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"snippet\" });\n }\n \n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n \n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n \n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n \n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n \n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n\n repo1.writeFile('master', system.name + '.json', JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html', htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js', jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^2.8.4';\n\n repo4.writeFile('master', 'package.json', JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.source());\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n \n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n });\n\n menuActions.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('afterbegin', '
  • ' + action.html().source() + '');\n });\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n this.require('state').messages(messages);\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n for (propName in this.document().schema) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n }\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n\n systemId = this.require('factory').system().id();\n schema = _getSchema(this.model());\n model = _getModel(this.model());\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = this.document()[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n if (modelName === '_Component') {\n modelName = _getModelFromComponent(propVal);\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n function gen() {\n return Math.floor((1 + Math.random()) * 0x10000).toString(16);\n }\n function getPrefix() {\n var validPrefix = 'abcdefghijklmnopqrstuvwxyz';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return getPrefix() + gen() + gen() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n\n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n \n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system !== 'undefined':\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && typeof system !== 'undefined':\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && typeof system !== 'undefined':\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && typeof system !== 'undefined' && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n default:\n break;\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin', \n template.source().replace(/{{message}}/gi, message));\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom) {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (typeof system === 'undefined') {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"u165f215d0217974":{"_id":"u165f215d0217974","component":"1dbc513e0e11z15","state":"click","action":"function click() { \n $('#designer-toolbar-item-copy').tooltip('hide');\n this.require('editor').copy(); \n}"},"f1846f199e41074c":{"_id":"f1846f199e41074c","component":"1dbc513e0e11z16","state":"click","action":"function click() { \n $('#designer-toolbar-item-paste').tooltip('hide');\n this.require('editor').paste(); \n}"},"m191d0168cd1e718":{"_id":"m191d0168cd1e718","component":"1dbc513e0e11z19","state":"click","action":"function click() { \n $('#designer-toolbar-item-select-all').tooltip('hide');\n this.require('editor').selectAll(); \n}"},"q13ca018ddf1b2cb":{"_id":"q13ca018ddf1b2cb","component":"1dbc513e0e11z18","state":"click","action":"function click() { \n $('#designer-toolbar-item-redo').tooltip('hide');\n this.require('editor').redo(); \n}"},"i17f271591b13ab8":{"_id":"i17f271591b13ab8","component":"1dbc513e0e11z17","state":"click","action":"function click() { \n $('#designer-toolbar-item-undo').tooltip('hide');\n this.require('editor').undo(); \n}"},"z151551d71511af6":{"_id":"z151551d71511af6","component":"1dbc51200e11616","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n this.require('designer').open('https://system-designer.readme.io/docs/create-a-behavior', '_blank', true); \n}"},"r1c1e3143bb14fea":{"_id":"r1c1e3143bb14fea","component":"1dbc51200e11612","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"g10e66157581049b":{"_id":"g10e66157581049b","component":"1dbc51200e11611","state":"click","action":"function click() {\n $('#designer-toolbar-item-save').tooltip('hide');\n this.require('designer').save(); \n}"},"r1e032137771c493":{"_id":"r1e032137771c493","component":"MenuItem","state":"click","action":"function click() { \n this.require('state').menu(this.name());\n}","useCoreAPI":false,"core":false},"w1d94e18b9f10fe3":{"_id":"w1d94e18b9f10fe3","component":"Workspace","state":"render","action":"function render() { \n var Editor = null,\n designer = null,\n editor = null;\n\n Editor = this.require('Editor');\n designer = this.require('designer');\n\n if (designer.isCordova()) {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'codemirror',\n 'context': 'behavior',\n 'editor': CodeMirror($('#designer-editor')[0], {\n lineNumbers: true,\n styleActiveLine: true,\n 'mode': 'text/javascript',\n 'theme': 'eclipse',\n 'tabSize': 2,\n 'autoCloseBrackets': true\n })\n });\n } else {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'ace',\n 'context': 'behavior',\n 'editor': ace.edit('designer-editor')\n });\n }\n \n editor.render();\n}","useCoreAPI":false,"core":false},"o1b89518d6212c82":{"_id":"o1b89518d6212c82","component":"1f1781882618110","state":"click","action":"function click() { \n var editor = this.require('editor');\n\n try {\n this.require('store').data(JSON.parse(editor.getValue()));\n } catch (e) {\n }\n\n editor.setEditor('javascript',this.require('store').data().action, 2);\n}","useCoreAPI":false,"core":false},"a16d1816a121a0ca":{"_id":"a16d1816a121a0ca","component":"1f1781882618111","state":"click","action":"function click() { \n var editor = this.require('editor');\n\n if (editor.getValue().indexOf('{') !== 0) {\n this.require('store').data().action = editor.getValue();\n }\n\n editor.setEditor('json', JSON.stringify(this.require('store').data(), null, '\\t'), 2);\n}","useCoreAPI":false,"core":false},"r1841b145401b120":{"_id":"r1841b145401b120","component":"Designer","state":"render","action":"function render() {\n var systemId = '',\n system = null,\n sys = null,\n id = '',\n behavior = null;\n\n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1]);\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n\n // set system\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n \n system = this.require('storage').get(systemId);\n \n sys = this.require('factory').create(system);\n \n // extensions\n this.installExtensions();\n\n // render\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('workspace').render();\n\n // set store\n behavior = this.require('storage').get(systemId).behaviors[id];\n\n this.require('store').uuid(id);\n this.require('store').data(behavior);\n\n if (behavior.state === 'start' && systemId === behavior.component) {\n document.title = 'behavior ' + this.require('factory').system().name() + '.' + behavior.state + ' · system ' + this.require('storage').get(systemId).name;\n } else {\n document.title = 'behavior ' + behavior.component + '.' + behavior.state + ' · system ' + this.require('storage').get(systemId).name;\n }\n\n this.require('editor').initValue(behavior.action, 2);\n \n this.require('router').update();\n \n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"t103d416bd313444":{"_id":"t103d416bd313444","component":"Designer","state":"save","action":"function save() { \n var val = this.require('editor').getValue(),\n designer = this.require('designer'),\n store = this.require('store').data();\n\n if (this.require('state').menu() === 'action') {\n store.action = val;\n } else {\n store = JSON.parse(val);\n }\n this.require('store').data(store);\n\n // check if ID change\n if (this.require('store').uuid() !== this.require('store').data()._id) {\n this.require('channel').$editorDeleteBehavior(this.require('store').uuid());\n this.require('store').uuid(this.require('store').data()._id);\n }\n\n if (store.state === 'start' && this.require('factory').system().id() === store.component) {\n document.title = 'behavior ' + this.require('factory').system().name() + ' · ' + document.title.split('·')[1].trim();\n } else {\n document.title = 'behavior ' + this.require('store').data().component + '.' + this.require('store').data().state + ' · ' + document.title.split('·')[1].trim();\n }\n\n this.require('channel').$editorUpdateBehavior(this.require('store').uuid(), this.require('store').data());\n this.require('message').clean();\n this.require('message').success('Behavior saved.');\n}","useCoreAPI":false,"core":false},"l16eb31f3a515bb9":{"_id":"l16eb31f3a515bb9","component":"c1444b19a0c1ec4d","state":"start","action":"function start() { \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"k1fa3c1a56a14081":{"_id":"k1fa3c1a56a14081","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n systemId = '',\n href = '';\n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1];\n menubar[i].href = '#' + id + '#' + systemId + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"i1227d101301030a":{"_id":"i1227d101301030a","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state');\n \n if (designer.isCordova()) {\n state.messages().push(message);\n }\n\n this.require('storage').set('system-designer-message', message);\n\n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\t\n}","useCoreAPI":false,"core":false},"d17bbd1a0311a1d7":{"_id":"d17bbd1a0311a1d7","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function changed(obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":false,"core":false},"j1ee401128b14b0a":{"_id":"j1ee401128b14b0a","component":"r11f4117b5111373","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');;\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"a154a417ccd16a26":{"_id":"a154a417ccd16a26","component":"u11695143131df2f","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"n199441b9c91e324":{"_id":"n199441b9c91e324","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar result = {};\n\treturn result;\n}","useCoreAPI":false,"core":false},"x18e941f8721d9b3":{"_id":"x18e941f8721d9b3","component":"Designer","state":"addShortcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"2.8.3"}},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.1.1","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1d113198721599d":{"_id":"l1d113198721599d","_name":"MenuItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"u1f9a01abe31b3bf":{"_id":"u1f9a01abe31b3bf","_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"menuitem-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"name":{"type":"string","readOnly":false,"mandatory":false,"default":"template"},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"},"render":{},"click":{}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() { \n\tvar name = $('#modal-modeljson-name').val(),\n\t jsonText = $('#modal-modeljson-json').val(),\n\t json = null,\n\t schema = {},\n\t model = {},\n\t property = '',\n\t type = '',\n\t typeName = '',\n\t arrayType = '',\n\t that = this,\n\t createdTypes = [];\n\t \n\tfunction _getTypeName(parent, name) {\n\t var result = name;\n\t \n\t if (!_validType(name)) {\n\t if (parent) {\n\t result = parent + '_' + name;\n\t } else {\n\t result = name + Math.floor(Math.random() * 11);\n\t }\n\t }\n\t \n\t return result;\n\t} \n\n function _getType(value) {\n var type = '';\n \n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n \n return type;\n } \n \n function _validName(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n } \n \n function _validType(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n return result;\n } \n \n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = ''; \n \n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false); \n \n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n switch (type) {\n case 'object':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = {};\n break;\n case 'number':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'number';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = 0;\n break;\n case 'boolean':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'boolean';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = false;\n break;\n case 'array':\n typeDef.schema[property] = {};\n typeDef.schema[property].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n \n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n \t typeDef.schema[property].type = [_createTypeFromObject(name, property, obj[property][0])];\n \t typeDef.schema[property].default = [];\n \t } else {\n \t typeDef.schema[property].type = ['object'];\n \t typeDef.schema[property].default = [];\n \t }\n } else {\n typeDef.schema[property].type = [arrayType];\n typeDef.schema[property].default = [];\n }\n } else {\n typeDef.schema[property].type = ['any'];\n typeDef.schema[property].default = [];\n\t }\n break;\n default:\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'string';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n \n return typeName;\n }\n \n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n\tif (name && _validName(name) && jsonText) {\n\t try {\n\t json = JSON.parse(jsonText);\n\t if (json) {\n\t // schema\n\t schema = this.require('factory').addSchema(name.trim());\n\t \n\t schema._inherit = [];\n\t this.require('factory').updateSchema(schema._id, schema);\n\t \n\t this.require('designer').save();\n\t \n\t for (property in json) {\n\t if (property.indexOf('_') !== 0) {\n \t type = _getType(json[property]);\n \t if (type === 'array') {\n \t schema[property] = 'collection';\n \t } else {\n \t schema[property] = 'property';\n \t }\n\t }\n\t }\n\t \n\t this.require('factory').updateSchema(schema._id, schema);\n\t this.require('designer').save();\n\t \n\t // model\n\t model = this.require('factory').createModel(schema);\n\t this.require('designer').save();\n\n\t for (property in schema) {\n\t if (property.indexOf('_') !== 0) {\n\t type = _getType(json[property]);\n\t switch (type) {\n\t case 'object':\n\t if (json[property] !== null) {\n\t model[property].type = _createTypeFromObject('', property, json[property]);\n\t model[property].default = {};\n\t } else {\n\t model[property].type = 'object';\n\t model[property].default = {};\n\t }\n\t break;\n\t case 'number':\n\t model[property].type = 'number';\n\t model[property].default = 0;\n\t break;\n\t case 'boolean':\n\t model[property].type = 'boolean';\n\t model[property].default = false;\n\t break;\n\t case 'array':\n\t if (typeof json[property][0] !== 'undefined') {\n\t arrayType = _getType(json[property][0]);\n\t if (arrayType === 'object') {\n\t if (json[property][0] !== null) {\n \t model[property].type = [_createTypeFromObject('', property, json[property][0])];\n \t model[property].default = [];\n \t } else {\n \t model[property].type = ['object'];\n \t model[property].default = [];\n \t }\n\t } else {\n\t model[property].type = [arrayType];\n\t model[property].default = [];\n\t }\n\t } else {\n\t model[property].type = ['any'];\n\t model[property].default = [];\n\t }\n\t break;\n\t \tcase 'string':\n\t model[property].type = 'string';\n\t model[property].default = '';\n\t break;\n\t default:\n\t break;\n\t }\n\t }\n\t }\n\t \n\t this.require('factory').updateModel(model._id, model);\n\t this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\t \n\t this.require('message').success('A model has been created for the JSON.');\n\t }\n\t } catch(e) {\n\t this.hide();\n\t this.require('message').warning('Can not create the model: the JSON is invalid.');\n\t }\n\t} \n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"MenuItem":{},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2018 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v2.8.3"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"A behavior is the action to do when a method or an event is called."},"help-components.html":{"_id":"help-components.html","source":"Components are your classes instances. Their states are saved in a store, a JSON object."},"help-logs.html":{"_id":"help-logs.html","source":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "},"help-models.html":{"_id":"help-models.html","source":"A model is an UML representation of your classes. It is generated from a schema."},"help-schemas.html":{"_id":"help-schemas.html","source":"A schema is the definition of your model. Models are generated based on the schema definition."},"help-system.html":{"_id":"help-system.html","source":"An application is a system. Once you have created one, your next step is to create a schema."},"help-types.html":{"_id":"help-types.html","source":"A type is used in your model to define an enumeration or a structure."},"menu-action-search.html":{"_id":"menu-action-search.html","source":"
    \n
    \n \n
    \n
    "},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-guide.html":{"_id":"menu-item-guide.html","source":"Guide"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs"},"menu-item-message-save.html":{"_id":"menu-item-message-save.html","source":" file saved!"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-quick-start.html":{"_id":"menu-item-quick-start.html","source":"Quick Start"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.0.0","description":"Quick start\n\nThis system is taken from the quick start: https://system-designer.readme.io/docs/quick-start","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n var luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n var result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vador":{"_id":"vador","father":"","firstName":"Dark","lastName":"Vador"},"luke":{"_id":"luke","father":"vador","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"04-send-messages.json":{"_id":"04-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.0.0","description":"Send messages threw a channel\n\n\nYou can send messages from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. In '_Channel' 'send' method, define how to send the message to another channel (webRTC, XHR, ...).\n3. In another system, define how to get the message and send it to the system with: runtime.message().\n4. To send a message: this.require('channel').myevent(param1, param2, ...).\n5. To listen to the message, just add a behavior to the event.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.0.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"type":"css","readOnly":false,"mandatory":false,"default":""},"render":{}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{},"filter":{"type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n var html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n var div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n var items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n var author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.0.1","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n var http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"04-create-extension.json":{"_id":"04-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.1.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"05-listen-collection-events.json":{"_id":"05-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.0.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""},"field":{"type":"string","mandatory":true,"default":""},"value":{"type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"document":{"type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179bi":{"_id":"1f8571164c179bi","html":"menu-action-version.html","position":10,"type":"behavior"}},"MenuHeader":{"1fb101b99813a17":{"_id":"1fb101b99813a17","html":"menu-header-behavior.html","type":"behavior"}},"MenuItem":{"1f1781882618110":{"_id":"1f1781882618110","name":"action","html":"menu-item-action.html","position":10,"type":"behavior","platform":"all"},"1f1781882618111":{"_id":"1f1781882618111","name":"behavior","html":"menu-item-behavior.html","position":20,"type":"behavior","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"1dbc513e0e11z15":{"_id":"1dbc513e0e11z15","html":"toolbar-item-copy.html","position":50,"type":"behavior","platform":"electron"},"1dbc513e0e11z16":{"_id":"1dbc513e0e11z16","html":"toolbar-item-paste.html","position":60,"type":"behavior","platform":"electron"},"1dbc51200e11611":{"_id":"1dbc51200e11611","html":"toolbar-item-save.html","position":10,"type":"behavior","platform":"all"},"1dbc51200e11612":{"_id":"1dbc51200e11612","html":"toolbar-item-copyright.html","position":90,"type":"behavior","platform":"all"},"1dbc51200e11616":{"_id":"1dbc51200e11616","html":"toolbar-item-help.html","position":80,"type":"behavior","platform":"all"},"1dbc513e0e11z17":{"_id":"1dbc513e0e11z17","html":"toolbar-item-undo.html","position":20,"type":"behavior","platform":"all"},"1dbc513e0e11z18":{"_id":"1dbc513e0e11z18","html":"toolbar-item-redo.html","position":30,"type":"behavior","platform":"all"},"1dbc513e0e11z19":{"_id":"1dbc513e0e11z19","html":"toolbar-item-select-all.html","position":40,"type":"behavior","platform":"all"},"r11f4117b5111373":{"_id":"r11f4117b5111373","html":"toolbar-item-command.html","platform":"web","position":75,"type":"behavior"},"u11695143131df2f":{"_id":"u11695143131df2f","html":"toolbar-item-command.html","platform":"electron","position":75,"type":"behavior"}}},"_id":"c1444b19a0c1ec4d"}); \ No newline at end of file +runtime.install({"name":"editor-behavior","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"v123b51abbb18712":{"_id":"v123b51abbb18712","_name":"Diagram","_inherit":["_Component"],"ref":"property","zoom":"property","render":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method","toGraphviz":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","isType":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"],"refresh":"method"},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"2.9.0"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"addShortcuts":{"result":"any"}},"b169321637f19101":{"_id":"b169321637f19101","_name":"Diagram","_description":"","ref":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""},"zoom":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":1},"render":{"description":"","params":[],"result":"any"}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toGraphviz":{"description":"","params":[],"result":"string"}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":false}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57"},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"},"isType":{"description":"","params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null;\n \n if (extension.installed) { \n system = extension.source;\n \n try {\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n } catch (e) {\n this.require('message').danger('Can not install an extension.');\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n\n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').hide();\n }\n } else {\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').show();\n }\n }\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-file').attr('checked', false);\n $('#designer-dialog-import-modal-from-library').attr('checked', true);\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n that.data(JSON.parse(json));\n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-export-graphviz');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').uninstall('ext_' + system._id)\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '
    ');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-graphviz').prop('checked'):\n textToWrite = this.require('export').toGraphviz();\n fileNameToSaveAs = this.require('factory').system().name() + '.gv';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n downloadLink.click();\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n if (system.name === name) {\n result = false;\n break;\n }\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n \n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"snippet\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'snippet' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'snippet' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'snippet' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'snippet' });\n }\n \n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n \n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n \n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n \n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n \n // snippets\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet:'{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'snippet' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n \n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"snippet\" });\n }\n \n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n \n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n \n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n \n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n \n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"e13c7916b1a15fc4":{"_id":"e13c7916b1a15fc4","component":"Export","state":"toGraphviz","action":"function toGraphviz() {\n var schemas = this.require('factory').system().schemas();\n var models = this.require('factory').system().models();\n var inheritance = '';\n var modelId = '';\n var modelName = '';\n var modelDescription = '';\n var propName = '';\n var propVal = '';\n var attributes = '';\n var methods = '';\n var result = '';\n var links = '';\n var collections = '';\n var that = this;\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n // create model\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n modelDescription += '\\n\\n\\t' + modelName + ' [\\r\\t\\tlabel = \"{' + modelName + '|';\n \n attributes = '';\n methods = '';\n\n for (propName in models[modelId]) {\n if (models[modelId].hasOwnProperty(propName)) {\n propVal = models[modelId][propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (modelId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (modelId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n }\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n }\n }\n }\n break;\n \n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + params + ' : ' + result + '\\\\l';\n } else {\n methods += '+ ' + propName + params + ' : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + params + '\\\\l';\n } else {\n methods += '+ ' + propName + params + '\\\\l';\n }\n }\n break;\n \n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n \n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + '() : ' + result + '\\\\l';\n } else {\n methods += '+ ' + propName + '() : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + '()\\\\l';\n } else {\n methods += '+ ' + propName + '()\\\\l';\n }\n }\n break;\n }\n }\n }\n\n modelDescription += attributes + '|' + methods;\n modelDescription += '}\"\\r\\t]';\n }\n\n // create inheritance links\n for (var schema in schemas) {\n if (schemas[schema]._inherit && schemas[schema]._inherit.length) {\n schemas[schema]._inherit.forEach(function (parent) {\n inheritance += '\\n\\t' + schemas[schema]._name + ' -> ' + parent;\n });\n }\n }\n \n // case of Component\n if (inheritance.indexOf('_Component') !== -1) {\n modelDescription += `\\n\\t_Component [\n label = \"{_Component|+ id : string\\\\l|+ classInfo() : _ClassInfo\\\\l+ init(conf : object)\\\\l+ destroy()\\\\l+ on(state : string, action : function, useCoreAPI : boolean, isCore : boolean) : string\\\\l+ off(state : string, behaviorId : string)\\\\l+ require(id : string) : _Component\\\\l+ error(data : errorParam)\\\\l}\"\n ]` \n };\n\n let generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n \n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]${modelDescription}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"1\"\n taillabel = \"\"\n ]\n ${links}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"0..*\"\n taillabel = \"\"\n ]\n ${collections}\n\n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n arrowhead = \"empty\"\n headlabel = \"\"\n taillabel = \"\"\n ]\n ${inheritance}\n}`;\n\n return generatedDiagram;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n\n repo1.writeFile('master', system.name + '.json', JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html', htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js', jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^2.9.0';\n\n repo4.writeFile('master', 'package.json', JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.source());\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n \n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n });\n\n menuActions.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('afterbegin', '
  • ' + action.html().source() + '');\n });\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n this.require('state').messages(messages);\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n for (propName in this.document().schema) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n }\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n\n systemId = this.require('factory').system().id();\n schema = _getSchema(this.model());\n model = _getModel(this.model());\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = this.document()[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n if (modelName === '_Component') {\n modelName = _getModelFromComponent(propVal);\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n function gen() {\n return Math.floor((1 + Math.random()) * 0x10000).toString(16);\n }\n function getPrefix() {\n var validPrefix = 'abcdefghijklmnopqrstuvwxyz';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return getPrefix() + gen() + gen() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"v119e617ef513e94":{"_id":"v119e617ef513e94","component":"SystemFactory","state":"isType","action":"function isType(name) { \n var types = this.system().types(),\n result = false,\n prop = '';\n\n\tif (!result) {\n\t for (prop in types) {\n\t if (schemas[prop].name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n\n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n \n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system !== 'undefined':\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && typeof system !== 'undefined':\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && typeof system !== 'undefined':\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && typeof system !== 'undefined' && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n default:\n break;\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin', \n template.source().replace(/{{message}}/gi, message));\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom) {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (typeof system === 'undefined') {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"u165f215d0217974":{"_id":"u165f215d0217974","component":"1dbc513e0e11z15","state":"click","action":"function click() { \n $('#designer-toolbar-item-copy').tooltip('hide');\n this.require('editor').copy();\n this.require('message').success('The text has been copied to the clipboard.');\n}"},"f1846f199e41074c":{"_id":"f1846f199e41074c","component":"1dbc513e0e11z16","state":"click","action":"function click() { \n $('#designer-toolbar-item-paste').tooltip('hide');\n this.require('editor').paste(); \n}"},"m191d0168cd1e718":{"_id":"m191d0168cd1e718","component":"1dbc513e0e11z19","state":"click","action":"function click() { \n $('#designer-toolbar-item-select-all').tooltip('hide');\n this.require('editor').selectAll(); \n}"},"q13ca018ddf1b2cb":{"_id":"q13ca018ddf1b2cb","component":"1dbc513e0e11z18","state":"click","action":"function click() { \n $('#designer-toolbar-item-redo').tooltip('hide');\n this.require('editor').redo(); \n}"},"i17f271591b13ab8":{"_id":"i17f271591b13ab8","component":"1dbc513e0e11z17","state":"click","action":"function click() { \n $('#designer-toolbar-item-undo').tooltip('hide');\n this.require('editor').undo(); \n}"},"z151551d71511af6":{"_id":"z151551d71511af6","component":"1dbc51200e11616","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n this.require('designer').open('https://system-designer.readme.io/docs/create-a-behavior', '_blank', true); \n}"},"r1c1e3143bb14fea":{"_id":"r1c1e3143bb14fea","component":"1dbc51200e11612","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"g10e66157581049b":{"_id":"g10e66157581049b","component":"1dbc51200e11611","state":"click","action":"function click() {\n $('#designer-toolbar-item-save').tooltip('hide');\n this.require('designer').save(); \n}"},"r1e032137771c493":{"_id":"r1e032137771c493","component":"MenuItem","state":"click","action":"function click() { \n this.require('state').menu(this.name());\n}","useCoreAPI":false,"core":false},"w1d94e18b9f10fe3":{"_id":"w1d94e18b9f10fe3","component":"Workspace","state":"render","action":"function render() { \n var Editor = null,\n designer = null,\n editor = null;\n\n Editor = this.require('Editor');\n designer = this.require('designer');\n\n if (designer.isCordova()) {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'codemirror',\n 'context': 'behavior',\n 'editor': CodeMirror($('#designer-editor')[0], {\n lineNumbers: true,\n styleActiveLine: true,\n 'mode': 'text/javascript',\n 'theme': 'eclipse',\n 'tabSize': 2,\n 'autoCloseBrackets': true\n })\n });\n } else {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'ace',\n 'context': 'behavior',\n 'editor': ace.edit('designer-editor')\n });\n }\n \n editor.render();\n}","useCoreAPI":false,"core":false},"o1b89518d6212c82":{"_id":"o1b89518d6212c82","component":"1f1781882618110","state":"click","action":"function click() { \n var editor = this.require('editor');\n\n try {\n this.require('store').data(JSON.parse(editor.getValue()));\n } catch (e) {\n }\n\n editor.setEditor('javascript',this.require('store').data().action, 2);\n}","useCoreAPI":false,"core":false},"a16d1816a121a0ca":{"_id":"a16d1816a121a0ca","component":"1f1781882618111","state":"click","action":"function click() { \n var editor = this.require('editor');\n\n if (editor.getValue().indexOf('{') !== 0) {\n this.require('store').data().action = editor.getValue();\n }\n\n editor.setEditor('json', JSON.stringify(this.require('store').data(), null, '\\t'), 2);\n}","useCoreAPI":false,"core":false},"r1841b145401b120":{"_id":"r1841b145401b120","component":"Designer","state":"render","action":"function render() {\n var systemId = '',\n system = null,\n sys = null,\n id = '',\n behavior = null;\n\n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1]);\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n\n // set system\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n \n system = this.require('storage').get(systemId);\n \n sys = this.require('factory').create(system);\n \n // extensions\n this.installExtensions();\n\n // render\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('workspace').render();\n\n // set store\n behavior = this.require('storage').get(systemId).behaviors[id];\n\n this.require('store').uuid(id);\n this.require('store').data(behavior);\n\n if (behavior.state === 'start' && systemId === behavior.component) {\n document.title = 'behavior ' + this.require('factory').system().name() + '.' + behavior.state + ' · system ' + this.require('storage').get(systemId).name;\n } else {\n document.title = 'behavior ' + behavior.component + '.' + behavior.state + ' · system ' + this.require('storage').get(systemId).name;\n }\n\n this.require('editor').initValue(behavior.action, 2);\n \n this.require('router').update();\n \n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"t103d416bd313444":{"_id":"t103d416bd313444","component":"Designer","state":"save","action":"function save() { \n var val = this.require('editor').getValue(),\n designer = this.require('designer'),\n store = this.require('store').data();\n\n if (this.require('state').menu() === 'action') {\n store.action = val;\n } else {\n store = JSON.parse(val);\n }\n this.require('store').data(store);\n\n // check if ID change\n if (this.require('store').uuid() !== this.require('store').data()._id) {\n this.require('channel').$editorDeleteBehavior(this.require('store').uuid());\n this.require('store').uuid(this.require('store').data()._id);\n }\n\n if (store.state === 'start' && this.require('factory').system().id() === store.component) {\n document.title = 'behavior ' + this.require('factory').system().name() + ' · ' + document.title.split('·')[1].trim();\n } else {\n document.title = 'behavior ' + this.require('store').data().component + '.' + this.require('store').data().state + ' · ' + document.title.split('·')[1].trim();\n }\n\n this.require('channel').$editorUpdateBehavior(this.require('store').uuid(), this.require('store').data());\n this.require('message').clean();\n this.require('message').success('Behavior saved.');\n}","useCoreAPI":false,"core":false},"l16eb31f3a515bb9":{"_id":"l16eb31f3a515bb9","component":"c1444b19a0c1ec4d","state":"start","action":"function start() { \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"k1fa3c1a56a14081":{"_id":"k1fa3c1a56a14081","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n systemId = '',\n href = '';\n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1];\n menubar[i].href = '#' + id + '#' + systemId + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"i1227d101301030a":{"_id":"i1227d101301030a","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state');\n \n if (designer.isCordova()) {\n state.messages().push(message);\n }\n\n this.require('storage').set('system-designer-message', message);\n\n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\t\n}","useCoreAPI":false,"core":false},"d17bbd1a0311a1d7":{"_id":"d17bbd1a0311a1d7","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function changed(obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":false,"core":false},"j1ee401128b14b0a":{"_id":"j1ee401128b14b0a","component":"r11f4117b5111373","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');;\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"a154a417ccd16a26":{"_id":"a154a417ccd16a26","component":"u11695143131df2f","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"x18e941f8721d9b3":{"_id":"x18e941f8721d9b3","component":"Designer","state":"addShortcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component","diagram"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"2.9.0"}},"Diagram":{},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.1.1","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1d113198721599d":{"_id":"l1d113198721599d","_name":"MenuItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"u1f9a01abe31b3bf":{"_id":"u1f9a01abe31b3bf","_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"menuitem-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"name":{"type":"string","readOnly":false,"mandatory":false,"default":"template"},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"},"render":{},"click":{}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() { \n\tvar name = $('#modal-modeljson-name').val(),\n\t jsonText = $('#modal-modeljson-json').val(),\n\t json = null,\n\t schema = {},\n\t model = {},\n\t property = '',\n\t type = '',\n\t typeName = '',\n\t arrayType = '',\n\t that = this,\n\t createdTypes = [];\n\t \n\tfunction _getTypeName(parent, name) {\n\t var result = name;\n\t \n\t if (!_validType(name)) {\n\t if (parent) {\n\t result = parent + '_' + name;\n\t } else {\n\t result = name + Math.floor(Math.random() * 11);\n\t }\n\t }\n\t \n\t return result;\n\t} \n\n function _getType(value) {\n var type = '';\n \n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n \n return type;\n } \n \n function _validName(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n } \n \n function _validType(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n return result;\n } \n \n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = ''; \n \n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false); \n \n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n switch (type) {\n case 'object':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = {};\n break;\n case 'number':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'number';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = 0;\n break;\n case 'boolean':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'boolean';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = false;\n break;\n case 'array':\n typeDef.schema[property] = {};\n typeDef.schema[property].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n \n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n \t typeDef.schema[property].type = [_createTypeFromObject(name, property, obj[property][0])];\n \t typeDef.schema[property].default = [];\n \t } else {\n \t typeDef.schema[property].type = ['object'];\n \t typeDef.schema[property].default = [];\n \t }\n } else {\n typeDef.schema[property].type = [arrayType];\n typeDef.schema[property].default = [];\n }\n } else {\n typeDef.schema[property].type = ['any'];\n typeDef.schema[property].default = [];\n\t }\n break;\n default:\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'string';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n \n return typeName;\n }\n \n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n\tif (name && _validName(name) && jsonText) {\n\t try {\n\t json = JSON.parse(jsonText);\n\t if (json) {\n\t // schema\n\t schema = this.require('factory').addSchema(name.trim());\n\t \n\t schema._inherit = [];\n\t this.require('factory').updateSchema(schema._id, schema);\n\t \n\t this.require('designer').save();\n\t \n\t for (property in json) {\n\t if (property.indexOf('_') !== 0) {\n \t type = _getType(json[property]);\n \t if (type === 'array') {\n \t schema[property] = 'collection';\n \t } else {\n \t schema[property] = 'property';\n \t }\n\t }\n\t }\n\t \n\t this.require('factory').updateSchema(schema._id, schema);\n\t this.require('designer').save();\n\t \n\t // model\n\t model = this.require('factory').createModel(schema);\n\t this.require('designer').save();\n\n\t for (property in schema) {\n\t if (property.indexOf('_') !== 0) {\n\t type = _getType(json[property]);\n\t switch (type) {\n\t case 'object':\n\t if (json[property] !== null) {\n\t model[property].type = _createTypeFromObject('', property, json[property]);\n\t model[property].default = {};\n\t } else {\n\t model[property].type = 'object';\n\t model[property].default = {};\n\t }\n\t break;\n\t case 'number':\n\t model[property].type = 'number';\n\t model[property].default = 0;\n\t break;\n\t case 'boolean':\n\t model[property].type = 'boolean';\n\t model[property].default = false;\n\t break;\n\t case 'array':\n\t if (typeof json[property][0] !== 'undefined') {\n\t arrayType = _getType(json[property][0]);\n\t if (arrayType === 'object') {\n\t if (json[property][0] !== null) {\n \t model[property].type = [_createTypeFromObject('', property, json[property][0])];\n \t model[property].default = [];\n \t } else {\n \t model[property].type = ['object'];\n \t model[property].default = [];\n \t }\n\t } else {\n\t model[property].type = [arrayType];\n\t model[property].default = [];\n\t }\n\t } else {\n\t model[property].type = ['any'];\n\t model[property].default = [];\n\t }\n\t break;\n\t \tcase 'string':\n\t model[property].type = 'string';\n\t model[property].default = '';\n\t break;\n\t default:\n\t break;\n\t }\n\t }\n\t }\n\t \n\t this.require('factory').updateModel(model._id, model);\n\t this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\t \n\t this.require('message').success('A model has been created for the JSON.');\n\t }\n\t } catch(e) {\n\t this.hide();\n\t this.require('message').warning('Can not create the model: the JSON is invalid.');\n\t }\n\t} \n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"MenuItem":{},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2018 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v2.9.0"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"A behavior is the action to do when a method or an event is called."},"help-components.html":{"_id":"help-components.html","source":"Components are your classes instances. Their states are saved in a store, a JSON object."},"help-logs.html":{"_id":"help-logs.html","source":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "},"help-models.html":{"_id":"help-models.html","source":"A model is an UML representation of your classes. It is generated from a schema."},"help-schemas.html":{"_id":"help-schemas.html","source":"A schema is the definition of your model. Models are generated based on the schema definition."},"help-system.html":{"_id":"help-system.html","source":"An application is a system. Once you have created one, your next step is to create a schema."},"help-types.html":{"_id":"help-types.html","source":"A type is used in your model to define an enumeration or a structure."},"menu-action-search.html":{"_id":"menu-action-search.html","source":"
    \n
    \n \n
    \n
    "},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-guide.html":{"_id":"menu-item-guide.html","source":"Guide"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs0"},"menu-item-message-save.html":{"_id":"menu-item-message-save.html","source":" file saved!"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-quick-start.html":{"_id":"menu-item-quick-start.html","source":"Quick Start"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"},"toolbar-item-diagram.html":{"_id":"toolbar-item-diagram.html","source":""},"menu-item-diagram.html":{"_id":"menu-item-diagram.html","source":"Class diagram"},"toolbar-item-zoomout.html":{"_id":"toolbar-item-zoomout.html","source":""},"toolbar-item-zoomin.html":{"_id":"toolbar-item-zoomin.html","source":""},"toolbar-item-zoominit.html":{"_id":"toolbar-item-zoominit.html","source":""},"toolbar-item-export-diagram.html":{"_id":"toolbar-item-export-diagram.html","source":""}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.0.0","description":"Quick start\n\nThis system is taken from the quick start: https://system-designer.readme.io/docs/quick-start","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n var luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n var result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vador":{"_id":"vador","father":"","firstName":"Dark","lastName":"Vador"},"luke":{"_id":"luke","father":"vador","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"04-send-messages.json":{"_id":"04-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.0.0","description":"Send messages threw a channel\n\n\nYou can send messages from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. In '_Channel' 'send' method, define how to send the message to another channel (webRTC, XHR, ...).\n3. In another system, define how to get the message and send it to the system with: runtime.message().\n4. To send a message: this.require('channel').myevent(param1, param2, ...).\n5. To listen to the message, just add a behavior to the event.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.0.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"type":"css","readOnly":false,"mandatory":false,"default":""},"render":{}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{},"filter":{"type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n var html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n var div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n var items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n var author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.0.1","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n var http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"04-create-extension.json":{"_id":"04-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.1.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"05-listen-collection-events.json":{"_id":"05-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.0.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""},"field":{"type":"string","mandatory":true,"default":""},"value":{"type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"document":{"type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179bi":{"_id":"1f8571164c179bi","html":"menu-action-version.html","position":10,"type":"behavior"}},"MenuHeader":{"1fb101b99813a17":{"_id":"1fb101b99813a17","html":"menu-header-behavior.html","type":"behavior"}},"MenuItem":{"1f1781882618110":{"_id":"1f1781882618110","name":"action","html":"menu-item-action.html","position":10,"type":"behavior","platform":"all"},"1f1781882618111":{"_id":"1f1781882618111","name":"behavior","html":"menu-item-behavior.html","position":20,"type":"behavior","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"1dbc513e0e11z15":{"_id":"1dbc513e0e11z15","html":"toolbar-item-copy.html","position":50,"type":"behavior","platform":"electron"},"1dbc513e0e11z16":{"_id":"1dbc513e0e11z16","html":"toolbar-item-paste.html","position":60,"type":"behavior","platform":"electron"},"1dbc51200e11611":{"_id":"1dbc51200e11611","html":"toolbar-item-save.html","position":10,"type":"behavior","platform":"all"},"1dbc51200e11612":{"_id":"1dbc51200e11612","html":"toolbar-item-copyright.html","position":90,"type":"behavior","platform":"all"},"1dbc51200e11616":{"_id":"1dbc51200e11616","html":"toolbar-item-help.html","position":80,"type":"behavior","platform":"all"},"1dbc513e0e11z17":{"_id":"1dbc513e0e11z17","html":"toolbar-item-undo.html","position":20,"type":"behavior","platform":"all"},"1dbc513e0e11z18":{"_id":"1dbc513e0e11z18","html":"toolbar-item-redo.html","position":30,"type":"behavior","platform":"all"},"1dbc513e0e11z19":{"_id":"1dbc513e0e11z19","html":"toolbar-item-select-all.html","position":40,"type":"behavior","platform":"all"},"r11f4117b5111373":{"_id":"r11f4117b5111373","html":"toolbar-item-command.html","platform":"web","position":75,"type":"behavior"},"u11695143131df2f":{"_id":"u11695143131df2f","html":"toolbar-item-command.html","platform":"electron","position":75,"type":"behavior"}}},"_id":"c1444b19a0c1ec4d"}); \ No newline at end of file diff --git a/designer/scripts/editor-component.js b/designer/scripts/editor-component.js index 9411c1d..fe6e1bc 100644 --- a/designer/scripts/editor-component.js +++ b/designer/scripts/editor-component.js @@ -1,3 +1,3 @@ // System Designer - Copyright 2018 Erwan Carriou // Licensed under the Apache License, Version 2.0 (the "License") -runtime.install({"name":"editor-component","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"]},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"2.8.3"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"addShortcuts":{}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}]}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":false}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57"},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null;\n \n if (extension.installed) { \n system = extension.source;\n \n try {\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n } catch (e) {\n this.require('message').danger('Can not install an extension.');\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n\n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').hide();\n }\n } else {\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').show();\n }\n }\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-file').attr('checked', false);\n $('#designer-dialog-import-modal-from-library').attr('checked', true);\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n that.data(JSON.parse(json));\n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').uninstall('ext_' + system._id)\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '
    ');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n downloadLink.click();\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n if (system.name === name) {\n result = false;\n break;\n }\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n \n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"snippet\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'snippet' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'snippet' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'snippet' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'snippet' });\n }\n \n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n \n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n \n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n \n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n \n // snippets\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet:'{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'snippet' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n \n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"snippet\" });\n }\n \n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n \n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n \n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n \n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n \n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n\n repo1.writeFile('master', system.name + '.json', JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html', htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js', jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^2.8.4';\n\n repo4.writeFile('master', 'package.json', JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.source());\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n \n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n });\n\n menuActions.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('afterbegin', '
  • ' + action.html().source() + '');\n });\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n this.require('state').messages(messages);\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n for (propName in this.document().schema) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n }\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n\n systemId = this.require('factory').system().id();\n schema = _getSchema(this.model());\n model = _getModel(this.model());\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = this.document()[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n if (modelName === '_Component') {\n modelName = _getModelFromComponent(propVal);\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n function gen() {\n return Math.floor((1 + Math.random()) * 0x10000).toString(16);\n }\n function getPrefix() {\n var validPrefix = 'abcdefghijklmnopqrstuvwxyz';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return getPrefix() + gen() + gen() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n\n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n \n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system !== 'undefined':\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && typeof system !== 'undefined':\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && typeof system !== 'undefined':\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && typeof system !== 'undefined' && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n default:\n break;\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin', \n template.source().replace(/{{message}}/gi, message));\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom) {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (typeof system === 'undefined') {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"x1013f12b661a249":{"_id":"x1013f12b661a249","component":"wdbc51200e11z03","state":"click","action":"function click() { \n $('#designer-toolbar-item-copy').tooltip('hide');\n this.require('editor').copy(); \n}"},"v1639613d361aacf":{"_id":"v1639613d361aacf","component":"wdbc51200e11z04","state":"click","action":"function click() { \n $('#designer-toolbar-item-paste').tooltip('hide');\n this.require('editor').paste(); \n}"},"g1a0081da861f758":{"_id":"g1a0081da861f758","component":"wdbc51200e11z02","state":"click","action":"function click() { \n $('#designer-toolbar-item-select-all').tooltip('hide');\n this.require('editor').selectAll(); \n}"},"q1812b16012148e4":{"_id":"q1812b16012148e4","component":"wdbc51200e11z01","state":"click","action":"function click() { \n $('#designer-toolbar-item-redo').tooltip('hide');\n this.require('editor').redo(); \n}"},"f1f85510ffb1f7de":{"_id":"f1f85510ffb1f7de","component":"wdbc51200e11z00","state":"click","action":"function click() { \n $('#designer-toolbar-item-undo').tooltip('hide');\n this.require('editor').undo(); \n}"},"a1ca6b1c67e16e93":{"_id":"a1ca6b1c67e16e93","component":"1dbc51200e11617","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n this.require('designer').open('https://system-designer.readme.io/docs/create-a-component', '_blank', true);\n}"},"u1b6fb175031cb76":{"_id":"u1b6fb175031cb76","component":"1dbc51200e11614","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"n1e17b11f5d1fd1d":{"_id":"n1e17b11f5d1fd1d","component":"1dbc51200e11613","state":"click","action":"function click() {\n $('#designer-toolbar-item-save').tooltip('hide');\n this.require('designer').save();\n}"},"s10e461a0831354a":{"_id":"s10e461a0831354a","component":"MenuItem","state":"click","action":"function click() { \n var designer = this.require('designer'),\n editor = this.require('editor'),\n state = this.require('state'),\n extra = null,\n oldContext = '',\n context = '',\n val = '';\n\n state.previousMenu(state.menu());\n state.menu(this.name());\n\n extra = this.require('store').extra();\n oldContext = state.previousMenu();\n context = state.menu();\n val = editor.getValue();\n\n if (oldContext) {\n if (oldContext !== 'runtimeComponent') {\n if (extra[oldContext] === 'json') {\n this.require('store').data()[oldContext] = JSON.parse(editor.getValue());\n } else {\n this.require('store').data()[oldContext] = editor.getValue();\n }\n } else {\n this.require('store').data(JSON.parse(editor.getValue()));\n }\n }\n\n component = this.require('store').data();\n\n if (context !== 'runtimeComponent') {\n if (extra[context] === 'json') {\n editor.setEditor(extra[context], JSON.stringify(component[context], null, '\\t'), 2);\n } else {\n editor.setEditor(extra[context], component[context], 1, true);\n }\n } else {\n editor.setEditor('json', JSON.stringify(this.require('store').data(), null, '\\t'), 2);\n }\n}","useCoreAPI":false,"core":false},"f1236f1ee1e1d68f":{"_id":"f1236f1ee1e1d68f","component":"Workspace","state":"render","action":"function render() { \n var Editor = null,\n designer = null,\n editor = null;\n\n Editor = this.require('Editor');\n designer = this.require('designer');\n\n if (designer.isCordova()) {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'codemirror',\n 'context': 'component',\n 'editor': CodeMirror($('#designer-editor')[0], {\n lineNumbers: true,\n styleActiveLine: true,\n 'mode': 'application/json',\n 'theme': 'eclipse',\n 'tabSize': 2,\n 'autoCloseBrackets': true\n })\n });\n } else {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'ace',\n 'context': 'component',\n 'editor': ace.edit('designer-editor')\n });\n }\n \n editor.render();\n}","useCoreAPI":false,"core":false},"b1c1bb1ef0416898":{"_id":"b1c1bb1ef0416898","component":"Designer","state":"render","action":"function render() {\n var systemId = '',\n system = null,\n sys = null,\n id = '',\n types = null,\n title = '',\n collection = '',\n self = this,\n designer = this.require('designer'),\n result = {},\n property = '',\n propName = '',\n editor = null;\n\n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1]);\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n\n // get parameters\n id = decodeURIComponent(document.location.href.split('#')[1].split('?')[0]);\n collection = decodeURIComponent(document.location.href.split('#')[2].split('?')[0]);\n systemId = document.location.href.split('#')[3].split('?')[0];\n \n // set system\n system = this.require('storage').get(systemId);\n\n sys = this.require('factory').create(system);\n \n // extensions\n this.installExtensions();\n\n // render\n this.require('toolbar').render();\n this.require('workspace').render();\n \n // set editor\n system = this.require('storage').get(systemId);\n component = system.components[collection][id];\n model = this.require('factory').getGeneratedModel(collection);\n\n function _init(props) {\n var propName = '',\n position = 0,\n menuitem = null,\n arrId = [];\n \n if (Object.keys(props)) {\n // add menuitems\n for (propName in props) {\n self.require('db').collections().HTML.insert({\n \"_id\": \"menu-item-property-\" + propName + \".html\",\n \"source\": '' + propName + ''\n });\n arrId = self.require('db').collections().MenuItem.insert({\n \"name\": propName,\n \"html\": \"menu-item-property-\" + propName + \".html\",\n \"position\": position + 10,\n \"type\": \"component\"\n });\n }\n\n // items\n var toto = self.require('menubar').items().sort(function (itemA, itemB) {\n var compA = runtime.require(itemA),\n compB = runtime.require(itemB);\n\n if (compA.position() > compB.position()) {\n return 1;\n }\n if (compA.position() < compB.position()) {\n return -1;\n }\n return 0;\n });\n // render\n self.require('menubar').render();\n }\n }\n\n this.require('store').uuid(id);\n this.require('store').collection(collection);\n this.require('store').data(component);\n\n for (property in component) {\n if (model[property] && model[property].type) {\n switch (true) {\n case model[property].type === 'html':\n result[property] = 'html';\n break;\n case model[property].type === 'javascript':\n result[property] = 'javascript';\n break;\n case model[property].type === 'css':\n result[property] = 'css';\n break;\n case model[property].type === 'json':\n result[property] = 'json';\n break;\n case model[property].type === 'object':\n result[property] = 'json';\n break;\n case model[property].type === 'text':\n result[property] = 'text';\n break;\n //case Array.isArray(model[property].type):\n //result[property] = 'array';\n //break;\n default:\n // case of object / json type\n types = system.types;\n if (\n types &&\n typeof types[model[property].type] !== 'undefined' &&\n (types[model[property].type].type === 'object' || types[model[property].type].type === 'json')\n ) {\n result[property] = 'json';\n }\n break;\n }\n }\n }\n\n this.require('store').extra(result);\n _init(result);\n\n document.title = 'component ' + id + ' · system ' + system.name;\n\n editor = this.require('editor');\n if (Object.keys(result).length === 0) {\n editor.setEditor('json', JSON.stringify(component, null, '\\t'), 2);\n } else {\n propName = Object.keys(result)[0];\n if (result[propName] === 'json') {\n editor.setEditor(result[propName], JSON.stringify(component[propName], null, '\\t'), 2);\n } else {\n editor.setEditor(result[propName], component[propName], 1, true);\n }\n }\n \n this.require('router').update();\n \n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"z1bac81ce5915b1d":{"_id":"z1bac81ce5915b1d","component":"Designer","state":"save","action":"function save() { \n var val = this.require('editor').getValue(),\n designer = this.require('designer'),\n message = this.require('message'),\n store = this.require('store').data(),\n state = this.require('state'),\n extra = this.require('store').extra(),\n factory = this.require('factory'),\n id = '';\n\n if (state.menu() === 'runtimeComponent') {\n try {\n store = JSON.parse(val);\n } catch (e) {\n message.danger('Can not save your component: your component has an invalid structure.');\n return;\n }\n\n if (!store._id) {\n id = decodeURIComponent(document.location.href.split('#')[1].split('?')[0]);\n if (id) {\n store._id = id;\n } else {\n store._id = factory.generateId();\n }\n }\n if (store._id && store._id.indexOf(' ') !== -1) {\n message.danger('Invalid \\'_id\\'.
    Space is not authorized in the value of \\'_id\\'.');\n return;\n }\n } else {\n if (extra[state.menu()] === 'json') {\n store[state.menu()] = JSON.parse(val);\n } else {\n store[state.menu()] = val;\n }\n }\n this.require('store').data(store);\n\n // check if ID change\n if (this.require('store').uuid() !== this.require('store').data()._id) {\n this.require('channel').$editorUpdateComponentId(this.require('store').uuid(), this.require('store').data()._id, this.require('store').collection());\n this.require('channel').$editorDeleteComponent(this.require('store').uuid(), this.require('store').collection());\n\n this.require('store').uuid(this.require('store').data()._id);\n\n // update title\n document.title = 'component ' + this.require('store').uuid() + ' · ' + document.title.split('·')[1].trim();\n }\n\n this.require('channel').$editorUpdateComponent(this.require('store').uuid(), this.require('store').collection(), this.require('store').data());\n this.require('message').clean();\n this.require('message').success('Component saved.');\n}","useCoreAPI":false,"core":false},"n1e0b41437a1ee21":{"_id":"n1e0b41437a1ee21","component":"x1f67a1a3311b2f4","state":"start","action":"function start() { \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"m169e6148951d670":{"_id":"m169e6148951d670","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n systemId = '',\n href = '';\n\n id = decodeURIComponent(document.location.href.split('#')[1]);\n collection = document.location.href.split('#')[2];\n systemId = document.location.href.split('#')[3].split('?')[0];\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1];\n menubar[i].href = '#' + id + '#' + collection + '#' + systemId + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"p16e0e101141aec7":{"_id":"p16e0e101141aec7","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var storage = this.require('storage'),\n config = storage.get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state');\n\n storage.set('system-designer-message', message);\n\n if (designer.isCordova()) {\n state.messages().push(message);\n }\n\n // message for server debug\n if (typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\t\n}","useCoreAPI":false,"core":false},"k141a418b2f1e2c1":{"_id":"k141a418b2f1e2c1","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function (obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":false,"core":false},"b1a55213199167b3":{"_id":"b1a55213199167b3","component":"r185da17faa18ba1","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"a12e151c735189b9":{"_id":"a12e151c735189b9","component":"z125f2124301bac8","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"b14c8e1d3f9189fd":{"_id":"b14c8e1d3f9189fd","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar result = {};\n\treturn result;\n}","useCoreAPI":false,"core":false},"y10fc61d1d41464f":{"_id":"y10fc61d1d41464f","component":"Designer","state":"addShortcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"2.8.3"}},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.1.1","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1d113198721599d":{"_id":"l1d113198721599d","_name":"MenuItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"u1f9a01abe31b3bf":{"_id":"u1f9a01abe31b3bf","_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"menuitem-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"name":{"type":"string","readOnly":false,"mandatory":false,"default":"template"},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"},"render":{},"click":{}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() { \n\tvar name = $('#modal-modeljson-name').val(),\n\t jsonText = $('#modal-modeljson-json').val(),\n\t json = null,\n\t schema = {},\n\t model = {},\n\t property = '',\n\t type = '',\n\t typeName = '',\n\t arrayType = '',\n\t that = this,\n\t createdTypes = [];\n\t \n\tfunction _getTypeName(parent, name) {\n\t var result = name;\n\t \n\t if (!_validType(name)) {\n\t if (parent) {\n\t result = parent + '_' + name;\n\t } else {\n\t result = name + Math.floor(Math.random() * 11);\n\t }\n\t }\n\t \n\t return result;\n\t} \n\n function _getType(value) {\n var type = '';\n \n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n \n return type;\n } \n \n function _validName(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n } \n \n function _validType(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n return result;\n } \n \n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = ''; \n \n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false); \n \n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n switch (type) {\n case 'object':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = {};\n break;\n case 'number':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'number';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = 0;\n break;\n case 'boolean':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'boolean';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = false;\n break;\n case 'array':\n typeDef.schema[property] = {};\n typeDef.schema[property].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n \n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n \t typeDef.schema[property].type = [_createTypeFromObject(name, property, obj[property][0])];\n \t typeDef.schema[property].default = [];\n \t } else {\n \t typeDef.schema[property].type = ['object'];\n \t typeDef.schema[property].default = [];\n \t }\n } else {\n typeDef.schema[property].type = [arrayType];\n typeDef.schema[property].default = [];\n }\n } else {\n typeDef.schema[property].type = ['any'];\n typeDef.schema[property].default = [];\n\t }\n break;\n default:\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'string';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n \n return typeName;\n }\n \n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n\tif (name && _validName(name) && jsonText) {\n\t try {\n\t json = JSON.parse(jsonText);\n\t if (json) {\n\t // schema\n\t schema = this.require('factory').addSchema(name.trim());\n\t \n\t schema._inherit = [];\n\t this.require('factory').updateSchema(schema._id, schema);\n\t \n\t this.require('designer').save();\n\t \n\t for (property in json) {\n\t if (property.indexOf('_') !== 0) {\n \t type = _getType(json[property]);\n \t if (type === 'array') {\n \t schema[property] = 'collection';\n \t } else {\n \t schema[property] = 'property';\n \t }\n\t }\n\t }\n\t \n\t this.require('factory').updateSchema(schema._id, schema);\n\t this.require('designer').save();\n\t \n\t // model\n\t model = this.require('factory').createModel(schema);\n\t this.require('designer').save();\n\n\t for (property in schema) {\n\t if (property.indexOf('_') !== 0) {\n\t type = _getType(json[property]);\n\t switch (type) {\n\t case 'object':\n\t if (json[property] !== null) {\n\t model[property].type = _createTypeFromObject('', property, json[property]);\n\t model[property].default = {};\n\t } else {\n\t model[property].type = 'object';\n\t model[property].default = {};\n\t }\n\t break;\n\t case 'number':\n\t model[property].type = 'number';\n\t model[property].default = 0;\n\t break;\n\t case 'boolean':\n\t model[property].type = 'boolean';\n\t model[property].default = false;\n\t break;\n\t case 'array':\n\t if (typeof json[property][0] !== 'undefined') {\n\t arrayType = _getType(json[property][0]);\n\t if (arrayType === 'object') {\n\t if (json[property][0] !== null) {\n \t model[property].type = [_createTypeFromObject('', property, json[property][0])];\n \t model[property].default = [];\n \t } else {\n \t model[property].type = ['object'];\n \t model[property].default = [];\n \t }\n\t } else {\n\t model[property].type = [arrayType];\n\t model[property].default = [];\n\t }\n\t } else {\n\t model[property].type = ['any'];\n\t model[property].default = [];\n\t }\n\t break;\n\t \tcase 'string':\n\t model[property].type = 'string';\n\t model[property].default = '';\n\t break;\n\t default:\n\t break;\n\t }\n\t }\n\t }\n\t \n\t this.require('factory').updateModel(model._id, model);\n\t this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\t \n\t this.require('message').success('A model has been created for the JSON.');\n\t }\n\t } catch(e) {\n\t this.hide();\n\t this.require('message').warning('Can not create the model: the JSON is invalid.');\n\t }\n\t} \n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"MenuItem":{},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2018 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v2.8.3"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"A behavior is the action to do when a method or an event is called."},"help-components.html":{"_id":"help-components.html","source":"Components are your classes instances. Their states are saved in a store, a JSON object."},"help-logs.html":{"_id":"help-logs.html","source":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "},"help-models.html":{"_id":"help-models.html","source":"A model is an UML representation of your classes. It is generated from a schema."},"help-schemas.html":{"_id":"help-schemas.html","source":"A schema is the definition of your model. Models are generated based on the schema definition."},"help-system.html":{"_id":"help-system.html","source":"An application is a system. Once you have created one, your next step is to create a schema."},"help-types.html":{"_id":"help-types.html","source":"A type is used in your model to define an enumeration or a structure."},"menu-action-search.html":{"_id":"menu-action-search.html","source":"
    \n
    \n \n
    \n
    "},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-guide.html":{"_id":"menu-item-guide.html","source":"Guide"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs"},"menu-item-message-save.html":{"_id":"menu-item-message-save.html","source":" file saved!"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-quick-start.html":{"_id":"menu-item-quick-start.html","source":"Quick Start"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.0.0","description":"Quick start\n\nThis system is taken from the quick start: https://system-designer.readme.io/docs/quick-start","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n var luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n var result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vador":{"_id":"vador","father":"","firstName":"Dark","lastName":"Vador"},"luke":{"_id":"luke","father":"vador","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"04-send-messages.json":{"_id":"04-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.0.0","description":"Send messages threw a channel\n\n\nYou can send messages from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. In '_Channel' 'send' method, define how to send the message to another channel (webRTC, XHR, ...).\n3. In another system, define how to get the message and send it to the system with: runtime.message().\n4. To send a message: this.require('channel').myevent(param1, param2, ...).\n5. To listen to the message, just add a behavior to the event.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.0.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"type":"css","readOnly":false,"mandatory":false,"default":""},"render":{}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{},"filter":{"type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n var html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n var div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n var items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n var author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.0.1","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n var http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"04-create-extension.json":{"_id":"04-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.1.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"05-listen-collection-events.json":{"_id":"05-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.0.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""},"field":{"type":"string","mandatory":true,"default":""},"value":{"type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"document":{"type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179bj":{"_id":"1f8571164c179bj","html":"menu-action-version.html","position":10,"type":"component"}},"MenuHeader":{"1fb101b99813a18":{"_id":"1fb101b99813a18","html":"menu-header-component.html","type":"component"}},"MenuItem":{"1f1781882618113":{"_id":"1f1781882618113","name":"runtimeComponent","html":"menu-item-component.html","position":200,"type":"component","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"wdbc51200e11z03":{"_id":"wdbc51200e11z03","html":"toolbar-item-copy.html","position":50,"type":"component","platform":"electron"},"wdbc51200e11z04":{"_id":"wdbc51200e11z04","html":"toolbar-item-paste.html","position":60,"type":"component","platform":"electron"},"1dbc51200e11613":{"_id":"1dbc51200e11613","html":"toolbar-item-save.html","position":10,"type":"component","platform":"all"},"1dbc51200e11614":{"_id":"1dbc51200e11614","html":"toolbar-item-copyright.html","position":90,"type":"component","platform":"all"},"1dbc51200e11617":{"_id":"1dbc51200e11617","html":"toolbar-item-help.html","position":80,"type":"component","platform":"all"},"wdbc51200e11z00":{"_id":"wdbc51200e11z00","html":"toolbar-item-undo.html","position":20,"type":"component","platform":"all"},"wdbc51200e11z01":{"_id":"wdbc51200e11z01","html":"toolbar-item-redo.html","position":30,"type":"component","platform":"all"},"wdbc51200e11z02":{"_id":"wdbc51200e11z02","html":"toolbar-item-select-all.html","position":40,"type":"component","platform":"all"},"r185da17faa18ba1":{"_id":"r185da17faa18ba1","html":"toolbar-item-command.html","platform":"web","position":75,"type":"component"},"z125f2124301bac8":{"_id":"z125f2124301bac8","html":"toolbar-item-command.html","platform":"electron","position":75,"type":"component"}}},"_id":"x1f67a1a3311b2f4"}); \ No newline at end of file +runtime.install({"name":"editor-component","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"v123b51abbb18712":{"_id":"v123b51abbb18712","_name":"Diagram","_inherit":["_Component"],"ref":"property","zoom":"property","render":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method","toGraphviz":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","isType":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"]},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"2.9.0"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"addShortcuts":{}},"b169321637f19101":{"_id":"b169321637f19101","_name":"Diagram","_description":"","ref":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""},"zoom":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":1},"render":{"description":"","params":[],"result":"any"}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toGraphviz":{"description":"","params":[],"result":"string"}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":false}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57"},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"},"isType":{"description":"","params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null;\n \n if (extension.installed) { \n system = extension.source;\n \n try {\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n } catch (e) {\n this.require('message').danger('Can not install an extension.');\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n\n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').hide();\n }\n } else {\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').show();\n }\n }\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-file').attr('checked', false);\n $('#designer-dialog-import-modal-from-library').attr('checked', true);\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n that.data(JSON.parse(json));\n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-export-graphviz');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').uninstall('ext_' + system._id)\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-graphviz').prop('checked'):\n textToWrite = this.require('export').toGraphviz();\n fileNameToSaveAs = this.require('factory').system().name() + '.gv';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n downloadLink.click();\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n if (system.name === name) {\n result = false;\n break;\n }\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n \n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"snippet\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'snippet' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'snippet' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'snippet' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'snippet' });\n }\n \n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n \n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n \n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n \n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n \n // snippets\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet:'{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'snippet' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n \n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"snippet\" });\n }\n \n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n \n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n \n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n \n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n \n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"e13c7916b1a15fc4":{"_id":"e13c7916b1a15fc4","component":"Export","state":"toGraphviz","action":"function toGraphviz() {\n var schemas = this.require('factory').system().schemas();\n var models = this.require('factory').system().models();\n var inheritance = '';\n var modelId = '';\n var modelName = '';\n var modelDescription = '';\n var propName = '';\n var propVal = '';\n var attributes = '';\n var methods = '';\n var result = '';\n var links = '';\n var collections = '';\n var that = this;\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n // create model\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n modelDescription += '\\n\\n\\t' + modelName + ' [\\r\\t\\tlabel = \"{' + modelName + '|';\n \n attributes = '';\n methods = '';\n\n for (propName in models[modelId]) {\n if (models[modelId].hasOwnProperty(propName)) {\n propVal = models[modelId][propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (modelId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (modelId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n }\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n }\n }\n }\n break;\n \n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + params + ' : ' + result + '\\\\l';\n } else {\n methods += '+ ' + propName + params + ' : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + params + '\\\\l';\n } else {\n methods += '+ ' + propName + params + '\\\\l';\n }\n }\n break;\n \n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n \n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + '() : ' + result + '\\\\l';\n } else {\n methods += '+ ' + propName + '() : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + '()\\\\l';\n } else {\n methods += '+ ' + propName + '()\\\\l';\n }\n }\n break;\n }\n }\n }\n\n modelDescription += attributes + '|' + methods;\n modelDescription += '}\"\\r\\t]';\n }\n\n // create inheritance links\n for (var schema in schemas) {\n if (schemas[schema]._inherit && schemas[schema]._inherit.length) {\n schemas[schema]._inherit.forEach(function (parent) {\n inheritance += '\\n\\t' + schemas[schema]._name + ' -> ' + parent;\n });\n }\n }\n \n // case of Component\n if (inheritance.indexOf('_Component') !== -1) {\n modelDescription += `\\n\\t_Component [\n label = \"{_Component|+ id : string\\\\l|+ classInfo() : _ClassInfo\\\\l+ init(conf : object)\\\\l+ destroy()\\\\l+ on(state : string, action : function, useCoreAPI : boolean, isCore : boolean) : string\\\\l+ off(state : string, behaviorId : string)\\\\l+ require(id : string) : _Component\\\\l+ error(data : errorParam)\\\\l}\"\n ]` \n };\n\n let generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n \n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]${modelDescription}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"1\"\n taillabel = \"\"\n ]\n ${links}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"0..*\"\n taillabel = \"\"\n ]\n ${collections}\n\n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n arrowhead = \"empty\"\n headlabel = \"\"\n taillabel = \"\"\n ]\n ${inheritance}\n}`;\n\n return generatedDiagram;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n\n repo1.writeFile('master', system.name + '.json', JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html', htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js', jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^2.9.0';\n\n repo4.writeFile('master', 'package.json', JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.source());\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n \n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n });\n\n menuActions.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('afterbegin', '
  • ' + action.html().source() + '');\n });\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n this.require('state').messages(messages);\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n for (propName in this.document().schema) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n }\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n\n systemId = this.require('factory').system().id();\n schema = _getSchema(this.model());\n model = _getModel(this.model());\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = this.document()[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n if (modelName === '_Component') {\n modelName = _getModelFromComponent(propVal);\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n function gen() {\n return Math.floor((1 + Math.random()) * 0x10000).toString(16);\n }\n function getPrefix() {\n var validPrefix = 'abcdefghijklmnopqrstuvwxyz';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return getPrefix() + gen() + gen() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"v119e617ef513e94":{"_id":"v119e617ef513e94","component":"SystemFactory","state":"isType","action":"function isType(name) { \n var types = this.system().types(),\n result = false,\n prop = '';\n\n\tif (!result) {\n\t for (prop in types) {\n\t if (schemas[prop].name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n\n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n \n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system !== 'undefined':\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && typeof system !== 'undefined':\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && typeof system !== 'undefined':\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && typeof system !== 'undefined' && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n default:\n break;\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin', \n template.source().replace(/{{message}}/gi, message));\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom) {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (typeof system === 'undefined') {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"x1013f12b661a249":{"_id":"x1013f12b661a249","component":"wdbc51200e11z03","state":"click","action":"function click() { \n $('#designer-toolbar-item-copy').tooltip('hide');\n this.require('editor').copy();\n this.require('message').success('The text has been copied to the clipboard.');\n}"},"v1639613d361aacf":{"_id":"v1639613d361aacf","component":"wdbc51200e11z04","state":"click","action":"function click() { \n $('#designer-toolbar-item-paste').tooltip('hide');\n this.require('editor').paste(); \n}"},"g1a0081da861f758":{"_id":"g1a0081da861f758","component":"wdbc51200e11z02","state":"click","action":"function click() { \n $('#designer-toolbar-item-select-all').tooltip('hide');\n this.require('editor').selectAll(); \n}"},"q1812b16012148e4":{"_id":"q1812b16012148e4","component":"wdbc51200e11z01","state":"click","action":"function click() { \n $('#designer-toolbar-item-redo').tooltip('hide');\n this.require('editor').redo(); \n}"},"f1f85510ffb1f7de":{"_id":"f1f85510ffb1f7de","component":"wdbc51200e11z00","state":"click","action":"function click() { \n $('#designer-toolbar-item-undo').tooltip('hide');\n this.require('editor').undo(); \n}"},"a1ca6b1c67e16e93":{"_id":"a1ca6b1c67e16e93","component":"1dbc51200e11617","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n this.require('designer').open('https://system-designer.readme.io/docs/create-a-component', '_blank', true);\n}"},"u1b6fb175031cb76":{"_id":"u1b6fb175031cb76","component":"1dbc51200e11614","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"n1e17b11f5d1fd1d":{"_id":"n1e17b11f5d1fd1d","component":"1dbc51200e11613","state":"click","action":"function click() {\n $('#designer-toolbar-item-save').tooltip('hide');\n this.require('designer').save();\n}"},"s10e461a0831354a":{"_id":"s10e461a0831354a","component":"MenuItem","state":"click","action":"function click() { \n var designer = this.require('designer'),\n editor = this.require('editor'),\n state = this.require('state'),\n extra = null,\n oldContext = '',\n context = '',\n val = '';\n\n state.previousMenu(state.menu());\n state.menu(this.name());\n\n extra = this.require('store').extra();\n oldContext = state.previousMenu();\n context = state.menu();\n val = editor.getValue();\n\n if (oldContext) {\n if (oldContext !== 'runtimeComponent') {\n if (extra[oldContext] === 'json') {\n this.require('store').data()[oldContext] = JSON.parse(editor.getValue());\n } else {\n this.require('store').data()[oldContext] = editor.getValue();\n }\n } else {\n this.require('store').data(JSON.parse(editor.getValue()));\n }\n }\n\n component = this.require('store').data();\n\n if (context !== 'runtimeComponent') {\n if (extra[context] === 'json') {\n editor.setEditor(extra[context], JSON.stringify(component[context], null, '\\t'), 2);\n } else {\n editor.setEditor(extra[context], component[context], 1, true);\n }\n } else {\n editor.setEditor('json', JSON.stringify(this.require('store').data(), null, '\\t'), 2);\n }\n}","useCoreAPI":false,"core":false},"f1236f1ee1e1d68f":{"_id":"f1236f1ee1e1d68f","component":"Workspace","state":"render","action":"function render() { \n var Editor = null,\n designer = null,\n editor = null;\n\n Editor = this.require('Editor');\n designer = this.require('designer');\n\n if (designer.isCordova()) {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'codemirror',\n 'context': 'component',\n 'editor': CodeMirror($('#designer-editor')[0], {\n lineNumbers: true,\n styleActiveLine: true,\n 'mode': 'application/json',\n 'theme': 'eclipse',\n 'tabSize': 2,\n 'autoCloseBrackets': true\n })\n });\n } else {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'ace',\n 'context': 'component',\n 'editor': ace.edit('designer-editor')\n });\n }\n \n editor.render();\n}","useCoreAPI":false,"core":false},"b1c1bb1ef0416898":{"_id":"b1c1bb1ef0416898","component":"Designer","state":"render","action":"function render() {\n var systemId = '',\n system = null,\n sys = null,\n id = '',\n types = null,\n title = '',\n collection = '',\n self = this,\n designer = this.require('designer'),\n result = {},\n property = '',\n propName = '',\n editor = null;\n\n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1]);\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n\n // get parameters\n id = decodeURIComponent(document.location.href.split('#')[1].split('?')[0]);\n collection = decodeURIComponent(document.location.href.split('#')[2].split('?')[0]);\n systemId = document.location.href.split('#')[3].split('?')[0];\n \n // set system\n system = this.require('storage').get(systemId);\n\n sys = this.require('factory').create(system);\n \n // extensions\n this.installExtensions();\n\n // render\n this.require('toolbar').render();\n this.require('workspace').render();\n \n // set editor\n system = this.require('storage').get(systemId);\n component = system.components[collection][id];\n model = this.require('factory').getGeneratedModel(collection);\n\n function _init(props) {\n var propName = '',\n position = 0,\n menuitem = null,\n arrId = [];\n \n if (Object.keys(props)) {\n // add menuitems\n for (propName in props) {\n self.require('db').collections().HTML.insert({\n \"_id\": \"menu-item-property-\" + propName + \".html\",\n \"source\": '' + propName + ''\n });\n arrId = self.require('db').collections().MenuItem.insert({\n \"name\": propName,\n \"html\": \"menu-item-property-\" + propName + \".html\",\n \"position\": position + 10,\n \"type\": \"component\"\n });\n }\n\n // items\n var toto = self.require('menubar').items().sort(function (itemA, itemB) {\n var compA = runtime.require(itemA),\n compB = runtime.require(itemB);\n\n if (compA.position() > compB.position()) {\n return 1;\n }\n if (compA.position() < compB.position()) {\n return -1;\n }\n return 0;\n });\n // render\n self.require('menubar').render();\n }\n }\n\n this.require('store').uuid(id);\n this.require('store').collection(collection);\n this.require('store').data(component);\n\n for (property in component) {\n if (model[property] && model[property].type) {\n switch (true) {\n case model[property].type === 'html':\n result[property] = 'html';\n break;\n case model[property].type === 'javascript':\n result[property] = 'javascript';\n break;\n case model[property].type === 'css':\n result[property] = 'css';\n break;\n case model[property].type === 'json':\n result[property] = 'json';\n break;\n case model[property].type === 'object':\n result[property] = 'json';\n break;\n case model[property].type === 'text':\n result[property] = 'text';\n break;\n //case Array.isArray(model[property].type):\n //result[property] = 'array';\n //break;\n default:\n // case of object / json type\n types = system.types;\n if (\n types &&\n typeof types[model[property].type] !== 'undefined' &&\n (types[model[property].type].type === 'object' || types[model[property].type].type === 'json')\n ) {\n result[property] = 'json';\n }\n break;\n }\n }\n }\n\n this.require('store').extra(result);\n _init(result);\n\n document.title = 'component ' + id + ' · system ' + system.name;\n\n editor = this.require('editor');\n if (Object.keys(result).length === 0) {\n editor.setEditor('json', JSON.stringify(component, null, '\\t'), 2);\n } else {\n propName = Object.keys(result)[0];\n if (result[propName] === 'json') {\n editor.setEditor(result[propName], JSON.stringify(component[propName], null, '\\t'), 2);\n } else {\n editor.setEditor(result[propName], component[propName], 1, true);\n }\n }\n \n this.require('router').update();\n \n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"z1bac81ce5915b1d":{"_id":"z1bac81ce5915b1d","component":"Designer","state":"save","action":"function save() { \n var val = this.require('editor').getValue(),\n designer = this.require('designer'),\n message = this.require('message'),\n store = this.require('store').data(),\n state = this.require('state'),\n extra = this.require('store').extra(),\n factory = this.require('factory'),\n id = '';\n\n if (state.menu() === 'runtimeComponent') {\n try {\n store = JSON.parse(val);\n } catch (e) {\n message.danger('Can not save your component: your component has an invalid structure.');\n return;\n }\n\n if (!store._id) {\n id = decodeURIComponent(document.location.href.split('#')[1].split('?')[0]);\n if (id) {\n store._id = id;\n } else {\n store._id = factory.generateId();\n }\n }\n if (store._id && store._id.indexOf(' ') !== -1) {\n message.danger('Invalid \\'_id\\'.
    Space is not authorized in the value of \\'_id\\'.');\n return;\n }\n } else {\n if (extra[state.menu()] === 'json') {\n store[state.menu()] = JSON.parse(val);\n } else {\n store[state.menu()] = val;\n }\n }\n this.require('store').data(store);\n\n // check if ID change\n if (this.require('store').uuid() !== this.require('store').data()._id) {\n this.require('channel').$editorUpdateComponentId(this.require('store').uuid(), this.require('store').data()._id, this.require('store').collection());\n this.require('channel').$editorDeleteComponent(this.require('store').uuid(), this.require('store').collection());\n\n this.require('store').uuid(this.require('store').data()._id);\n\n // update title\n document.title = 'component ' + this.require('store').uuid() + ' · ' + document.title.split('·')[1].trim();\n }\n\n this.require('channel').$editorUpdateComponent(this.require('store').uuid(), this.require('store').collection(), this.require('store').data());\n this.require('message').clean();\n this.require('message').success('Component saved.');\n}","useCoreAPI":false,"core":false},"n1e0b41437a1ee21":{"_id":"n1e0b41437a1ee21","component":"x1f67a1a3311b2f4","state":"start","action":"function start() { \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"m169e6148951d670":{"_id":"m169e6148951d670","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n systemId = '',\n href = '';\n\n id = decodeURIComponent(document.location.href.split('#')[1]);\n collection = document.location.href.split('#')[2];\n systemId = document.location.href.split('#')[3].split('?')[0];\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1];\n menubar[i].href = '#' + id + '#' + collection + '#' + systemId + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"p16e0e101141aec7":{"_id":"p16e0e101141aec7","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var storage = this.require('storage'),\n config = storage.get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state');\n\n storage.set('system-designer-message', message);\n\n if (designer.isCordova()) {\n state.messages().push(message);\n }\n\n // message for server debug\n if (typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\t\n}","useCoreAPI":false,"core":false},"k141a418b2f1e2c1":{"_id":"k141a418b2f1e2c1","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function (obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":false,"core":false},"b1a55213199167b3":{"_id":"b1a55213199167b3","component":"r185da17faa18ba1","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"a12e151c735189b9":{"_id":"a12e151c735189b9","component":"z125f2124301bac8","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"y10fc61d1d41464f":{"_id":"y10fc61d1d41464f","component":"Designer","state":"addShortcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component","diagram"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"2.9.0"}},"Diagram":{},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.1.1","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1d113198721599d":{"_id":"l1d113198721599d","_name":"MenuItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"u1f9a01abe31b3bf":{"_id":"u1f9a01abe31b3bf","_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"menuitem-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"name":{"type":"string","readOnly":false,"mandatory":false,"default":"template"},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"},"render":{},"click":{}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() { \n\tvar name = $('#modal-modeljson-name').val(),\n\t jsonText = $('#modal-modeljson-json').val(),\n\t json = null,\n\t schema = {},\n\t model = {},\n\t property = '',\n\t type = '',\n\t typeName = '',\n\t arrayType = '',\n\t that = this,\n\t createdTypes = [];\n\t \n\tfunction _getTypeName(parent, name) {\n\t var result = name;\n\t \n\t if (!_validType(name)) {\n\t if (parent) {\n\t result = parent + '_' + name;\n\t } else {\n\t result = name + Math.floor(Math.random() * 11);\n\t }\n\t }\n\t \n\t return result;\n\t} \n\n function _getType(value) {\n var type = '';\n \n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n \n return type;\n } \n \n function _validName(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n } \n \n function _validType(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n return result;\n } \n \n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = ''; \n \n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false); \n \n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n switch (type) {\n case 'object':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = {};\n break;\n case 'number':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'number';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = 0;\n break;\n case 'boolean':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'boolean';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = false;\n break;\n case 'array':\n typeDef.schema[property] = {};\n typeDef.schema[property].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n \n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n \t typeDef.schema[property].type = [_createTypeFromObject(name, property, obj[property][0])];\n \t typeDef.schema[property].default = [];\n \t } else {\n \t typeDef.schema[property].type = ['object'];\n \t typeDef.schema[property].default = [];\n \t }\n } else {\n typeDef.schema[property].type = [arrayType];\n typeDef.schema[property].default = [];\n }\n } else {\n typeDef.schema[property].type = ['any'];\n typeDef.schema[property].default = [];\n\t }\n break;\n default:\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'string';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n \n return typeName;\n }\n \n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n\tif (name && _validName(name) && jsonText) {\n\t try {\n\t json = JSON.parse(jsonText);\n\t if (json) {\n\t // schema\n\t schema = this.require('factory').addSchema(name.trim());\n\t \n\t schema._inherit = [];\n\t this.require('factory').updateSchema(schema._id, schema);\n\t \n\t this.require('designer').save();\n\t \n\t for (property in json) {\n\t if (property.indexOf('_') !== 0) {\n \t type = _getType(json[property]);\n \t if (type === 'array') {\n \t schema[property] = 'collection';\n \t } else {\n \t schema[property] = 'property';\n \t }\n\t }\n\t }\n\t \n\t this.require('factory').updateSchema(schema._id, schema);\n\t this.require('designer').save();\n\t \n\t // model\n\t model = this.require('factory').createModel(schema);\n\t this.require('designer').save();\n\n\t for (property in schema) {\n\t if (property.indexOf('_') !== 0) {\n\t type = _getType(json[property]);\n\t switch (type) {\n\t case 'object':\n\t if (json[property] !== null) {\n\t model[property].type = _createTypeFromObject('', property, json[property]);\n\t model[property].default = {};\n\t } else {\n\t model[property].type = 'object';\n\t model[property].default = {};\n\t }\n\t break;\n\t case 'number':\n\t model[property].type = 'number';\n\t model[property].default = 0;\n\t break;\n\t case 'boolean':\n\t model[property].type = 'boolean';\n\t model[property].default = false;\n\t break;\n\t case 'array':\n\t if (typeof json[property][0] !== 'undefined') {\n\t arrayType = _getType(json[property][0]);\n\t if (arrayType === 'object') {\n\t if (json[property][0] !== null) {\n \t model[property].type = [_createTypeFromObject('', property, json[property][0])];\n \t model[property].default = [];\n \t } else {\n \t model[property].type = ['object'];\n \t model[property].default = [];\n \t }\n\t } else {\n\t model[property].type = [arrayType];\n\t model[property].default = [];\n\t }\n\t } else {\n\t model[property].type = ['any'];\n\t model[property].default = [];\n\t }\n\t break;\n\t \tcase 'string':\n\t model[property].type = 'string';\n\t model[property].default = '';\n\t break;\n\t default:\n\t break;\n\t }\n\t }\n\t }\n\t \n\t this.require('factory').updateModel(model._id, model);\n\t this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\t \n\t this.require('message').success('A model has been created for the JSON.');\n\t }\n\t } catch(e) {\n\t this.hide();\n\t this.require('message').warning('Can not create the model: the JSON is invalid.');\n\t }\n\t} \n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"MenuItem":{},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2018 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v2.9.0"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"A behavior is the action to do when a method or an event is called."},"help-components.html":{"_id":"help-components.html","source":"Components are your classes instances. Their states are saved in a store, a JSON object."},"help-logs.html":{"_id":"help-logs.html","source":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "},"help-models.html":{"_id":"help-models.html","source":"A model is an UML representation of your classes. It is generated from a schema."},"help-schemas.html":{"_id":"help-schemas.html","source":"A schema is the definition of your model. Models are generated based on the schema definition."},"help-system.html":{"_id":"help-system.html","source":"An application is a system. Once you have created one, your next step is to create a schema."},"help-types.html":{"_id":"help-types.html","source":"A type is used in your model to define an enumeration or a structure."},"menu-action-search.html":{"_id":"menu-action-search.html","source":"
    \n
    \n \n
    \n
    "},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-guide.html":{"_id":"menu-item-guide.html","source":"Guide"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs0"},"menu-item-message-save.html":{"_id":"menu-item-message-save.html","source":" file saved!"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-quick-start.html":{"_id":"menu-item-quick-start.html","source":"Quick Start"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"},"toolbar-item-diagram.html":{"_id":"toolbar-item-diagram.html","source":""},"menu-item-diagram.html":{"_id":"menu-item-diagram.html","source":"Class diagram"},"toolbar-item-zoomout.html":{"_id":"toolbar-item-zoomout.html","source":""},"toolbar-item-zoomin.html":{"_id":"toolbar-item-zoomin.html","source":""},"toolbar-item-zoominit.html":{"_id":"toolbar-item-zoominit.html","source":""},"toolbar-item-export-diagram.html":{"_id":"toolbar-item-export-diagram.html","source":""}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.0.0","description":"Quick start\n\nThis system is taken from the quick start: https://system-designer.readme.io/docs/quick-start","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n var luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n var result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vador":{"_id":"vador","father":"","firstName":"Dark","lastName":"Vador"},"luke":{"_id":"luke","father":"vador","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"04-send-messages.json":{"_id":"04-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.0.0","description":"Send messages threw a channel\n\n\nYou can send messages from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. In '_Channel' 'send' method, define how to send the message to another channel (webRTC, XHR, ...).\n3. In another system, define how to get the message and send it to the system with: runtime.message().\n4. To send a message: this.require('channel').myevent(param1, param2, ...).\n5. To listen to the message, just add a behavior to the event.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.0.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"type":"css","readOnly":false,"mandatory":false,"default":""},"render":{}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{},"filter":{"type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n var html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n var div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n var items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n var author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.0.1","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n var http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"04-create-extension.json":{"_id":"04-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.1.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"05-listen-collection-events.json":{"_id":"05-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.0.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""},"field":{"type":"string","mandatory":true,"default":""},"value":{"type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"document":{"type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179bj":{"_id":"1f8571164c179bj","html":"menu-action-version.html","position":10,"type":"component"}},"MenuHeader":{"1fb101b99813a18":{"_id":"1fb101b99813a18","html":"menu-header-component.html","type":"component"}},"MenuItem":{"1f1781882618113":{"_id":"1f1781882618113","name":"runtimeComponent","html":"menu-item-component.html","position":200,"type":"component","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"wdbc51200e11z03":{"_id":"wdbc51200e11z03","html":"toolbar-item-copy.html","position":50,"type":"component","platform":"electron"},"wdbc51200e11z04":{"_id":"wdbc51200e11z04","html":"toolbar-item-paste.html","position":60,"type":"component","platform":"electron"},"1dbc51200e11613":{"_id":"1dbc51200e11613","html":"toolbar-item-save.html","position":10,"type":"component","platform":"all"},"1dbc51200e11614":{"_id":"1dbc51200e11614","html":"toolbar-item-copyright.html","position":90,"type":"component","platform":"all"},"1dbc51200e11617":{"_id":"1dbc51200e11617","html":"toolbar-item-help.html","position":80,"type":"component","platform":"all"},"wdbc51200e11z00":{"_id":"wdbc51200e11z00","html":"toolbar-item-undo.html","position":20,"type":"component","platform":"all"},"wdbc51200e11z01":{"_id":"wdbc51200e11z01","html":"toolbar-item-redo.html","position":30,"type":"component","platform":"all"},"wdbc51200e11z02":{"_id":"wdbc51200e11z02","html":"toolbar-item-select-all.html","position":40,"type":"component","platform":"all"},"r185da17faa18ba1":{"_id":"r185da17faa18ba1","html":"toolbar-item-command.html","platform":"web","position":75,"type":"component"},"z125f2124301bac8":{"_id":"z125f2124301bac8","html":"toolbar-item-command.html","platform":"electron","position":75,"type":"component"}}},"_id":"x1f67a1a3311b2f4"}); \ No newline at end of file diff --git a/designer/scripts/editor-model.js b/designer/scripts/editor-model.js index 92defbf..68dd3c7 100644 --- a/designer/scripts/editor-model.js +++ b/designer/scripts/editor-model.js @@ -1,3 +1,3 @@ // System Designer - Copyright 2018 Erwan Carriou // Licensed under the Apache License, Version 2.0 (the "License") -runtime.install({"name":"editor-model","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"],"refresh":"method"},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"2.8.3"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"addShortcuts":{}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}]}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":false}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57"},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null;\n \n if (extension.installed) { \n system = extension.source;\n \n try {\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n } catch (e) {\n this.require('message').danger('Can not install an extension.');\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n\n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').hide();\n }\n } else {\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').show();\n }\n }\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-file').attr('checked', false);\n $('#designer-dialog-import-modal-from-library').attr('checked', true);\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n that.data(JSON.parse(json));\n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').uninstall('ext_' + system._id)\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n downloadLink.click();\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n if (system.name === name) {\n result = false;\n break;\n }\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n \n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"snippet\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'snippet' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'snippet' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'snippet' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'snippet' });\n }\n \n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n \n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n \n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n \n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n \n // snippets\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet:'{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'snippet' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n \n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"snippet\" });\n }\n \n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n \n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n \n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n \n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n \n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n\n repo1.writeFile('master', system.name + '.json', JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html', htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js', jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^2.8.4';\n\n repo4.writeFile('master', 'package.json', JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.source());\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n \n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n });\n\n menuActions.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('afterbegin', '
  • ' + action.html().source() + '');\n });\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n this.require('state').messages(messages);\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n for (propName in this.document().schema) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n }\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n\n systemId = this.require('factory').system().id();\n schema = _getSchema(this.model());\n model = _getModel(this.model());\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = this.document()[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n if (modelName === '_Component') {\n modelName = _getModelFromComponent(propVal);\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n function gen() {\n return Math.floor((1 + Math.random()) * 0x10000).toString(16);\n }\n function getPrefix() {\n var validPrefix = 'abcdefghijklmnopqrstuvwxyz';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return getPrefix() + gen() + gen() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n\n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n \n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system !== 'undefined':\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && typeof system !== 'undefined':\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && typeof system !== 'undefined':\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && typeof system !== 'undefined' && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n default:\n break;\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin', \n template.source().replace(/{{message}}/gi, message));\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom) {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (typeof system === 'undefined') {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"t15f921e6a316234":{"_id":"t15f921e6a316234","component":"udbc51200e11z03","state":"click","action":"function click() { \n $('#designer-toolbar-item-copy').tooltip('hide');\n this.require('editor').copy(); \n}"},"d10e191ee9813950":{"_id":"d10e191ee9813950","component":"udbc51200e11z04","state":"click","action":"function click() { \n $('#designer-toolbar-item-paste').tooltip('hide');\n this.require('editor').paste(); \n}"},"i1a1951779613207":{"_id":"i1a1951779613207","component":"udbc51200e11z02","state":"click","action":"function click() { \n $('#designer-toolbar-item-select-all').tooltip('hide');\n this.require('editor').selectAll(); \n}"},"d1d8ee1ac3812186":{"_id":"d1d8ee1ac3812186","component":"udbc51200e11z01","state":"click","action":"function click() { \n $('#designer-toolbar-item-redo').tooltip('hide');\n this.require('editor').redo(); \n}"},"i15954170f111203":{"_id":"i15954170f111203","component":"udbc51200e11z00","state":"click","action":"function click() { \n $('#designer-toolbar-item-undo').tooltip('hide');\n this.require('editor').undo(); \n}"},"y1dbc0114c11c791":{"_id":"y1dbc0114c11c791","component":"1dbc51200e116e9","state":"click","action":"function click() {\n $('#designer-toolbar-item-save').tooltip('hide');\n this.require('designer').save(); \n}"},"j1ac7610be61012b":{"_id":"j1ac7610be61012b","component":"1dbc51200e11615","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n this.require('designer').open('https://system-designer.readme.io/docs/edit-a-model', '_blank', true); \n}"},"g161d21f3a912625":{"_id":"g161d21f3a912625","component":"1dbc51200e11610","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"d1802118f46183c0":{"_id":"d1802118f46183c0","component":"Workspace","state":"render","action":"function render() { \n var Editor = null,\n designer = null,\n editor = null;\n\n Editor = this.require('Editor');\n designer = this.require('designer');\n\n if (designer.isCordova()) {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'codemirror',\n 'context': 'model',\n 'editor': CodeMirror($('#designer-editor')[0], {\n lineNumbers: true,\n styleActiveLine: true,\n 'mode': 'application/json',\n 'theme': 'eclipse',\n 'tabSize': 2,\n 'autoCloseBrackets': true\n })\n });\n } else {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'ace',\n 'context': 'model',\n 'editor': ace.edit('designer-editor')\n });\n }\n \n editor.render();\n}","useCoreAPI":false,"core":false},"x1cd3e156f81600f":{"_id":"x1cd3e156f81600f","component":"Designer","state":"render","action":"function render() {\n var systemId = '',\n system = null,\n sys = null,\n id = '',\n modelName = '',\n modelGen = null;\n\n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1].split('?')[0]);\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n\n // get parameters\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n \n // set system\n system = this.require('storage').get(systemId);\n sys = this.require('factory').create(system);\n \n // extensions\n this.installExtensions();\n\n // render\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('workspace').render();\n \n // set editor\n system = this.require('storage').get(systemId);\n model = system.models[id];\n\n this.require('store').uuid(id);\n this.require('store').data(model);\n\n modelName = system.models[id]._name;\n modelGen = this.require('factory').getGeneratedModel(modelName);\n this.require('store').extra(modelGen);\n\n document.title = 'model ' + model._name + ' · system ' + system.name;\n\n this.require('editor').initValue(JSON.stringify(model, null, '\\t'), 2);\n\n this.require('router').update();\n \n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"s1bc6b11e9a13afd":{"_id":"s1bc6b11e9a13afd","component":"Designer","state":"save","action":"function save() { \n var val = this.require('editor').getValue(),\n designer = this.require('designer'),\n message = this.require('message'),\n model = null,\n property = '',\n modelGen = null,\n hasError = false;\n\n try {\n model = JSON.parse(val);\n } catch (e) {\n message.danger('Can not save your model: your model has an invalid structure.');\n return;\n }\n \n \n // _inherit check\n if (typeof model._inherit !== 'undefined' && !Array.isArray(model._inherit)) {\n message.danger('Invalid inheritance value: it must be an array.');\n return;\n }\n \n if (model._inherit && model._inherit.indexOf(model._name) !== -1) {\n message.danger('Invalid inheritance value: you can not inherit from yourself.');\n return;\n }\n \n if (model._inherit && model._inherit.indexOf('') !== -1) {\n message.danger('Invalid inheritance value: it can not be empty.');\n return;\n }\n\n if (model._inherit) {\n model._inherit.forEach(function (parent) {\n if (parent.constructor.name !== 'String') {\n hasError = true;\n }\n });\n if (hasError) {\n message.danger('Invalid inheritance value: it must be a string.');\n return;\n }\n }\n\n // _name check\n if (typeof model._name === 'undefined') {\n message.danger('The property \\'_name\\' is missing.');\n return;\n }\n \n if (model._name.constructor.name !== 'String') {\n message.danger('The property \\'_name\\' must be a string.');\n return;\n }\n \n // clean name\n model._name = model._name.replace(/\\s|\\t/gi, '_')\n .replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '')\n .replace(/\\r|\\n/gi,'');\n\n // _id check\n if (typeof model._id === 'undefined') {\n message.danger('The property \\'_id\\' is missing.');\n return;\n }\n \n if (model._id.constructor.name !== 'String') {\n message.danger('The property \\'_id\\' must be a string.');\n return;\n }\n\n for (property in model) {\n if (property.indexOf(' ') !== -1) {\n message.danger('Invalid property name \\'' + property + '\\’.
    Space is not authorized in the name of a property.');\n return;\n }\n propVal = model[property];\n if (typeof propVal === 'object' && !Array.isArray(propVal) && property.indexOf('_') === 0) {\n message.danger('Invalid property name \\'' + property + '\\’.
    A property name can not start with \\'_\\'.');\n return;\n }\n if (property.indexOf('_') === 0) {\n if (['_id', '_name', '_inherit', '_class', '_core', '_description'].indexOf(property) === -1) {\n message.danger('Invalid value \\'' + property + '\\’.
    Authorized values are: \\'_id\\', \\'_name\\', \\'_inherit\\', \\'_class\\', \\'_core\\' and \\'_description\\'.');\n return;\n }\n }\n }\n\n modelGen = this.require('store').extra();\n for (property in model) {\n if (property.indexOf('_') !== 0 && typeof modelGen[property] === 'undefined') {\n message.danger('Invalid property name \\'' + property + '\\’.
    \\'' + property + '\\’ must be defined in the schema.');\n return;\n }\n }\n\n if (this.require('store').data()._name === model._name) {\n this.require('store').data(model);\n\n // check if ID change\n if (this.require('store').uuid() !== this.require('store').data()._id) {\n this.require('channel').$editorUpdateModelId(this.require('store').uuid(), this.require('store').data()._id);\n this.require('store').uuid(this.require('store').data()._id);\n }\n\n this.require('channel').$editorUpdateModel(this.require('store').uuid(), this.require('store').data());\n message.success('Model saved.');\n } else {\n message.danger('You can not modify the name of a model.');\n }\n}","useCoreAPI":false,"core":false},"z1b1ad1fdbb1a46a":{"_id":"z1b1ad1fdbb1a46a","component":"w1a78b16d7311831","state":"start","action":"function start() { \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"t12f1412dc71b53b":{"_id":"t12f1412dc71b53b","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n href = '';\n\n id = decodeURIComponent(document.location.href.split('#')[1]);\n collection = document.location.href.split('#')[2];\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1];\n menubar[i].href = '#' + id + '#' + collection + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"q1db4d1ae7a19ae6":{"_id":"q1db4d1ae7a19ae6","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state');\n\n if (designer.isCordova()) {\n state.messages().push(message);\n }\n\n this.require('storage').set('system-designer-message', message);\n\n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\n}","useCoreAPI":false,"core":false},"m193c119f111fd88":{"_id":"m193c119f111fd88","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function changed(obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":false,"core":false},"s1a154168ce17fa9":{"_id":"s1a154168ce17fa9","component":"o1f40e168bd10174","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"c1e34c13e6b10bd9":{"_id":"c1e34c13e6b10bd9","component":"m1ff0113f491d841","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"z1d0c211b1b131ca":{"_id":"z1d0c211b1b131ca","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar result = {};\n\treturn result;\n}","useCoreAPI":false,"core":false},"f1c23c1dcb0122a3":{"_id":"f1c23c1dcb0122a3","component":"Designer","state":"addShortcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"2.8.3"}},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.1.1","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1d113198721599d":{"_id":"l1d113198721599d","_name":"MenuItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"u1f9a01abe31b3bf":{"_id":"u1f9a01abe31b3bf","_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"menuitem-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"name":{"type":"string","readOnly":false,"mandatory":false,"default":"template"},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"},"render":{},"click":{}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() { \n\tvar name = $('#modal-modeljson-name').val(),\n\t jsonText = $('#modal-modeljson-json').val(),\n\t json = null,\n\t schema = {},\n\t model = {},\n\t property = '',\n\t type = '',\n\t typeName = '',\n\t arrayType = '',\n\t that = this,\n\t createdTypes = [];\n\t \n\tfunction _getTypeName(parent, name) {\n\t var result = name;\n\t \n\t if (!_validType(name)) {\n\t if (parent) {\n\t result = parent + '_' + name;\n\t } else {\n\t result = name + Math.floor(Math.random() * 11);\n\t }\n\t }\n\t \n\t return result;\n\t} \n\n function _getType(value) {\n var type = '';\n \n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n \n return type;\n } \n \n function _validName(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n } \n \n function _validType(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n return result;\n } \n \n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = ''; \n \n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false); \n \n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n switch (type) {\n case 'object':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = {};\n break;\n case 'number':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'number';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = 0;\n break;\n case 'boolean':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'boolean';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = false;\n break;\n case 'array':\n typeDef.schema[property] = {};\n typeDef.schema[property].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n \n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n \t typeDef.schema[property].type = [_createTypeFromObject(name, property, obj[property][0])];\n \t typeDef.schema[property].default = [];\n \t } else {\n \t typeDef.schema[property].type = ['object'];\n \t typeDef.schema[property].default = [];\n \t }\n } else {\n typeDef.schema[property].type = [arrayType];\n typeDef.schema[property].default = [];\n }\n } else {\n typeDef.schema[property].type = ['any'];\n typeDef.schema[property].default = [];\n\t }\n break;\n default:\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'string';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n \n return typeName;\n }\n \n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n\tif (name && _validName(name) && jsonText) {\n\t try {\n\t json = JSON.parse(jsonText);\n\t if (json) {\n\t // schema\n\t schema = this.require('factory').addSchema(name.trim());\n\t \n\t schema._inherit = [];\n\t this.require('factory').updateSchema(schema._id, schema);\n\t \n\t this.require('designer').save();\n\t \n\t for (property in json) {\n\t if (property.indexOf('_') !== 0) {\n \t type = _getType(json[property]);\n \t if (type === 'array') {\n \t schema[property] = 'collection';\n \t } else {\n \t schema[property] = 'property';\n \t }\n\t }\n\t }\n\t \n\t this.require('factory').updateSchema(schema._id, schema);\n\t this.require('designer').save();\n\t \n\t // model\n\t model = this.require('factory').createModel(schema);\n\t this.require('designer').save();\n\n\t for (property in schema) {\n\t if (property.indexOf('_') !== 0) {\n\t type = _getType(json[property]);\n\t switch (type) {\n\t case 'object':\n\t if (json[property] !== null) {\n\t model[property].type = _createTypeFromObject('', property, json[property]);\n\t model[property].default = {};\n\t } else {\n\t model[property].type = 'object';\n\t model[property].default = {};\n\t }\n\t break;\n\t case 'number':\n\t model[property].type = 'number';\n\t model[property].default = 0;\n\t break;\n\t case 'boolean':\n\t model[property].type = 'boolean';\n\t model[property].default = false;\n\t break;\n\t case 'array':\n\t if (typeof json[property][0] !== 'undefined') {\n\t arrayType = _getType(json[property][0]);\n\t if (arrayType === 'object') {\n\t if (json[property][0] !== null) {\n \t model[property].type = [_createTypeFromObject('', property, json[property][0])];\n \t model[property].default = [];\n \t } else {\n \t model[property].type = ['object'];\n \t model[property].default = [];\n \t }\n\t } else {\n\t model[property].type = [arrayType];\n\t model[property].default = [];\n\t }\n\t } else {\n\t model[property].type = ['any'];\n\t model[property].default = [];\n\t }\n\t break;\n\t \tcase 'string':\n\t model[property].type = 'string';\n\t model[property].default = '';\n\t break;\n\t default:\n\t break;\n\t }\n\t }\n\t }\n\t \n\t this.require('factory').updateModel(model._id, model);\n\t this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\t \n\t this.require('message').success('A model has been created for the JSON.');\n\t }\n\t } catch(e) {\n\t this.hide();\n\t this.require('message').warning('Can not create the model: the JSON is invalid.');\n\t }\n\t} \n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"MenuItem":{},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2018 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v2.8.3"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"A behavior is the action to do when a method or an event is called."},"help-components.html":{"_id":"help-components.html","source":"Components are your classes instances. Their states are saved in a store, a JSON object."},"help-logs.html":{"_id":"help-logs.html","source":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "},"help-models.html":{"_id":"help-models.html","source":"A model is an UML representation of your classes. It is generated from a schema."},"help-schemas.html":{"_id":"help-schemas.html","source":"A schema is the definition of your model. Models are generated based on the schema definition."},"help-system.html":{"_id":"help-system.html","source":"An application is a system. Once you have created one, your next step is to create a schema."},"help-types.html":{"_id":"help-types.html","source":"A type is used in your model to define an enumeration or a structure."},"menu-action-search.html":{"_id":"menu-action-search.html","source":"
    \n
    \n \n
    \n
    "},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-guide.html":{"_id":"menu-item-guide.html","source":"Guide"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs"},"menu-item-message-save.html":{"_id":"menu-item-message-save.html","source":" file saved!"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-quick-start.html":{"_id":"menu-item-quick-start.html","source":"Quick Start"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.0.0","description":"Quick start\n\nThis system is taken from the quick start: https://system-designer.readme.io/docs/quick-start","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n var luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n var result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vador":{"_id":"vador","father":"","firstName":"Dark","lastName":"Vador"},"luke":{"_id":"luke","father":"vador","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"04-send-messages.json":{"_id":"04-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.0.0","description":"Send messages threw a channel\n\n\nYou can send messages from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. In '_Channel' 'send' method, define how to send the message to another channel (webRTC, XHR, ...).\n3. In another system, define how to get the message and send it to the system with: runtime.message().\n4. To send a message: this.require('channel').myevent(param1, param2, ...).\n5. To listen to the message, just add a behavior to the event.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.0.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"type":"css","readOnly":false,"mandatory":false,"default":""},"render":{}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{},"filter":{"type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n var html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n var div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n var items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n var author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.0.1","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n var http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"04-create-extension.json":{"_id":"04-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.1.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"05-listen-collection-events.json":{"_id":"05-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.0.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""},"field":{"type":"string","mandatory":true,"default":""},"value":{"type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"document":{"type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179bh":{"_id":"1f8571164c179bh","html":"menu-action-version.html","position":10,"type":"model"}},"MenuHeader":{"1fb101b99813a16":{"_id":"1fb101b99813a16","html":"menu-header-model.html","type":"model"}},"MenuItem":{"1f1781882618108":{"_id":"1f1781882618108","name":"model","html":"menu-item-model.html","position":10,"type":"model","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"udbc51200e11z03":{"_id":"udbc51200e11z03","html":"toolbar-item-copy.html","position":50,"type":"model","platform":"electron"},"udbc51200e11z04":{"_id":"udbc51200e11z04","html":"toolbar-item-paste.html","position":60,"type":"model","platform":"electron"},"1dbc51200e11610":{"_id":"1dbc51200e11610","html":"toolbar-item-copyright.html","position":90,"type":"model","platform":"all"},"1dbc51200e11615":{"_id":"1dbc51200e11615","html":"toolbar-item-help.html","position":80,"type":"model","platform":"all"},"1dbc51200e116e9":{"_id":"1dbc51200e116e9","html":"toolbar-item-save.html","position":10,"type":"model","platform":"all"},"udbc51200e11z00":{"_id":"udbc51200e11z00","html":"toolbar-item-undo.html","position":20,"type":"model","platform":"all"},"udbc51200e11z01":{"_id":"udbc51200e11z01","html":"toolbar-item-redo.html","position":30,"type":"model","platform":"all"},"udbc51200e11z02":{"_id":"udbc51200e11z02","html":"toolbar-item-select-all.html","position":40,"type":"model","platform":"all"},"o1f40e168bd10174":{"_id":"o1f40e168bd10174","html":"toolbar-item-command.html","platform":"web","position":75,"type":"model"},"m1ff0113f491d841":{"_id":"m1ff0113f491d841","html":"toolbar-item-command.html","platform":"electron","position":75,"type":"model"}}},"_id":"w1a78b16d7311831"}); \ No newline at end of file +runtime.install({"name":"editor-model","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"v123b51abbb18712":{"_id":"v123b51abbb18712","_name":"Diagram","_inherit":["_Component"],"ref":"property","zoom":"property","render":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method","toGraphviz":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","isType":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"],"refresh":"method"},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"2.9.0"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"addShortcuts":{}},"b169321637f19101":{"_id":"b169321637f19101","_name":"Diagram","_description":"","ref":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""},"zoom":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":1},"render":{"description":"","params":[],"result":"any"}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toGraphviz":{"description":"","params":[],"result":"string"}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":false}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57"},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"},"isType":{"description":"","params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null;\n \n if (extension.installed) { \n system = extension.source;\n \n try {\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n } catch (e) {\n this.require('message').danger('Can not install an extension.');\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n\n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').hide();\n }\n } else {\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').show();\n }\n }\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-file').attr('checked', false);\n $('#designer-dialog-import-modal-from-library').attr('checked', true);\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n that.data(JSON.parse(json));\n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-export-graphviz');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').uninstall('ext_' + system._id)\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-graphviz').prop('checked'):\n textToWrite = this.require('export').toGraphviz();\n fileNameToSaveAs = this.require('factory').system().name() + '.gv';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n downloadLink.click();\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n if (system.name === name) {\n result = false;\n break;\n }\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n \n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"snippet\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'snippet' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'snippet' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'snippet' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'snippet' });\n }\n \n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n \n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n \n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n \n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n \n // snippets\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet:'{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'snippet' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n \n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"snippet\" });\n }\n \n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n \n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n \n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n \n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n \n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"e13c7916b1a15fc4":{"_id":"e13c7916b1a15fc4","component":"Export","state":"toGraphviz","action":"function toGraphviz() {\n var schemas = this.require('factory').system().schemas();\n var models = this.require('factory').system().models();\n var inheritance = '';\n var modelId = '';\n var modelName = '';\n var modelDescription = '';\n var propName = '';\n var propVal = '';\n var attributes = '';\n var methods = '';\n var result = '';\n var links = '';\n var collections = '';\n var that = this;\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n // create model\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n modelDescription += '\\n\\n\\t' + modelName + ' [\\r\\t\\tlabel = \"{' + modelName + '|';\n \n attributes = '';\n methods = '';\n\n for (propName in models[modelId]) {\n if (models[modelId].hasOwnProperty(propName)) {\n propVal = models[modelId][propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (modelId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (modelId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n }\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n }\n }\n }\n break;\n \n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + params + ' : ' + result + '\\\\l';\n } else {\n methods += '+ ' + propName + params + ' : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + params + '\\\\l';\n } else {\n methods += '+ ' + propName + params + '\\\\l';\n }\n }\n break;\n \n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n \n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + '() : ' + result + '\\\\l';\n } else {\n methods += '+ ' + propName + '() : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + '()\\\\l';\n } else {\n methods += '+ ' + propName + '()\\\\l';\n }\n }\n break;\n }\n }\n }\n\n modelDescription += attributes + '|' + methods;\n modelDescription += '}\"\\r\\t]';\n }\n\n // create inheritance links\n for (var schema in schemas) {\n if (schemas[schema]._inherit && schemas[schema]._inherit.length) {\n schemas[schema]._inherit.forEach(function (parent) {\n inheritance += '\\n\\t' + schemas[schema]._name + ' -> ' + parent;\n });\n }\n }\n \n // case of Component\n if (inheritance.indexOf('_Component') !== -1) {\n modelDescription += `\\n\\t_Component [\n label = \"{_Component|+ id : string\\\\l|+ classInfo() : _ClassInfo\\\\l+ init(conf : object)\\\\l+ destroy()\\\\l+ on(state : string, action : function, useCoreAPI : boolean, isCore : boolean) : string\\\\l+ off(state : string, behaviorId : string)\\\\l+ require(id : string) : _Component\\\\l+ error(data : errorParam)\\\\l}\"\n ]` \n };\n\n let generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n \n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]${modelDescription}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"1\"\n taillabel = \"\"\n ]\n ${links}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"0..*\"\n taillabel = \"\"\n ]\n ${collections}\n\n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n arrowhead = \"empty\"\n headlabel = \"\"\n taillabel = \"\"\n ]\n ${inheritance}\n}`;\n\n return generatedDiagram;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n\n repo1.writeFile('master', system.name + '.json', JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html', htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js', jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^2.9.0';\n\n repo4.writeFile('master', 'package.json', JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.source());\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n \n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n });\n\n menuActions.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('afterbegin', '
  • ' + action.html().source() + '');\n });\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n this.require('state').messages(messages);\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n for (propName in this.document().schema) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n }\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n\n systemId = this.require('factory').system().id();\n schema = _getSchema(this.model());\n model = _getModel(this.model());\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = this.document()[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n if (modelName === '_Component') {\n modelName = _getModelFromComponent(propVal);\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n function gen() {\n return Math.floor((1 + Math.random()) * 0x10000).toString(16);\n }\n function getPrefix() {\n var validPrefix = 'abcdefghijklmnopqrstuvwxyz';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return getPrefix() + gen() + gen() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"v119e617ef513e94":{"_id":"v119e617ef513e94","component":"SystemFactory","state":"isType","action":"function isType(name) { \n var types = this.system().types(),\n result = false,\n prop = '';\n\n\tif (!result) {\n\t for (prop in types) {\n\t if (schemas[prop].name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n\n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n \n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system !== 'undefined':\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && typeof system !== 'undefined':\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && typeof system !== 'undefined':\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && typeof system !== 'undefined' && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n default:\n break;\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin', \n template.source().replace(/{{message}}/gi, message));\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom) {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (typeof system === 'undefined') {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"t15f921e6a316234":{"_id":"t15f921e6a316234","component":"udbc51200e11z03","state":"click","action":"function click() { \n $('#designer-toolbar-item-copy').tooltip('hide');\n this.require('editor').copy(); \n this.require('message').success('The text has been copied to the clipboard.');\n}"},"d10e191ee9813950":{"_id":"d10e191ee9813950","component":"udbc51200e11z04","state":"click","action":"function click() { \n $('#designer-toolbar-item-paste').tooltip('hide');\n this.require('editor').paste(); \n}"},"i1a1951779613207":{"_id":"i1a1951779613207","component":"udbc51200e11z02","state":"click","action":"function click() { \n $('#designer-toolbar-item-select-all').tooltip('hide');\n this.require('editor').selectAll(); \n}"},"d1d8ee1ac3812186":{"_id":"d1d8ee1ac3812186","component":"udbc51200e11z01","state":"click","action":"function click() { \n $('#designer-toolbar-item-redo').tooltip('hide');\n this.require('editor').redo(); \n}"},"i15954170f111203":{"_id":"i15954170f111203","component":"udbc51200e11z00","state":"click","action":"function click() { \n $('#designer-toolbar-item-undo').tooltip('hide');\n this.require('editor').undo(); \n}"},"y1dbc0114c11c791":{"_id":"y1dbc0114c11c791","component":"1dbc51200e116e9","state":"click","action":"function click() {\n $('#designer-toolbar-item-save').tooltip('hide');\n this.require('designer').save(); \n}"},"j1ac7610be61012b":{"_id":"j1ac7610be61012b","component":"1dbc51200e11615","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n this.require('designer').open('https://system-designer.readme.io/docs/edit-a-model', '_blank', true); \n}"},"g161d21f3a912625":{"_id":"g161d21f3a912625","component":"1dbc51200e11610","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"d1802118f46183c0":{"_id":"d1802118f46183c0","component":"Workspace","state":"render","action":"function render() { \n var Editor = null,\n designer = null,\n editor = null;\n\n Editor = this.require('Editor');\n designer = this.require('designer');\n\n if (designer.isCordova()) {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'codemirror',\n 'context': 'model',\n 'editor': CodeMirror($('#designer-editor')[0], {\n lineNumbers: true,\n styleActiveLine: true,\n 'mode': 'application/json',\n 'theme': 'eclipse',\n 'tabSize': 2,\n 'autoCloseBrackets': true\n })\n });\n } else {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'ace',\n 'context': 'model',\n 'editor': ace.edit('designer-editor')\n });\n }\n \n editor.render();\n}","useCoreAPI":false,"core":false},"x1cd3e156f81600f":{"_id":"x1cd3e156f81600f","component":"Designer","state":"render","action":"function render() {\n var systemId = '',\n system = null,\n sys = null,\n id = '',\n modelName = '',\n modelGen = null;\n\n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1].split('?')[0]);\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n\n // get parameters\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n \n // set system\n system = this.require('storage').get(systemId);\n sys = this.require('factory').create(system);\n \n // extensions\n this.installExtensions();\n\n // render\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('workspace').render();\n \n // set editor\n system = this.require('storage').get(systemId);\n model = system.models[id];\n\n this.require('store').uuid(id);\n this.require('store').data(model);\n\n modelName = system.models[id]._name;\n modelGen = this.require('factory').getGeneratedModel(modelName);\n this.require('store').extra(modelGen);\n\n document.title = 'model ' + model._name + ' · system ' + system.name;\n\n this.require('editor').initValue(JSON.stringify(model, null, '\\t'), 2);\n\n this.require('router').update();\n \n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"s1bc6b11e9a13afd":{"_id":"s1bc6b11e9a13afd","component":"Designer","state":"save","action":"function save() { \n var val = this.require('editor').getValue(),\n designer = this.require('designer'),\n message = this.require('message'),\n model = null,\n property = '',\n modelGen = null,\n hasError = false;\n\n try {\n model = JSON.parse(val);\n } catch (e) {\n message.danger('Can not save your model: your model has an invalid structure.');\n return;\n }\n \n \n // _inherit check\n if (typeof model._inherit !== 'undefined' && !Array.isArray(model._inherit)) {\n message.danger('Invalid inheritance value: it must be an array.');\n return;\n }\n \n if (model._inherit && model._inherit.indexOf(model._name) !== -1) {\n message.danger('Invalid inheritance value: you can not inherit from yourself.');\n return;\n }\n \n if (model._inherit && model._inherit.indexOf('') !== -1) {\n message.danger('Invalid inheritance value: it can not be empty.');\n return;\n }\n\n if (model._inherit) {\n model._inherit.forEach(function (parent) {\n if (parent.constructor.name !== 'String') {\n hasError = true;\n }\n });\n if (hasError) {\n message.danger('Invalid inheritance value: it must be a string.');\n return;\n }\n }\n\n // _name check\n if (typeof model._name === 'undefined') {\n message.danger('The property \\'_name\\' is missing.');\n return;\n }\n \n if (model._name.constructor.name !== 'String') {\n message.danger('The property \\'_name\\' must be a string.');\n return;\n }\n \n // clean name\n model._name = model._name.replace(/\\s|\\t/gi, '_')\n .replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '')\n .replace(/\\r|\\n/gi,'');\n\n // _id check\n if (typeof model._id === 'undefined') {\n message.danger('The property \\'_id\\' is missing.');\n return;\n }\n \n if (model._id.constructor.name !== 'String') {\n message.danger('The property \\'_id\\' must be a string.');\n return;\n }\n\n for (property in model) {\n if (property.indexOf(' ') !== -1) {\n message.danger('Invalid property name \\'' + property + '\\’.
    Space is not authorized in the name of a property.');\n return;\n }\n propVal = model[property];\n if (typeof propVal === 'object' && !Array.isArray(propVal) && property.indexOf('_') === 0) {\n message.danger('Invalid property name \\'' + property + '\\’.
    A property name can not start with \\'_\\'.');\n return;\n }\n if (property.indexOf('_') === 0) {\n if (['_id', '_name', '_inherit', '_class', '_core', '_description'].indexOf(property) === -1) {\n message.danger('Invalid value \\'' + property + '\\’.
    Authorized values are: \\'_id\\', \\'_name\\', \\'_inherit\\', \\'_class\\', \\'_core\\' and \\'_description\\'.');\n return;\n }\n }\n }\n\n modelGen = this.require('store').extra();\n for (property in model) {\n if (property.indexOf('_') !== 0 && typeof modelGen[property] === 'undefined') {\n message.danger('Invalid property name \\'' + property + '\\’.
    \\'' + property + '\\’ must be defined in the schema.');\n return;\n }\n }\n\n if (this.require('store').data()._name === model._name) {\n this.require('store').data(model);\n\n // check if ID change\n if (this.require('store').uuid() !== this.require('store').data()._id) {\n this.require('channel').$editorUpdateModelId(this.require('store').uuid(), this.require('store').data()._id);\n this.require('store').uuid(this.require('store').data()._id);\n }\n\n this.require('channel').$editorUpdateModel(this.require('store').uuid(), this.require('store').data());\n message.success('Model saved.');\n } else {\n message.danger('You can not modify the name of a model.');\n }\n}","useCoreAPI":false,"core":false},"z1b1ad1fdbb1a46a":{"_id":"z1b1ad1fdbb1a46a","component":"w1a78b16d7311831","state":"start","action":"function start() { \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"t12f1412dc71b53b":{"_id":"t12f1412dc71b53b","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n href = '';\n\n id = decodeURIComponent(document.location.href.split('#')[1]);\n collection = document.location.href.split('#')[2];\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1];\n menubar[i].href = '#' + id + '#' + collection + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"q1db4d1ae7a19ae6":{"_id":"q1db4d1ae7a19ae6","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state');\n\n if (designer.isCordova()) {\n state.messages().push(message);\n }\n\n this.require('storage').set('system-designer-message', message);\n\n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\n}","useCoreAPI":false,"core":false},"m193c119f111fd88":{"_id":"m193c119f111fd88","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function changed(obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":false,"core":false},"s1a154168ce17fa9":{"_id":"s1a154168ce17fa9","component":"o1f40e168bd10174","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"c1e34c13e6b10bd9":{"_id":"c1e34c13e6b10bd9","component":"m1ff0113f491d841","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"f1c23c1dcb0122a3":{"_id":"f1c23c1dcb0122a3","component":"Designer","state":"addShortcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component","diagram"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"2.9.0"}},"Diagram":{},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.1.1","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1d113198721599d":{"_id":"l1d113198721599d","_name":"MenuItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"u1f9a01abe31b3bf":{"_id":"u1f9a01abe31b3bf","_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"menuitem-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"name":{"type":"string","readOnly":false,"mandatory":false,"default":"template"},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"},"render":{},"click":{}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() { \n\tvar name = $('#modal-modeljson-name').val(),\n\t jsonText = $('#modal-modeljson-json').val(),\n\t json = null,\n\t schema = {},\n\t model = {},\n\t property = '',\n\t type = '',\n\t typeName = '',\n\t arrayType = '',\n\t that = this,\n\t createdTypes = [];\n\t \n\tfunction _getTypeName(parent, name) {\n\t var result = name;\n\t \n\t if (!_validType(name)) {\n\t if (parent) {\n\t result = parent + '_' + name;\n\t } else {\n\t result = name + Math.floor(Math.random() * 11);\n\t }\n\t }\n\t \n\t return result;\n\t} \n\n function _getType(value) {\n var type = '';\n \n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n \n return type;\n } \n \n function _validName(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n } \n \n function _validType(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n return result;\n } \n \n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = ''; \n \n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false); \n \n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n switch (type) {\n case 'object':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = {};\n break;\n case 'number':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'number';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = 0;\n break;\n case 'boolean':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'boolean';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = false;\n break;\n case 'array':\n typeDef.schema[property] = {};\n typeDef.schema[property].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n \n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n \t typeDef.schema[property].type = [_createTypeFromObject(name, property, obj[property][0])];\n \t typeDef.schema[property].default = [];\n \t } else {\n \t typeDef.schema[property].type = ['object'];\n \t typeDef.schema[property].default = [];\n \t }\n } else {\n typeDef.schema[property].type = [arrayType];\n typeDef.schema[property].default = [];\n }\n } else {\n typeDef.schema[property].type = ['any'];\n typeDef.schema[property].default = [];\n\t }\n break;\n default:\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'string';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n \n return typeName;\n }\n \n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n\tif (name && _validName(name) && jsonText) {\n\t try {\n\t json = JSON.parse(jsonText);\n\t if (json) {\n\t // schema\n\t schema = this.require('factory').addSchema(name.trim());\n\t \n\t schema._inherit = [];\n\t this.require('factory').updateSchema(schema._id, schema);\n\t \n\t this.require('designer').save();\n\t \n\t for (property in json) {\n\t if (property.indexOf('_') !== 0) {\n \t type = _getType(json[property]);\n \t if (type === 'array') {\n \t schema[property] = 'collection';\n \t } else {\n \t schema[property] = 'property';\n \t }\n\t }\n\t }\n\t \n\t this.require('factory').updateSchema(schema._id, schema);\n\t this.require('designer').save();\n\t \n\t // model\n\t model = this.require('factory').createModel(schema);\n\t this.require('designer').save();\n\n\t for (property in schema) {\n\t if (property.indexOf('_') !== 0) {\n\t type = _getType(json[property]);\n\t switch (type) {\n\t case 'object':\n\t if (json[property] !== null) {\n\t model[property].type = _createTypeFromObject('', property, json[property]);\n\t model[property].default = {};\n\t } else {\n\t model[property].type = 'object';\n\t model[property].default = {};\n\t }\n\t break;\n\t case 'number':\n\t model[property].type = 'number';\n\t model[property].default = 0;\n\t break;\n\t case 'boolean':\n\t model[property].type = 'boolean';\n\t model[property].default = false;\n\t break;\n\t case 'array':\n\t if (typeof json[property][0] !== 'undefined') {\n\t arrayType = _getType(json[property][0]);\n\t if (arrayType === 'object') {\n\t if (json[property][0] !== null) {\n \t model[property].type = [_createTypeFromObject('', property, json[property][0])];\n \t model[property].default = [];\n \t } else {\n \t model[property].type = ['object'];\n \t model[property].default = [];\n \t }\n\t } else {\n\t model[property].type = [arrayType];\n\t model[property].default = [];\n\t }\n\t } else {\n\t model[property].type = ['any'];\n\t model[property].default = [];\n\t }\n\t break;\n\t \tcase 'string':\n\t model[property].type = 'string';\n\t model[property].default = '';\n\t break;\n\t default:\n\t break;\n\t }\n\t }\n\t }\n\t \n\t this.require('factory').updateModel(model._id, model);\n\t this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\t \n\t this.require('message').success('A model has been created for the JSON.');\n\t }\n\t } catch(e) {\n\t this.hide();\n\t this.require('message').warning('Can not create the model: the JSON is invalid.');\n\t }\n\t} \n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"MenuItem":{},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2018 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v2.9.0"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"A behavior is the action to do when a method or an event is called."},"help-components.html":{"_id":"help-components.html","source":"Components are your classes instances. Their states are saved in a store, a JSON object."},"help-logs.html":{"_id":"help-logs.html","source":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "},"help-models.html":{"_id":"help-models.html","source":"A model is an UML representation of your classes. It is generated from a schema."},"help-schemas.html":{"_id":"help-schemas.html","source":"A schema is the definition of your model. Models are generated based on the schema definition."},"help-system.html":{"_id":"help-system.html","source":"An application is a system. Once you have created one, your next step is to create a schema."},"help-types.html":{"_id":"help-types.html","source":"A type is used in your model to define an enumeration or a structure."},"menu-action-search.html":{"_id":"menu-action-search.html","source":"
    \n
    \n \n
    \n
    "},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-guide.html":{"_id":"menu-item-guide.html","source":"Guide"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs0"},"menu-item-message-save.html":{"_id":"menu-item-message-save.html","source":" file saved!"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-quick-start.html":{"_id":"menu-item-quick-start.html","source":"Quick Start"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"},"toolbar-item-diagram.html":{"_id":"toolbar-item-diagram.html","source":""},"menu-item-diagram.html":{"_id":"menu-item-diagram.html","source":"Class diagram"},"toolbar-item-zoomout.html":{"_id":"toolbar-item-zoomout.html","source":""},"toolbar-item-zoomin.html":{"_id":"toolbar-item-zoomin.html","source":""},"toolbar-item-zoominit.html":{"_id":"toolbar-item-zoominit.html","source":""},"toolbar-item-export-diagram.html":{"_id":"toolbar-item-export-diagram.html","source":""}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.0.0","description":"Quick start\n\nThis system is taken from the quick start: https://system-designer.readme.io/docs/quick-start","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n var luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n var result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vador":{"_id":"vador","father":"","firstName":"Dark","lastName":"Vador"},"luke":{"_id":"luke","father":"vador","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"04-send-messages.json":{"_id":"04-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.0.0","description":"Send messages threw a channel\n\n\nYou can send messages from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. In '_Channel' 'send' method, define how to send the message to another channel (webRTC, XHR, ...).\n3. In another system, define how to get the message and send it to the system with: runtime.message().\n4. To send a message: this.require('channel').myevent(param1, param2, ...).\n5. To listen to the message, just add a behavior to the event.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.0.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"type":"css","readOnly":false,"mandatory":false,"default":""},"render":{}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{},"filter":{"type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n var html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n var div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n var items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n var author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.0.1","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n var http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"04-create-extension.json":{"_id":"04-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.1.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"05-listen-collection-events.json":{"_id":"05-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.0.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""},"field":{"type":"string","mandatory":true,"default":""},"value":{"type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"document":{"type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179bh":{"_id":"1f8571164c179bh","html":"menu-action-version.html","position":10,"type":"model"}},"MenuHeader":{"1fb101b99813a16":{"_id":"1fb101b99813a16","html":"menu-header-model.html","type":"model"}},"MenuItem":{"1f1781882618108":{"_id":"1f1781882618108","name":"model","html":"menu-item-model.html","position":10,"type":"model","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"udbc51200e11z03":{"_id":"udbc51200e11z03","html":"toolbar-item-copy.html","position":50,"type":"model","platform":"electron"},"udbc51200e11z04":{"_id":"udbc51200e11z04","html":"toolbar-item-paste.html","position":60,"type":"model","platform":"electron"},"1dbc51200e11610":{"_id":"1dbc51200e11610","html":"toolbar-item-copyright.html","position":90,"type":"model","platform":"all"},"1dbc51200e11615":{"_id":"1dbc51200e11615","html":"toolbar-item-help.html","position":80,"type":"model","platform":"all"},"1dbc51200e116e9":{"_id":"1dbc51200e116e9","html":"toolbar-item-save.html","position":10,"type":"model","platform":"all"},"udbc51200e11z00":{"_id":"udbc51200e11z00","html":"toolbar-item-undo.html","position":20,"type":"model","platform":"all"},"udbc51200e11z01":{"_id":"udbc51200e11z01","html":"toolbar-item-redo.html","position":30,"type":"model","platform":"all"},"udbc51200e11z02":{"_id":"udbc51200e11z02","html":"toolbar-item-select-all.html","position":40,"type":"model","platform":"all"},"o1f40e168bd10174":{"_id":"o1f40e168bd10174","html":"toolbar-item-command.html","platform":"web","position":75,"type":"model"},"m1ff0113f491d841":{"_id":"m1ff0113f491d841","html":"toolbar-item-command.html","platform":"electron","position":75,"type":"model"}}},"_id":"w1a78b16d7311831"}); \ No newline at end of file diff --git a/designer/scripts/editor-schema.js b/designer/scripts/editor-schema.js index 5a7eed7..01a57ec 100644 --- a/designer/scripts/editor-schema.js +++ b/designer/scripts/editor-schema.js @@ -1,3 +1,3 @@ // System Designer - Copyright 2018 Erwan Carriou // Licensed under the Apache License, Version 2.0 (the "License") -runtime.install({"name":"editor-schema","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"]},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"2.8.3"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"addShortcuts":{}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}]}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":false}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57"},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null;\n \n if (extension.installed) { \n system = extension.source;\n \n try {\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n } catch (e) {\n this.require('message').danger('Can not install an extension.');\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n\n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').hide();\n }\n } else {\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').show();\n }\n }\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-file').attr('checked', false);\n $('#designer-dialog-import-modal-from-library').attr('checked', true);\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n that.data(JSON.parse(json));\n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').uninstall('ext_' + system._id)\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n downloadLink.click();\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n if (system.name === name) {\n result = false;\n break;\n }\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n \n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"snippet\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'snippet' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'snippet' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'snippet' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'snippet' });\n }\n \n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n \n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n \n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n \n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n \n // snippets\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet:'{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'snippet' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n \n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"snippet\" });\n }\n \n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n \n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n \n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n \n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n \n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n\n repo1.writeFile('master', system.name + '.json', JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html', htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js', jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^2.8.4';\n\n repo4.writeFile('master', 'package.json', JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.source());\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n \n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n });\n\n menuActions.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('afterbegin', '
  • ' + action.html().source() + '');\n });\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n this.require('state').messages(messages);\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n for (propName in this.document().schema) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n }\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n\n systemId = this.require('factory').system().id();\n schema = _getSchema(this.model());\n model = _getModel(this.model());\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = this.document()[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n if (modelName === '_Component') {\n modelName = _getModelFromComponent(propVal);\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n function gen() {\n return Math.floor((1 + Math.random()) * 0x10000).toString(16);\n }\n function getPrefix() {\n var validPrefix = 'abcdefghijklmnopqrstuvwxyz';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return getPrefix() + gen() + gen() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n\n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n \n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system !== 'undefined':\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && typeof system !== 'undefined':\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && typeof system !== 'undefined':\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && typeof system !== 'undefined' && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n default:\n break;\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin', \n template.source().replace(/{{message}}/gi, message));\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom) {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (typeof system === 'undefined') {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"d10d6e1b5571c73b":{"_id":"d10d6e1b5571c73b","component":"tdbc51200e11z03","state":"click","action":"function click() { \n $('#designer-toolbar-item-copy').tooltip('hide');\n this.require('editor').copy(); \n}"},"m17c7d1483011aa2":{"_id":"m17c7d1483011aa2","component":"tdbc51200e11z04","state":"click","action":"function click() { \n $('#designer-toolbar-item-paste').tooltip('hide');\n this.require('editor').paste(); \n}"},"y19bc51629a15aca":{"_id":"y19bc51629a15aca","component":"tdbc51200e11z02","state":"click","action":"function click() { \n $('#designer-toolbar-item-select-all').tooltip('hide');\n this.require('editor').selectAll(); \n}"},"p150db1b77d11ba1":{"_id":"p150db1b77d11ba1","component":"tdbc51200e11z01","state":"click","action":"function click() { \n $('#designer-toolbar-item-redo').tooltip('hide');\n this.require('editor').redo(); \n}"},"h1c4c115aa81281f":{"_id":"h1c4c115aa81281f","component":"tdbc51200e11z00","state":"click","action":"function click() { \n $('#designer-toolbar-item-undo').tooltip('hide');\n this.require('editor').undo(); \n}"},"f14706139781d16b":{"_id":"f14706139781d16b","component":"1dbc51200e116e8","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"w1e52a173f31d0da":{"_id":"w1e52a173f31d0da","component":"1dbc51200e116e7","state":"click","action":"function click() {\n $('#designer-toolbar-item-save').tooltip('hide');\n this.require('designer').save();\n}"},"e1bb25114121f519":{"_id":"e1bb25114121f519","component":"1dbc51200e11510","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n this.require('designer').open('https://system-designer.readme.io/docs/create-a-schema', '_blank', true); \n}"},"b18fab15f501e117":{"_id":"b18fab15f501e117","component":"Workspace","state":"render","action":"function render() { \n var Editor = null,\n designer = null,\n editor = null;\n\n Editor = this.require('Editor');\n designer = this.require('designer');\n\n if (designer.isCordova()) {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'codemirror',\n 'context': 'schema',\n 'editor': CodeMirror($('#designer-editor')[0], {\n lineNumbers: true,\n styleActiveLine: true,\n 'mode': 'application/json',\n 'theme': 'eclipse',\n 'tabSize': 2,\n 'autoCloseBrackets': true\n })\n });\n } else {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'ace',\n 'context': 'schema',\n 'editor': ace.edit('designer-editor')\n });\n }\n \n editor.render();\n}","useCoreAPI":false,"core":false},"b105d21fac11b017":{"_id":"b105d21fac11b017","component":"Designer","state":"render","action":"function render() {\n var id = '',\n systemId = '',\n system = null,\n schema = null;\n \n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1]);\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n\n // render\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('workspace').render();\n \n // get parameters\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n // set editor\n system = this.require('storage').get(systemId);\n \n this.require('factory').create(system);\n \n // extensions\n this.installExtensions();\n \n schema = system.schemas[id];\n\n this.require('store').uuid(id);\n this.require('store').data(schema);\n\n document.title = 'schema ' + schema._name + ' · system ' + system.name;\n\n this.require('editor').initValue(JSON.stringify(schema, null, '\\t'), 2);\n\n // router\n this.require('router').update();\n \n // shorcuts\n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"u102ee100eb1fb61":{"_id":"u102ee100eb1fb61","component":"Designer","state":"save","action":"function save() { \n var val = this.require('editor').getValue(),\n designer = this.require('designer'),\n message = this.require('message'),\n schema = null,\n property = '',\n propVal = '',\n hasError = false;\n\n try {\n schema = JSON.parse(val);\n } catch (e) {\n message.danger('Can not save your schema: your schema has an invalid structure.');\n return;\n }\n \n // global properties check\n for (property in schema) {\n if (schema.hasOwnProperty(property) && property.indexOf('_') !== 0) {\n propVal = schema[property];\n if (['property', 'link', 'collection', 'event', 'method'].indexOf(propVal) === -1) {\n message.danger('Invalid value for the property \\'' + property + '\\’.
    Authorized values are: \\'property\\', \\'link\\', \\'collection\\', \\'event\\' and \\'method\\'.');\n return;\n }\n }\n }\n \n for (property in schema) {\n if (schema.hasOwnProperty(property) && property.indexOf('_') === 0) {\n if (['_id', '_name', '_inherit', '_class', '_core', '_description'].indexOf(property) === -1) {\n message.danger('Invalid value \\'' + property + '\\’.
    Authorized values are: \\'_id\\', \\'_name\\', \\'_inherit\\', \\'_class\\', \\'_core\\' and \\'_description\\'.');\n return;\n }\n }\n }\n\n for (property in schema) {\n if (property.indexOf(' ') !== -1) {\n message.danger('Invalid property name \\'' + property + '\\’.
    Space is not authorized in the name of a property.');\n return;\n }\n propVal = schema[property];\n if (['property', 'link', 'collection', 'event', 'method'].indexOf(propVal) !== -1 && property.indexOf('_') === 0) {\n message.danger('Invalid property name \\'' + property + '\\’.
    A property name can not start with \\'_\\'.');\n return;\n }\n }\n \n // _inherit check\n if (typeof schema._inherit !== 'undefined' && !Array.isArray(schema._inherit)) {\n message.danger('Invalid inheritance value: it must be an array.');\n return;\n }\n \n if (schema._inherit && schema._inherit.indexOf(schema._name) !== -1) {\n message.danger('Invalid inheritance value: you can not inherit from yourself.');\n return;\n }\n \n if (schema._inherit && schema._inherit.indexOf('') !== -1) {\n message.danger('Invalid inheritance value: it can not be empty.');\n return;\n }\n\n if (schema._inherit) {\n schema._inherit.forEach(function (parent) {\n if (parent.constructor.name !== 'String') {\n hasError = true;\n }\n });\n if (hasError) {\n message.danger('Invalid inheritance value: it must be a string.');\n return;\n }\n }\n\n // _name check\n if (typeof schema._name === 'undefined') {\n message.danger('The property \\'_name\\' is missing.');\n return;\n }\n \n if (schema._name.constructor.name !== 'String') {\n message.danger('The property \\'_name\\' must be a string.');\n return;\n }\n\n // _id check\n if (typeof schema._id === 'undefined') {\n message.danger('The property \\'_id\\' is missing.');\n return;\n }\n \n if (schema._id.constructor.name !== 'String') {\n message.danger('The property \\'_id\\' must be a string.');\n return;\n }\n \n // clean name\n schema._name = schema._name.replace(/\\s|\\t/gi, '_')\n .replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '')\n .replace(/\\r|\\n/gi,'');\n\n // check if _name had changed\n if (this.require('store').data()._name !== schema._name) {\n this.require('channel').$editorUpdateSchemaName(schema._name, this.require('store').uuid());\n document.title = 'schema ' + schema._name + ' · ' + document.title.split('·')[1].trim();\n }\n\n this.require('store').data(schema);\n\n // check if _id has changed\n if (this.require('store').uuid() !== this.require('store').data()._id) {\n this.require('channel').$editorUpdateSchemaId(this.require('store').uuid(), this.require('store').data()._id);\n this.require('store').uuid(this.require('store').data()._id);\n }\n\n this.require('channel').$editorUpdateSchema(this.require('store').uuid(), this.require('store').data());\n message.success('Schema saved.');\n}","useCoreAPI":false,"core":false},"k171ad182081ca3c":{"_id":"k171ad182081ca3c","component":"l1ffcf1761317c7b","state":"start","action":"function start() { \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"q16ab5185c81f37d":{"_id":"q16ab5185c81f37d","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n href = '';\n\n id = decodeURIComponent(document.location.href.split('#')[1]);\n collection = document.location.href.split('#')[2];\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1];\n menubar[i].href = '#' + id + '#' + collection + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"t1e0be117b312cf0":{"_id":"t1e0be117b312cf0","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state'),\n system = {};\n \n if (designer.isCordova()) {\n state.messages().push(message);\n }\n\n this.require('storage').set('system-designer-message', message);\n\n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\t\n}","useCoreAPI":false,"core":false},"i12aee1bd7815e89":{"_id":"i12aee1bd7815e89","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function (obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":false,"core":false},"l178f0159e514a91":{"_id":"l178f0159e514a91","component":"p13d881c2fe174bd","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"y1c98019d4c1d53c":{"_id":"y1c98019d4c1d53c","component":"u1c5aa1b25d1e8e5","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"i1596a1f6141603b":{"_id":"i1596a1f6141603b","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar result = {};\n\treturn result;\n}","useCoreAPI":false,"core":false},"g1d47010c7e1904c":{"_id":"g1d47010c7e1904c","component":"Designer","state":"addShortcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"2.8.3"}},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.1.1","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1d113198721599d":{"_id":"l1d113198721599d","_name":"MenuItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"u1f9a01abe31b3bf":{"_id":"u1f9a01abe31b3bf","_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"menuitem-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"name":{"type":"string","readOnly":false,"mandatory":false,"default":"template"},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"},"render":{},"click":{}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() { \n\tvar name = $('#modal-modeljson-name').val(),\n\t jsonText = $('#modal-modeljson-json').val(),\n\t json = null,\n\t schema = {},\n\t model = {},\n\t property = '',\n\t type = '',\n\t typeName = '',\n\t arrayType = '',\n\t that = this,\n\t createdTypes = [];\n\t \n\tfunction _getTypeName(parent, name) {\n\t var result = name;\n\t \n\t if (!_validType(name)) {\n\t if (parent) {\n\t result = parent + '_' + name;\n\t } else {\n\t result = name + Math.floor(Math.random() * 11);\n\t }\n\t }\n\t \n\t return result;\n\t} \n\n function _getType(value) {\n var type = '';\n \n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n \n return type;\n } \n \n function _validName(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n } \n \n function _validType(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n return result;\n } \n \n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = ''; \n \n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false); \n \n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n switch (type) {\n case 'object':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = {};\n break;\n case 'number':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'number';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = 0;\n break;\n case 'boolean':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'boolean';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = false;\n break;\n case 'array':\n typeDef.schema[property] = {};\n typeDef.schema[property].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n \n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n \t typeDef.schema[property].type = [_createTypeFromObject(name, property, obj[property][0])];\n \t typeDef.schema[property].default = [];\n \t } else {\n \t typeDef.schema[property].type = ['object'];\n \t typeDef.schema[property].default = [];\n \t }\n } else {\n typeDef.schema[property].type = [arrayType];\n typeDef.schema[property].default = [];\n }\n } else {\n typeDef.schema[property].type = ['any'];\n typeDef.schema[property].default = [];\n\t }\n break;\n default:\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'string';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n \n return typeName;\n }\n \n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n\tif (name && _validName(name) && jsonText) {\n\t try {\n\t json = JSON.parse(jsonText);\n\t if (json) {\n\t // schema\n\t schema = this.require('factory').addSchema(name.trim());\n\t \n\t schema._inherit = [];\n\t this.require('factory').updateSchema(schema._id, schema);\n\t \n\t this.require('designer').save();\n\t \n\t for (property in json) {\n\t if (property.indexOf('_') !== 0) {\n \t type = _getType(json[property]);\n \t if (type === 'array') {\n \t schema[property] = 'collection';\n \t } else {\n \t schema[property] = 'property';\n \t }\n\t }\n\t }\n\t \n\t this.require('factory').updateSchema(schema._id, schema);\n\t this.require('designer').save();\n\t \n\t // model\n\t model = this.require('factory').createModel(schema);\n\t this.require('designer').save();\n\n\t for (property in schema) {\n\t if (property.indexOf('_') !== 0) {\n\t type = _getType(json[property]);\n\t switch (type) {\n\t case 'object':\n\t if (json[property] !== null) {\n\t model[property].type = _createTypeFromObject('', property, json[property]);\n\t model[property].default = {};\n\t } else {\n\t model[property].type = 'object';\n\t model[property].default = {};\n\t }\n\t break;\n\t case 'number':\n\t model[property].type = 'number';\n\t model[property].default = 0;\n\t break;\n\t case 'boolean':\n\t model[property].type = 'boolean';\n\t model[property].default = false;\n\t break;\n\t case 'array':\n\t if (typeof json[property][0] !== 'undefined') {\n\t arrayType = _getType(json[property][0]);\n\t if (arrayType === 'object') {\n\t if (json[property][0] !== null) {\n \t model[property].type = [_createTypeFromObject('', property, json[property][0])];\n \t model[property].default = [];\n \t } else {\n \t model[property].type = ['object'];\n \t model[property].default = [];\n \t }\n\t } else {\n\t model[property].type = [arrayType];\n\t model[property].default = [];\n\t }\n\t } else {\n\t model[property].type = ['any'];\n\t model[property].default = [];\n\t }\n\t break;\n\t \tcase 'string':\n\t model[property].type = 'string';\n\t model[property].default = '';\n\t break;\n\t default:\n\t break;\n\t }\n\t }\n\t }\n\t \n\t this.require('factory').updateModel(model._id, model);\n\t this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\t \n\t this.require('message').success('A model has been created for the JSON.');\n\t }\n\t } catch(e) {\n\t this.hide();\n\t this.require('message').warning('Can not create the model: the JSON is invalid.');\n\t }\n\t} \n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"MenuItem":{},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2018 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v2.8.3"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"A behavior is the action to do when a method or an event is called."},"help-components.html":{"_id":"help-components.html","source":"Components are your classes instances. Their states are saved in a store, a JSON object."},"help-logs.html":{"_id":"help-logs.html","source":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "},"help-models.html":{"_id":"help-models.html","source":"A model is an UML representation of your classes. It is generated from a schema."},"help-schemas.html":{"_id":"help-schemas.html","source":"A schema is the definition of your model. Models are generated based on the schema definition."},"help-system.html":{"_id":"help-system.html","source":"An application is a system. Once you have created one, your next step is to create a schema."},"help-types.html":{"_id":"help-types.html","source":"A type is used in your model to define an enumeration or a structure."},"menu-action-search.html":{"_id":"menu-action-search.html","source":"
    \n
    \n \n
    \n
    "},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-guide.html":{"_id":"menu-item-guide.html","source":"Guide"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs"},"menu-item-message-save.html":{"_id":"menu-item-message-save.html","source":" file saved!"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-quick-start.html":{"_id":"menu-item-quick-start.html","source":"Quick Start"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.0.0","description":"Quick start\n\nThis system is taken from the quick start: https://system-designer.readme.io/docs/quick-start","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n var luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n var result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vador":{"_id":"vador","father":"","firstName":"Dark","lastName":"Vador"},"luke":{"_id":"luke","father":"vador","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"04-send-messages.json":{"_id":"04-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.0.0","description":"Send messages threw a channel\n\n\nYou can send messages from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. In '_Channel' 'send' method, define how to send the message to another channel (webRTC, XHR, ...).\n3. In another system, define how to get the message and send it to the system with: runtime.message().\n4. To send a message: this.require('channel').myevent(param1, param2, ...).\n5. To listen to the message, just add a behavior to the event.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.0.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"type":"css","readOnly":false,"mandatory":false,"default":""},"render":{}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{},"filter":{"type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n var html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n var div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n var items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n var author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.0.1","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n var http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"04-create-extension.json":{"_id":"04-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.1.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"05-listen-collection-events.json":{"_id":"05-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.0.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""},"field":{"type":"string","mandatory":true,"default":""},"value":{"type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"document":{"type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179bg":{"_id":"1f8571164c179bg","html":"menu-action-version.html","position":10,"type":"schema"}},"MenuHeader":{"1fb101b99813a15":{"_id":"1fb101b99813a15","html":"menu-header-schema.html","type":"schema"}},"MenuItem":{"1f1781882618106":{"_id":"1f1781882618106","name":"schema","html":"menu-item-schema.html","position":10,"type":"schema","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"tdbc51200e11z03":{"_id":"tdbc51200e11z03","html":"toolbar-item-copy.html","position":50,"type":"schema","platform":"electron"},"tdbc51200e11z04":{"_id":"tdbc51200e11z04","html":"toolbar-item-paste.html","position":60,"type":"schema","platform":"electron"},"1dbc51200e11510":{"_id":"1dbc51200e11510","html":"toolbar-item-help.html","position":80,"type":"schema","platform":"all"},"1dbc51200e116e7":{"_id":"1dbc51200e116e7","html":"toolbar-item-save.html","position":10,"type":"schema","platform":"all"},"1dbc51200e116e8":{"_id":"1dbc51200e116e8","html":"toolbar-item-copyright.html","position":90,"type":"schema","platform":"all"},"tdbc51200e11z00":{"_id":"tdbc51200e11z00","html":"toolbar-item-undo.html","position":20,"type":"schema","platform":"all"},"tdbc51200e11z01":{"_id":"tdbc51200e11z01","html":"toolbar-item-redo.html","position":30,"type":"schema","platform":"all"},"tdbc51200e11z02":{"_id":"tdbc51200e11z02","html":"toolbar-item-select-all.html","position":40,"type":"schema","platform":"all"},"p13d881c2fe174bd":{"_id":"p13d881c2fe174bd","html":"toolbar-item-command.html","platform":"web","position":75,"type":"schema"},"u1c5aa1b25d1e8e5":{"_id":"u1c5aa1b25d1e8e5","html":"toolbar-item-command.html","platform":"electron","position":75,"type":"schema"}}},"_id":"l1ffcf1761317c7b"}); \ No newline at end of file +runtime.install({"name":"editor-schema","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"v123b51abbb18712":{"_id":"v123b51abbb18712","_name":"Diagram","_inherit":["_Component"],"ref":"property","zoom":"property","render":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method","toGraphviz":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","isType":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"]},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"2.9.0"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"addShortcuts":{}},"b169321637f19101":{"_id":"b169321637f19101","_name":"Diagram","_description":"","ref":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""},"zoom":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":1},"render":{"description":"","params":[],"result":"any"}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toGraphviz":{"description":"","params":[],"result":"string"}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":false}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57"},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"},"isType":{"description":"","params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null;\n \n if (extension.installed) { \n system = extension.source;\n \n try {\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n } catch (e) {\n this.require('message').danger('Can not install an extension.');\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n\n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').hide();\n }\n } else {\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').show();\n }\n }\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-file').attr('checked', false);\n $('#designer-dialog-import-modal-from-library').attr('checked', true);\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n that.data(JSON.parse(json));\n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-export-graphviz');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').uninstall('ext_' + system._id)\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-graphviz').prop('checked'):\n textToWrite = this.require('export').toGraphviz();\n fileNameToSaveAs = this.require('factory').system().name() + '.gv';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n downloadLink.click();\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n if (system.name === name) {\n result = false;\n break;\n }\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n \n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"snippet\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'snippet' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'snippet' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'snippet' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'snippet' });\n }\n \n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n \n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n \n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n \n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n \n // snippets\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet:'{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'snippet' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n \n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"snippet\" });\n }\n \n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n \n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n \n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n \n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n \n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"e13c7916b1a15fc4":{"_id":"e13c7916b1a15fc4","component":"Export","state":"toGraphviz","action":"function toGraphviz() {\n var schemas = this.require('factory').system().schemas();\n var models = this.require('factory').system().models();\n var inheritance = '';\n var modelId = '';\n var modelName = '';\n var modelDescription = '';\n var propName = '';\n var propVal = '';\n var attributes = '';\n var methods = '';\n var result = '';\n var links = '';\n var collections = '';\n var that = this;\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n // create model\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n modelDescription += '\\n\\n\\t' + modelName + ' [\\r\\t\\tlabel = \"{' + modelName + '|';\n \n attributes = '';\n methods = '';\n\n for (propName in models[modelId]) {\n if (models[modelId].hasOwnProperty(propName)) {\n propVal = models[modelId][propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (modelId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (modelId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n }\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n }\n }\n }\n break;\n \n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + params + ' : ' + result + '\\\\l';\n } else {\n methods += '+ ' + propName + params + ' : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + params + '\\\\l';\n } else {\n methods += '+ ' + propName + params + '\\\\l';\n }\n }\n break;\n \n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n \n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + '() : ' + result + '\\\\l';\n } else {\n methods += '+ ' + propName + '() : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + '()\\\\l';\n } else {\n methods += '+ ' + propName + '()\\\\l';\n }\n }\n break;\n }\n }\n }\n\n modelDescription += attributes + '|' + methods;\n modelDescription += '}\"\\r\\t]';\n }\n\n // create inheritance links\n for (var schema in schemas) {\n if (schemas[schema]._inherit && schemas[schema]._inherit.length) {\n schemas[schema]._inherit.forEach(function (parent) {\n inheritance += '\\n\\t' + schemas[schema]._name + ' -> ' + parent;\n });\n }\n }\n \n // case of Component\n if (inheritance.indexOf('_Component') !== -1) {\n modelDescription += `\\n\\t_Component [\n label = \"{_Component|+ id : string\\\\l|+ classInfo() : _ClassInfo\\\\l+ init(conf : object)\\\\l+ destroy()\\\\l+ on(state : string, action : function, useCoreAPI : boolean, isCore : boolean) : string\\\\l+ off(state : string, behaviorId : string)\\\\l+ require(id : string) : _Component\\\\l+ error(data : errorParam)\\\\l}\"\n ]` \n };\n\n let generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n \n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]${modelDescription}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"1\"\n taillabel = \"\"\n ]\n ${links}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"0..*\"\n taillabel = \"\"\n ]\n ${collections}\n\n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n arrowhead = \"empty\"\n headlabel = \"\"\n taillabel = \"\"\n ]\n ${inheritance}\n}`;\n\n return generatedDiagram;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n\n repo1.writeFile('master', system.name + '.json', JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html', htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js', jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^2.9.0';\n\n repo4.writeFile('master', 'package.json', JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.source());\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n \n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n });\n\n menuActions.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('afterbegin', '
  • ' + action.html().source() + '');\n });\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n this.require('state').messages(messages);\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n for (propName in this.document().schema) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n }\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n\n systemId = this.require('factory').system().id();\n schema = _getSchema(this.model());\n model = _getModel(this.model());\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = this.document()[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n if (modelName === '_Component') {\n modelName = _getModelFromComponent(propVal);\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n function gen() {\n return Math.floor((1 + Math.random()) * 0x10000).toString(16);\n }\n function getPrefix() {\n var validPrefix = 'abcdefghijklmnopqrstuvwxyz';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return getPrefix() + gen() + gen() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"v119e617ef513e94":{"_id":"v119e617ef513e94","component":"SystemFactory","state":"isType","action":"function isType(name) { \n var types = this.system().types(),\n result = false,\n prop = '';\n\n\tif (!result) {\n\t for (prop in types) {\n\t if (schemas[prop].name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n\n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n \n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system !== 'undefined':\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && typeof system !== 'undefined':\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && typeof system !== 'undefined':\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && typeof system !== 'undefined' && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n default:\n break;\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin', \n template.source().replace(/{{message}}/gi, message));\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom) {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (typeof system === 'undefined') {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"d10d6e1b5571c73b":{"_id":"d10d6e1b5571c73b","component":"tdbc51200e11z03","state":"click","action":"function click() { \n $('#designer-toolbar-item-copy').tooltip('hide');\n this.require('editor').copy();\n this.require('message').success('The text has been copied to the clipboard.');\n}"},"m17c7d1483011aa2":{"_id":"m17c7d1483011aa2","component":"tdbc51200e11z04","state":"click","action":"function click() { \n $('#designer-toolbar-item-paste').tooltip('hide');\n this.require('editor').paste(); \n}"},"y19bc51629a15aca":{"_id":"y19bc51629a15aca","component":"tdbc51200e11z02","state":"click","action":"function click() { \n $('#designer-toolbar-item-select-all').tooltip('hide');\n this.require('editor').selectAll(); \n}"},"p150db1b77d11ba1":{"_id":"p150db1b77d11ba1","component":"tdbc51200e11z01","state":"click","action":"function click() { \n $('#designer-toolbar-item-redo').tooltip('hide');\n this.require('editor').redo(); \n}"},"h1c4c115aa81281f":{"_id":"h1c4c115aa81281f","component":"tdbc51200e11z00","state":"click","action":"function click() { \n $('#designer-toolbar-item-undo').tooltip('hide');\n this.require('editor').undo(); \n}"},"f14706139781d16b":{"_id":"f14706139781d16b","component":"1dbc51200e116e8","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"w1e52a173f31d0da":{"_id":"w1e52a173f31d0da","component":"1dbc51200e116e7","state":"click","action":"function click() {\n $('#designer-toolbar-item-save').tooltip('hide');\n this.require('designer').save();\n}"},"e1bb25114121f519":{"_id":"e1bb25114121f519","component":"1dbc51200e11510","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n this.require('designer').open('https://system-designer.readme.io/docs/create-a-schema', '_blank', true); \n}"},"b18fab15f501e117":{"_id":"b18fab15f501e117","component":"Workspace","state":"render","action":"function render() { \n var Editor = null,\n designer = null,\n editor = null;\n\n Editor = this.require('Editor');\n designer = this.require('designer');\n\n if (designer.isCordova()) {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'codemirror',\n 'context': 'schema',\n 'editor': CodeMirror($('#designer-editor')[0], {\n lineNumbers: true,\n styleActiveLine: true,\n 'mode': 'application/json',\n 'theme': 'eclipse',\n 'tabSize': 2,\n 'autoCloseBrackets': true\n })\n });\n } else {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'ace',\n 'context': 'schema',\n 'editor': ace.edit('designer-editor')\n });\n }\n \n editor.render();\n}","useCoreAPI":false,"core":false},"b105d21fac11b017":{"_id":"b105d21fac11b017","component":"Designer","state":"render","action":"function render() {\n var id = '',\n systemId = '',\n system = null,\n schema = null;\n \n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1]);\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n\n // render\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('workspace').render();\n \n // get parameters\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n // set editor\n system = this.require('storage').get(systemId);\n \n this.require('factory').create(system);\n \n // extensions\n this.installExtensions();\n \n schema = system.schemas[id];\n\n this.require('store').uuid(id);\n this.require('store').data(schema);\n\n document.title = 'schema ' + schema._name + ' · system ' + system.name;\n\n this.require('editor').initValue(JSON.stringify(schema, null, '\\t'), 2);\n\n // router\n this.require('router').update();\n \n // shorcuts\n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"u102ee100eb1fb61":{"_id":"u102ee100eb1fb61","component":"Designer","state":"save","action":"function save() { \n var val = this.require('editor').getValue(),\n designer = this.require('designer'),\n message = this.require('message'),\n schema = null,\n property = '',\n propVal = '',\n hasError = false;\n\n try {\n schema = JSON.parse(val);\n } catch (e) {\n message.danger('Can not save your schema: your schema has an invalid structure.');\n return;\n }\n \n // global properties check\n for (property in schema) {\n if (schema.hasOwnProperty(property) && property.indexOf('_') !== 0) {\n propVal = schema[property];\n if (['property', 'link', 'collection', 'event', 'method'].indexOf(propVal) === -1) {\n message.danger('Invalid value for the property \\'' + property + '\\’.
    Authorized values are: \\'property\\', \\'link\\', \\'collection\\', \\'event\\' and \\'method\\'.');\n return;\n }\n }\n }\n \n for (property in schema) {\n if (schema.hasOwnProperty(property) && property.indexOf('_') === 0) {\n if (['_id', '_name', '_inherit', '_class', '_core', '_description'].indexOf(property) === -1) {\n message.danger('Invalid value \\'' + property + '\\’.
    Authorized values are: \\'_id\\', \\'_name\\', \\'_inherit\\', \\'_class\\', \\'_core\\' and \\'_description\\'.');\n return;\n }\n }\n }\n\n for (property in schema) {\n if (property.indexOf(' ') !== -1) {\n message.danger('Invalid property name \\'' + property + '\\’.
    Space is not authorized in the name of a property.');\n return;\n }\n propVal = schema[property];\n if (['property', 'link', 'collection', 'event', 'method'].indexOf(propVal) !== -1 && property.indexOf('_') === 0) {\n message.danger('Invalid property name \\'' + property + '\\’.
    A property name can not start with \\'_\\'.');\n return;\n }\n }\n \n // _inherit check\n if (typeof schema._inherit !== 'undefined' && !Array.isArray(schema._inherit)) {\n message.danger('Invalid inheritance value: it must be an array.');\n return;\n }\n \n if (schema._inherit && schema._inherit.indexOf(schema._name) !== -1) {\n message.danger('Invalid inheritance value: you can not inherit from yourself.');\n return;\n }\n \n if (schema._inherit && schema._inherit.indexOf('') !== -1) {\n message.danger('Invalid inheritance value: it can not be empty.');\n return;\n }\n\n if (schema._inherit) {\n schema._inherit.forEach(function (parent) {\n if (parent.constructor.name !== 'String') {\n hasError = true;\n }\n });\n if (hasError) {\n message.danger('Invalid inheritance value: it must be a string.');\n return;\n }\n }\n\n // _name check\n if (typeof schema._name === 'undefined') {\n message.danger('The property \\'_name\\' is missing.');\n return;\n }\n \n if (schema._name.constructor.name !== 'String') {\n message.danger('The property \\'_name\\' must be a string.');\n return;\n }\n\n // _id check\n if (typeof schema._id === 'undefined') {\n message.danger('The property \\'_id\\' is missing.');\n return;\n }\n \n if (schema._id.constructor.name !== 'String') {\n message.danger('The property \\'_id\\' must be a string.');\n return;\n }\n \n // clean name\n schema._name = schema._name.replace(/\\s|\\t/gi, '_')\n .replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '')\n .replace(/\\r|\\n/gi,'');\n\n // check if _name had changed\n if (this.require('store').data()._name !== schema._name) {\n this.require('channel').$editorUpdateSchemaName(schema._name, this.require('store').uuid());\n document.title = 'schema ' + schema._name + ' · ' + document.title.split('·')[1].trim();\n }\n\n this.require('store').data(schema);\n\n // check if _id has changed\n if (this.require('store').uuid() !== this.require('store').data()._id) {\n this.require('channel').$editorUpdateSchemaId(this.require('store').uuid(), this.require('store').data()._id);\n this.require('store').uuid(this.require('store').data()._id);\n }\n\n this.require('channel').$editorUpdateSchema(this.require('store').uuid(), this.require('store').data());\n message.success('Schema saved.');\n}","useCoreAPI":false,"core":false},"k171ad182081ca3c":{"_id":"k171ad182081ca3c","component":"l1ffcf1761317c7b","state":"start","action":"function start() { \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"q16ab5185c81f37d":{"_id":"q16ab5185c81f37d","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n href = '';\n\n id = decodeURIComponent(document.location.href.split('#')[1]);\n collection = document.location.href.split('#')[2];\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1];\n menubar[i].href = '#' + id + '#' + collection + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"t1e0be117b312cf0":{"_id":"t1e0be117b312cf0","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state'),\n system = {};\n \n if (designer.isCordova()) {\n state.messages().push(message);\n }\n\n this.require('storage').set('system-designer-message', message);\n\n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\t\n}","useCoreAPI":false,"core":false},"i12aee1bd7815e89":{"_id":"i12aee1bd7815e89","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function (obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":false,"core":false},"l178f0159e514a91":{"_id":"l178f0159e514a91","component":"p13d881c2fe174bd","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"y1c98019d4c1d53c":{"_id":"y1c98019d4c1d53c","component":"u1c5aa1b25d1e8e5","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"g1d47010c7e1904c":{"_id":"g1d47010c7e1904c","component":"Designer","state":"addShortcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component","diagram"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"2.9.0"}},"Diagram":{},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.1.1","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1d113198721599d":{"_id":"l1d113198721599d","_name":"MenuItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"u1f9a01abe31b3bf":{"_id":"u1f9a01abe31b3bf","_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"menuitem-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"name":{"type":"string","readOnly":false,"mandatory":false,"default":"template"},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"},"render":{},"click":{}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() { \n\tvar name = $('#modal-modeljson-name').val(),\n\t jsonText = $('#modal-modeljson-json').val(),\n\t json = null,\n\t schema = {},\n\t model = {},\n\t property = '',\n\t type = '',\n\t typeName = '',\n\t arrayType = '',\n\t that = this,\n\t createdTypes = [];\n\t \n\tfunction _getTypeName(parent, name) {\n\t var result = name;\n\t \n\t if (!_validType(name)) {\n\t if (parent) {\n\t result = parent + '_' + name;\n\t } else {\n\t result = name + Math.floor(Math.random() * 11);\n\t }\n\t }\n\t \n\t return result;\n\t} \n\n function _getType(value) {\n var type = '';\n \n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n \n return type;\n } \n \n function _validName(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n } \n \n function _validType(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n return result;\n } \n \n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = ''; \n \n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false); \n \n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n switch (type) {\n case 'object':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = {};\n break;\n case 'number':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'number';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = 0;\n break;\n case 'boolean':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'boolean';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = false;\n break;\n case 'array':\n typeDef.schema[property] = {};\n typeDef.schema[property].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n \n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n \t typeDef.schema[property].type = [_createTypeFromObject(name, property, obj[property][0])];\n \t typeDef.schema[property].default = [];\n \t } else {\n \t typeDef.schema[property].type = ['object'];\n \t typeDef.schema[property].default = [];\n \t }\n } else {\n typeDef.schema[property].type = [arrayType];\n typeDef.schema[property].default = [];\n }\n } else {\n typeDef.schema[property].type = ['any'];\n typeDef.schema[property].default = [];\n\t }\n break;\n default:\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'string';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n \n return typeName;\n }\n \n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n\tif (name && _validName(name) && jsonText) {\n\t try {\n\t json = JSON.parse(jsonText);\n\t if (json) {\n\t // schema\n\t schema = this.require('factory').addSchema(name.trim());\n\t \n\t schema._inherit = [];\n\t this.require('factory').updateSchema(schema._id, schema);\n\t \n\t this.require('designer').save();\n\t \n\t for (property in json) {\n\t if (property.indexOf('_') !== 0) {\n \t type = _getType(json[property]);\n \t if (type === 'array') {\n \t schema[property] = 'collection';\n \t } else {\n \t schema[property] = 'property';\n \t }\n\t }\n\t }\n\t \n\t this.require('factory').updateSchema(schema._id, schema);\n\t this.require('designer').save();\n\t \n\t // model\n\t model = this.require('factory').createModel(schema);\n\t this.require('designer').save();\n\n\t for (property in schema) {\n\t if (property.indexOf('_') !== 0) {\n\t type = _getType(json[property]);\n\t switch (type) {\n\t case 'object':\n\t if (json[property] !== null) {\n\t model[property].type = _createTypeFromObject('', property, json[property]);\n\t model[property].default = {};\n\t } else {\n\t model[property].type = 'object';\n\t model[property].default = {};\n\t }\n\t break;\n\t case 'number':\n\t model[property].type = 'number';\n\t model[property].default = 0;\n\t break;\n\t case 'boolean':\n\t model[property].type = 'boolean';\n\t model[property].default = false;\n\t break;\n\t case 'array':\n\t if (typeof json[property][0] !== 'undefined') {\n\t arrayType = _getType(json[property][0]);\n\t if (arrayType === 'object') {\n\t if (json[property][0] !== null) {\n \t model[property].type = [_createTypeFromObject('', property, json[property][0])];\n \t model[property].default = [];\n \t } else {\n \t model[property].type = ['object'];\n \t model[property].default = [];\n \t }\n\t } else {\n\t model[property].type = [arrayType];\n\t model[property].default = [];\n\t }\n\t } else {\n\t model[property].type = ['any'];\n\t model[property].default = [];\n\t }\n\t break;\n\t \tcase 'string':\n\t model[property].type = 'string';\n\t model[property].default = '';\n\t break;\n\t default:\n\t break;\n\t }\n\t }\n\t }\n\t \n\t this.require('factory').updateModel(model._id, model);\n\t this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\t \n\t this.require('message').success('A model has been created for the JSON.');\n\t }\n\t } catch(e) {\n\t this.hide();\n\t this.require('message').warning('Can not create the model: the JSON is invalid.');\n\t }\n\t} \n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"MenuItem":{},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2018 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v2.9.0"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"A behavior is the action to do when a method or an event is called."},"help-components.html":{"_id":"help-components.html","source":"Components are your classes instances. Their states are saved in a store, a JSON object."},"help-logs.html":{"_id":"help-logs.html","source":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "},"help-models.html":{"_id":"help-models.html","source":"A model is an UML representation of your classes. It is generated from a schema."},"help-schemas.html":{"_id":"help-schemas.html","source":"A schema is the definition of your model. Models are generated based on the schema definition."},"help-system.html":{"_id":"help-system.html","source":"An application is a system. Once you have created one, your next step is to create a schema."},"help-types.html":{"_id":"help-types.html","source":"A type is used in your model to define an enumeration or a structure."},"menu-action-search.html":{"_id":"menu-action-search.html","source":"
    \n
    \n \n
    \n
    "},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-guide.html":{"_id":"menu-item-guide.html","source":"Guide"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs0"},"menu-item-message-save.html":{"_id":"menu-item-message-save.html","source":" file saved!"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-quick-start.html":{"_id":"menu-item-quick-start.html","source":"Quick Start"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"},"toolbar-item-diagram.html":{"_id":"toolbar-item-diagram.html","source":""},"menu-item-diagram.html":{"_id":"menu-item-diagram.html","source":"Class diagram"},"toolbar-item-zoomout.html":{"_id":"toolbar-item-zoomout.html","source":""},"toolbar-item-zoomin.html":{"_id":"toolbar-item-zoomin.html","source":""},"toolbar-item-zoominit.html":{"_id":"toolbar-item-zoominit.html","source":""},"toolbar-item-export-diagram.html":{"_id":"toolbar-item-export-diagram.html","source":""}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.0.0","description":"Quick start\n\nThis system is taken from the quick start: https://system-designer.readme.io/docs/quick-start","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n var luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n var result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vador":{"_id":"vador","father":"","firstName":"Dark","lastName":"Vador"},"luke":{"_id":"luke","father":"vador","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"04-send-messages.json":{"_id":"04-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.0.0","description":"Send messages threw a channel\n\n\nYou can send messages from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. In '_Channel' 'send' method, define how to send the message to another channel (webRTC, XHR, ...).\n3. In another system, define how to get the message and send it to the system with: runtime.message().\n4. To send a message: this.require('channel').myevent(param1, param2, ...).\n5. To listen to the message, just add a behavior to the event.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.0.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"type":"css","readOnly":false,"mandatory":false,"default":""},"render":{}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{},"filter":{"type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n var html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n var div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n var items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n var author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.0.1","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n var http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"04-create-extension.json":{"_id":"04-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.1.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"05-listen-collection-events.json":{"_id":"05-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.0.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""},"field":{"type":"string","mandatory":true,"default":""},"value":{"type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"document":{"type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179bg":{"_id":"1f8571164c179bg","html":"menu-action-version.html","position":10,"type":"schema"}},"MenuHeader":{"1fb101b99813a15":{"_id":"1fb101b99813a15","html":"menu-header-schema.html","type":"schema"}},"MenuItem":{"1f1781882618106":{"_id":"1f1781882618106","name":"schema","html":"menu-item-schema.html","position":10,"type":"schema","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"tdbc51200e11z03":{"_id":"tdbc51200e11z03","html":"toolbar-item-copy.html","position":50,"type":"schema","platform":"electron"},"tdbc51200e11z04":{"_id":"tdbc51200e11z04","html":"toolbar-item-paste.html","position":60,"type":"schema","platform":"electron"},"1dbc51200e11510":{"_id":"1dbc51200e11510","html":"toolbar-item-help.html","position":80,"type":"schema","platform":"all"},"1dbc51200e116e7":{"_id":"1dbc51200e116e7","html":"toolbar-item-save.html","position":10,"type":"schema","platform":"all"},"1dbc51200e116e8":{"_id":"1dbc51200e116e8","html":"toolbar-item-copyright.html","position":90,"type":"schema","platform":"all"},"tdbc51200e11z00":{"_id":"tdbc51200e11z00","html":"toolbar-item-undo.html","position":20,"type":"schema","platform":"all"},"tdbc51200e11z01":{"_id":"tdbc51200e11z01","html":"toolbar-item-redo.html","position":30,"type":"schema","platform":"all"},"tdbc51200e11z02":{"_id":"tdbc51200e11z02","html":"toolbar-item-select-all.html","position":40,"type":"schema","platform":"all"},"p13d881c2fe174bd":{"_id":"p13d881c2fe174bd","html":"toolbar-item-command.html","platform":"web","position":75,"type":"schema"},"u1c5aa1b25d1e8e5":{"_id":"u1c5aa1b25d1e8e5","html":"toolbar-item-command.html","platform":"electron","position":75,"type":"schema"}}},"_id":"l1ffcf1761317c7b"}); \ No newline at end of file diff --git a/designer/scripts/editor-system.js b/designer/scripts/editor-system.js index 2c219ae..b8245db 100644 --- a/designer/scripts/editor-system.js +++ b/designer/scripts/editor-system.js @@ -1,3 +1,3 @@ // System Designer - Copyright 2018 Erwan Carriou // Licensed under the Apache License, Version 2.0 (the "License") -runtime.install({"name":"editor-system","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"]},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"2.8.3"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"addShortcuts":{}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}]}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":false}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57"},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null;\n \n if (extension.installed) { \n system = extension.source;\n \n try {\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n } catch (e) {\n this.require('message').danger('Can not install an extension.');\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n\n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').hide();\n }\n } else {\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').show();\n }\n }\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-file').attr('checked', false);\n $('#designer-dialog-import-modal-from-library').attr('checked', true);\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n that.data(JSON.parse(json));\n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').uninstall('ext_' + system._id)\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n downloadLink.click();\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n if (system.name === name) {\n result = false;\n break;\n }\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n \n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"snippet\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'snippet' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'snippet' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'snippet' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'snippet' });\n }\n \n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n \n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n \n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n \n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n \n // snippets\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet:'{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'snippet' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n \n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"snippet\" });\n }\n \n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n \n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n \n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n \n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n \n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n\n repo1.writeFile('master', system.name + '.json', JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html', htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js', jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^2.8.4';\n\n repo4.writeFile('master', 'package.json', JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.source());\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n \n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n });\n\n menuActions.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('afterbegin', '
  • ' + action.html().source() + '');\n });\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n this.require('state').messages(messages);\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n for (propName in this.document().schema) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n }\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n\n systemId = this.require('factory').system().id();\n schema = _getSchema(this.model());\n model = _getModel(this.model());\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = this.document()[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n if (modelName === '_Component') {\n modelName = _getModelFromComponent(propVal);\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n function gen() {\n return Math.floor((1 + Math.random()) * 0x10000).toString(16);\n }\n function getPrefix() {\n var validPrefix = 'abcdefghijklmnopqrstuvwxyz';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return getPrefix() + gen() + gen() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n\n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n \n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system !== 'undefined':\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && typeof system !== 'undefined':\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && typeof system !== 'undefined':\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && typeof system !== 'undefined' && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n default:\n break;\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin', \n template.source().replace(/{{message}}/gi, message));\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom) {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (typeof system === 'undefined') {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"u1148712dc118eea":{"_id":"u1148712dc118eea","component":"sdbc51200e11z03","state":"click","action":"function click() { \n $('#designer-toolbar-item-copy').tooltip('hide');\n this.require('editor').copy(); \n}"},"l1c2d911d83104a2":{"_id":"l1c2d911d83104a2","component":"sdbc51200e11z04","state":"click","action":"function click() { \n $('#designer-toolbar-item-paste').tooltip('hide');\n this.require('editor').paste(); \n}"},"a194c816a861f58c":{"_id":"a194c816a861f58c","component":"sdbc51200e11z02","state":"click","action":"function click() { \n $('#designer-toolbar-item-select-all').tooltip('hide');\n this.require('editor').selectAll(); \n}"},"u1ad2a18ae7197d7":{"_id":"u1ad2a18ae7197d7","component":"sdbc51200e11z01","state":"click","action":"function click() { \n $('#designer-toolbar-item-redo').tooltip('hide');\n this.require('editor').redo(); \n}"},"m12f44111501c769":{"_id":"m12f44111501c769","component":"sdbc51200e11z00","state":"click","action":"function click() { \n $('#designer-toolbar-item-undo').tooltip('hide');\n this.require('editor').undo(); \n}"},"g1fcf31e19f15b6f":{"_id":"g1fcf31e19f15b6f","component":"1dbc51200e11z10","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n this.require('designer').open('https://system-designer.readme.io/docs/create-a-system', '_blank', true); \n}"},"j190d61dacc1fb05":{"_id":"j190d61dacc1fb05","component":"1dbc51200e116e4","state":"click","action":"function click() {\n $('#designer-toolbar-item-save').tooltip('hide');\n this.require('designer').save();\n}"},"c1076f15499194ba":{"_id":"c1076f15499194ba","component":"13a291c27f16311","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n\n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"a1b1d011fe31872d":{"_id":"a1b1d011fe31872d","component":"v1c4421834f1995a","state":"start","action":"function start() { \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"z1b2ed1f26c196e0":{"_id":"z1b2ed1f26c196e0","component":"MenuItem","state":"click","action":"function click() { \n this.require('state').menu(this.name());\n}","useCoreAPI":false,"core":false},"p1e0b1155ea1f248":{"_id":"p1e0b1155ea1f248","component":"1f1781882618115","state":"click","action":"function click() { \n var editor = this.require('editor'),\n designer = this.require('designer'),\n extra = {},\n data = {};\n\n if (editor.getValue().indexOf('{') === 0) {\n this.require('store').data(JSON.parse(editor.getValue()));\n } else {\n extra = this.require('store').extra();\n if (extra && extra.context) {\n data = this.require('store').data();\n data[extra.context] = editor.getValue();\n this.require('store').data(data);\n }\n }\n\n extra = {};\n extra.context = 'name';\n this.require('store').extra(extra);\n\n editor.setEditor('text', this.require('store').data().name, 1);\n}","useCoreAPI":false,"core":false},"r1edbf1004f16a37":{"_id":"r1edbf1004f16a37","component":"1f1781882618114","state":"click","action":"function click() { \n var editor = this.require('editor'),\n designer = this.require('designer'),\n extra = {},\n data = {};\n\n if (editor.getValue().indexOf('{') === 0) {\n this.require('store').data(JSON.parse(editor.getValue()));\n } else {\n extra = this.require('store').extra();\n if (extra && extra.context) {\n data = this.require('store').data();\n data[extra.context] = editor.getValue();\n this.require('store').data(data);\n }\n }\n\n extra = {};\n extra.context = 'description';\n this.require('store').extra(extra);\n\n editor.setEditor('text', this.require('store').data().description, 1);\n}","useCoreAPI":false,"core":false},"o1626e18db0119a9":{"_id":"o1626e18db0119a9","component":"1f1781882618116","state":"click","action":"function click() { \n var editor = this.require('editor'),\n extra = {},\n data = {};\n\n if (editor.getValue().indexOf('{') === 0) {\n this.require('store').data(JSON.parse(editor.getValue()));\n } else {\n extra = this.require('store').extra();\n if (extra && extra.context) {\n data = this.require('store').data();\n data[extra.context] = editor.getValue();\n this.require('store').data(data);\n }\n }\n\n extra = {};\n extra.context = 'version';\n this.require('store').extra(extra);\n\n editor.setEditor('text', this.require('store').data().version, 1);\n}","useCoreAPI":false,"core":false},"o1363f106aa19961":{"_id":"o1363f106aa19961","component":"1f1781882618102","state":"click","action":"function click() { \n var editor = this.require('editor'),\n data = this.require('store').data(),\n extra = this.require('store').extra();\n \n if (extra && extra.context) {\n data[extra.context] = editor.getValue();\n this.require('store').data(data);\n }\n \n delete data.classInfo;\n \n editor.setEditor('json', JSON.stringify(data, null, '\\t'), 2);\n}","useCoreAPI":false,"core":false},"n1a54b1da681f33e":{"_id":"n1a54b1da681f33e","component":"Workspace","state":"render","action":"function render() {\n var Editor = null,\n editor = null,\n designer = null;\n\n Editor = this.require('Editor');\n designer = this.require('designer');\n\n if (designer.isCordova()) {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'codemirror',\n 'context': 'system',\n 'editor': CodeMirror($('#designer-editor')[0], {\n lineNumbers: true,\n styleActiveLine: true,\n 'mode': 'text/x-textile',\n 'theme': 'eclipse',\n 'tabSize': 2,\n 'autoCloseBrackets': true\n })\n });\n } else {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'ace',\n 'context': 'system',\n 'editor': ace.edit('designer-editor')\n });\n }\n \n editor.render();\n}","useCoreAPI":false,"core":false},"g1e35b1112512787":{"_id":"g1e35b1112512787","component":"Designer","state":"render","action":"function render() {\n var id = '',\n system = null,\n extra = {};\n \n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1]);\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n \n // render\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('workspace').render();\n \n // get parameters\n id = document.location.href.split('#')[1].split('?')[0];\n \n // set editor\n system = this.require('storage').get(id);\n \n this.require('factory').create(system);\n \n // extensions\n this.installExtensions();\n\n this.require('store').uuid(id);\n this.require('store').data(system);\n\n document.title = 'system ' + system.name;\n\n extra.context = 'name';\n this.require('store').extra(extra);\n\n this.require('editor').initValue(this.require('store').data().name, 1);\n \n this.require('router').update();\n \n // shorcuts\n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"f199b4184ea1639d":{"_id":"f199b4184ea1639d","component":"Designer","state":"save","action":"function save() { \n var val = this.require('editor').getValue(),\n designer = this.require('designer'),\n store = this.require('store').data();\n\n switch (this.require('state').menu()) {\n case 'name':\n val = val.trim();\n val = val.replace(/\\s|\\t/gi, '-')\n .replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '')\n .replace(/\\r|\\n/gi,'');\n this.require('editor').setValue(val);\n store.name = val;\n document.title = 'system ' + store.name;\n break;\n case 'description':\n store.description = val.trim();\n break;\n case 'version':\n store.version = val.trim();\n break;\n case 'bundle':\n store = JSON.parse(val);\n document.title = 'system ' + store.name;\n break;\n default:\n break;\n }\n\n this.require('store').data(store);\n\n this.require('channel').$editorUpdateSystem(this.require('store').uuid(), this.require('store').data());\n this.require('message').clean();\n this.require('message').success('System saved.');\n}","useCoreAPI":false,"core":false},"x1645919b431ab61":{"_id":"x1645919b431ab61","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n href = '';\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1].split('?')[0];\n menubar[i].href = '#' + this.require('store').uuid() + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"g1c050192531348c":{"_id":"g1c050192531348c","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state');\n\n if (designer.isCordova()) {\n state.messages().push(message);\n }\n\n this.require('storage').set('system-designer-message', message);\n\n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\t\n}","useCoreAPI":false,"core":false},"k1473f1cbe41b194":{"_id":"k1473f1cbe41b194","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function (obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":false,"core":false},"w1aa16102d712d94":{"_id":"w1aa16102d712d94","component":"x1cfa910cac1f8da","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"l11b92128ce147e8":{"_id":"l11b92128ce147e8","component":"k13bb31b8681ba70","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"l1c65b1fc3e1c1c2":{"_id":"l1c65b1fc3e1c1c2","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar result = {};\n\treturn result;\n}","useCoreAPI":false,"core":false},"p1e6c41a4bc1b4d3":{"_id":"p1e6c41a4bc1b4d3","component":"Designer","state":"addShortcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"2.8.3"}},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.1.1","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1d113198721599d":{"_id":"l1d113198721599d","_name":"MenuItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"u1f9a01abe31b3bf":{"_id":"u1f9a01abe31b3bf","_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"menuitem-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"name":{"type":"string","readOnly":false,"mandatory":false,"default":"template"},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"},"render":{},"click":{}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() { \n\tvar name = $('#modal-modeljson-name').val(),\n\t jsonText = $('#modal-modeljson-json').val(),\n\t json = null,\n\t schema = {},\n\t model = {},\n\t property = '',\n\t type = '',\n\t typeName = '',\n\t arrayType = '',\n\t that = this,\n\t createdTypes = [];\n\t \n\tfunction _getTypeName(parent, name) {\n\t var result = name;\n\t \n\t if (!_validType(name)) {\n\t if (parent) {\n\t result = parent + '_' + name;\n\t } else {\n\t result = name + Math.floor(Math.random() * 11);\n\t }\n\t }\n\t \n\t return result;\n\t} \n\n function _getType(value) {\n var type = '';\n \n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n \n return type;\n } \n \n function _validName(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n } \n \n function _validType(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n return result;\n } \n \n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = ''; \n \n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false); \n \n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n switch (type) {\n case 'object':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = {};\n break;\n case 'number':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'number';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = 0;\n break;\n case 'boolean':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'boolean';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = false;\n break;\n case 'array':\n typeDef.schema[property] = {};\n typeDef.schema[property].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n \n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n \t typeDef.schema[property].type = [_createTypeFromObject(name, property, obj[property][0])];\n \t typeDef.schema[property].default = [];\n \t } else {\n \t typeDef.schema[property].type = ['object'];\n \t typeDef.schema[property].default = [];\n \t }\n } else {\n typeDef.schema[property].type = [arrayType];\n typeDef.schema[property].default = [];\n }\n } else {\n typeDef.schema[property].type = ['any'];\n typeDef.schema[property].default = [];\n\t }\n break;\n default:\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'string';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n \n return typeName;\n }\n \n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n\tif (name && _validName(name) && jsonText) {\n\t try {\n\t json = JSON.parse(jsonText);\n\t if (json) {\n\t // schema\n\t schema = this.require('factory').addSchema(name.trim());\n\t \n\t schema._inherit = [];\n\t this.require('factory').updateSchema(schema._id, schema);\n\t \n\t this.require('designer').save();\n\t \n\t for (property in json) {\n\t if (property.indexOf('_') !== 0) {\n \t type = _getType(json[property]);\n \t if (type === 'array') {\n \t schema[property] = 'collection';\n \t } else {\n \t schema[property] = 'property';\n \t }\n\t }\n\t }\n\t \n\t this.require('factory').updateSchema(schema._id, schema);\n\t this.require('designer').save();\n\t \n\t // model\n\t model = this.require('factory').createModel(schema);\n\t this.require('designer').save();\n\n\t for (property in schema) {\n\t if (property.indexOf('_') !== 0) {\n\t type = _getType(json[property]);\n\t switch (type) {\n\t case 'object':\n\t if (json[property] !== null) {\n\t model[property].type = _createTypeFromObject('', property, json[property]);\n\t model[property].default = {};\n\t } else {\n\t model[property].type = 'object';\n\t model[property].default = {};\n\t }\n\t break;\n\t case 'number':\n\t model[property].type = 'number';\n\t model[property].default = 0;\n\t break;\n\t case 'boolean':\n\t model[property].type = 'boolean';\n\t model[property].default = false;\n\t break;\n\t case 'array':\n\t if (typeof json[property][0] !== 'undefined') {\n\t arrayType = _getType(json[property][0]);\n\t if (arrayType === 'object') {\n\t if (json[property][0] !== null) {\n \t model[property].type = [_createTypeFromObject('', property, json[property][0])];\n \t model[property].default = [];\n \t } else {\n \t model[property].type = ['object'];\n \t model[property].default = [];\n \t }\n\t } else {\n\t model[property].type = [arrayType];\n\t model[property].default = [];\n\t }\n\t } else {\n\t model[property].type = ['any'];\n\t model[property].default = [];\n\t }\n\t break;\n\t \tcase 'string':\n\t model[property].type = 'string';\n\t model[property].default = '';\n\t break;\n\t default:\n\t break;\n\t }\n\t }\n\t }\n\t \n\t this.require('factory').updateModel(model._id, model);\n\t this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\t \n\t this.require('message').success('A model has been created for the JSON.');\n\t }\n\t } catch(e) {\n\t this.hide();\n\t this.require('message').warning('Can not create the model: the JSON is invalid.');\n\t }\n\t} \n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"MenuItem":{},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2018 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v2.8.3"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"A behavior is the action to do when a method or an event is called."},"help-components.html":{"_id":"help-components.html","source":"Components are your classes instances. Their states are saved in a store, a JSON object."},"help-logs.html":{"_id":"help-logs.html","source":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "},"help-models.html":{"_id":"help-models.html","source":"A model is an UML representation of your classes. It is generated from a schema."},"help-schemas.html":{"_id":"help-schemas.html","source":"A schema is the definition of your model. Models are generated based on the schema definition."},"help-system.html":{"_id":"help-system.html","source":"An application is a system. Once you have created one, your next step is to create a schema."},"help-types.html":{"_id":"help-types.html","source":"A type is used in your model to define an enumeration or a structure."},"menu-action-search.html":{"_id":"menu-action-search.html","source":"
    \n
    \n \n
    \n
    "},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-guide.html":{"_id":"menu-item-guide.html","source":"Guide"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs"},"menu-item-message-save.html":{"_id":"menu-item-message-save.html","source":" file saved!"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-quick-start.html":{"_id":"menu-item-quick-start.html","source":"Quick Start"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.0.0","description":"Quick start\n\nThis system is taken from the quick start: https://system-designer.readme.io/docs/quick-start","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n var luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n var result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vador":{"_id":"vador","father":"","firstName":"Dark","lastName":"Vador"},"luke":{"_id":"luke","father":"vador","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"04-send-messages.json":{"_id":"04-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.0.0","description":"Send messages threw a channel\n\n\nYou can send messages from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. In '_Channel' 'send' method, define how to send the message to another channel (webRTC, XHR, ...).\n3. In another system, define how to get the message and send it to the system with: runtime.message().\n4. To send a message: this.require('channel').myevent(param1, param2, ...).\n5. To listen to the message, just add a behavior to the event.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.0.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"type":"css","readOnly":false,"mandatory":false,"default":""},"render":{}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{},"filter":{"type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n var html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n var div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n var items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n var author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.0.1","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n var http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"04-create-extension.json":{"_id":"04-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.1.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"05-listen-collection-events.json":{"_id":"05-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.0.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""},"field":{"type":"string","mandatory":true,"default":""},"value":{"type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"document":{"type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179be":{"_id":"1f8571164c179be","html":"menu-action-version.html","position":10,"type":"system"}},"MenuHeader":{"1fb101b99813a13":{"_id":"1fb101b99813a13","html":"menu-header-system.html","type":"system"}},"MenuItem":{"1f1781882618102":{"_id":"1f1781882618102","name":"bundle","html":"menu-item-bundle.html","position":50,"type":"system","platform":"all"},"1f1781882618114":{"_id":"1f1781882618114","name":"description","html":"menu-item-description.html","position":30,"type":"system","platform":"all"},"1f1781882618115":{"_id":"1f1781882618115","name":"name","html":"menu-item-name.html","position":10,"type":"system","platform":"all"},"1f1781882618116":{"_id":"1f1781882618116","name":"version","html":"menu-item-version.html","position":20,"type":"system","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"sdbc51200e11z03":{"_id":"sdbc51200e11z03","html":"toolbar-item-copy.html","position":50,"type":"system","platform":"electron"},"sdbc51200e11z04":{"_id":"sdbc51200e11z04","html":"toolbar-item-paste.html","position":60,"type":"system","platform":"electron"},"13a291c27f16311":{"_id":"13a291c27f16311","html":"toolbar-item-copyright.html","position":90,"type":"system","platform":"all"},"1dbc51200e116e4":{"_id":"1dbc51200e116e4","html":"toolbar-item-save.html","position":10,"type":"system","platform":"all"},"1dbc51200e11z10":{"_id":"1dbc51200e11z10","html":"toolbar-item-help.html","position":80,"type":"system","platform":"all"},"sdbc51200e11z00":{"_id":"sdbc51200e11z00","html":"toolbar-item-undo.html","position":20,"type":"system","platform":"all"},"sdbc51200e11z01":{"_id":"sdbc51200e11z01","html":"toolbar-item-redo.html","position":30,"type":"system","platform":"all"},"sdbc51200e11z02":{"_id":"sdbc51200e11z02","html":"toolbar-item-select-all.html","position":40,"type":"system","platform":"all"},"x1cfa910cac1f8da":{"_id":"x1cfa910cac1f8da","html":"toolbar-item-command.html","platform":"web","position":75,"type":"system"},"k13bb31b8681ba70":{"_id":"k13bb31b8681ba70","html":"toolbar-item-command.html","platform":"electron","position":75,"type":"system"}}},"_id":"v1c4421834f1995a"}); \ No newline at end of file +runtime.install({"name":"editor-system","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"v123b51abbb18712":{"_id":"v123b51abbb18712","_name":"Diagram","_inherit":["_Component"],"ref":"property","zoom":"property","render":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method","toGraphviz":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","isType":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"]},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"2.9.0"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"addShortcuts":{}},"b169321637f19101":{"_id":"b169321637f19101","_name":"Diagram","_description":"","ref":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""},"zoom":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":1},"render":{"description":"","params":[],"result":"any"}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toGraphviz":{"description":"","params":[],"result":"string"}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":false}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57"},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"},"isType":{"description":"","params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null;\n \n if (extension.installed) { \n system = extension.source;\n \n try {\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n } catch (e) {\n this.require('message').danger('Can not install an extension.');\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n\n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').hide();\n }\n } else {\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').show();\n }\n }\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-file').attr('checked', false);\n $('#designer-dialog-import-modal-from-library').attr('checked', true);\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n that.data(JSON.parse(json));\n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-export-graphviz');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').uninstall('ext_' + system._id)\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-graphviz').prop('checked'):\n textToWrite = this.require('export').toGraphviz();\n fileNameToSaveAs = this.require('factory').system().name() + '.gv';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n downloadLink.click();\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n if (system.name === name) {\n result = false;\n break;\n }\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n \n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"snippet\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'snippet' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'snippet' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'snippet' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'snippet' });\n }\n \n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n \n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n \n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n \n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n \n // snippets\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet:'{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'snippet' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n \n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"snippet\" });\n }\n \n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n \n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n \n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n \n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n \n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"e13c7916b1a15fc4":{"_id":"e13c7916b1a15fc4","component":"Export","state":"toGraphviz","action":"function toGraphviz() {\n var schemas = this.require('factory').system().schemas();\n var models = this.require('factory').system().models();\n var inheritance = '';\n var modelId = '';\n var modelName = '';\n var modelDescription = '';\n var propName = '';\n var propVal = '';\n var attributes = '';\n var methods = '';\n var result = '';\n var links = '';\n var collections = '';\n var that = this;\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n // create model\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n modelDescription += '\\n\\n\\t' + modelName + ' [\\r\\t\\tlabel = \"{' + modelName + '|';\n \n attributes = '';\n methods = '';\n\n for (propName in models[modelId]) {\n if (models[modelId].hasOwnProperty(propName)) {\n propVal = models[modelId][propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (modelId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (modelId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n }\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n }\n }\n }\n break;\n \n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + params + ' : ' + result + '\\\\l';\n } else {\n methods += '+ ' + propName + params + ' : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + params + '\\\\l';\n } else {\n methods += '+ ' + propName + params + '\\\\l';\n }\n }\n break;\n \n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n \n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + '() : ' + result + '\\\\l';\n } else {\n methods += '+ ' + propName + '() : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + '()\\\\l';\n } else {\n methods += '+ ' + propName + '()\\\\l';\n }\n }\n break;\n }\n }\n }\n\n modelDescription += attributes + '|' + methods;\n modelDescription += '}\"\\r\\t]';\n }\n\n // create inheritance links\n for (var schema in schemas) {\n if (schemas[schema]._inherit && schemas[schema]._inherit.length) {\n schemas[schema]._inherit.forEach(function (parent) {\n inheritance += '\\n\\t' + schemas[schema]._name + ' -> ' + parent;\n });\n }\n }\n \n // case of Component\n if (inheritance.indexOf('_Component') !== -1) {\n modelDescription += `\\n\\t_Component [\n label = \"{_Component|+ id : string\\\\l|+ classInfo() : _ClassInfo\\\\l+ init(conf : object)\\\\l+ destroy()\\\\l+ on(state : string, action : function, useCoreAPI : boolean, isCore : boolean) : string\\\\l+ off(state : string, behaviorId : string)\\\\l+ require(id : string) : _Component\\\\l+ error(data : errorParam)\\\\l}\"\n ]` \n };\n\n let generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n \n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]${modelDescription}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"1\"\n taillabel = \"\"\n ]\n ${links}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"0..*\"\n taillabel = \"\"\n ]\n ${collections}\n\n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n arrowhead = \"empty\"\n headlabel = \"\"\n taillabel = \"\"\n ]\n ${inheritance}\n}`;\n\n return generatedDiagram;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n\n repo1.writeFile('master', system.name + '.json', JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html', htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js', jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^2.9.0';\n\n repo4.writeFile('master', 'package.json', JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.source());\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n \n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n });\n\n menuActions.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('afterbegin', '
  • ' + action.html().source() + '');\n });\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n this.require('state').messages(messages);\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n for (propName in this.document().schema) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n }\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n\n systemId = this.require('factory').system().id();\n schema = _getSchema(this.model());\n model = _getModel(this.model());\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = this.document()[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n if (modelName === '_Component') {\n modelName = _getModelFromComponent(propVal);\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n function gen() {\n return Math.floor((1 + Math.random()) * 0x10000).toString(16);\n }\n function getPrefix() {\n var validPrefix = 'abcdefghijklmnopqrstuvwxyz';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return getPrefix() + gen() + gen() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"v119e617ef513e94":{"_id":"v119e617ef513e94","component":"SystemFactory","state":"isType","action":"function isType(name) { \n var types = this.system().types(),\n result = false,\n prop = '';\n\n\tif (!result) {\n\t for (prop in types) {\n\t if (schemas[prop].name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n\n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n \n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system !== 'undefined':\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && typeof system !== 'undefined':\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && typeof system !== 'undefined':\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && typeof system !== 'undefined' && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n default:\n break;\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin', \n template.source().replace(/{{message}}/gi, message));\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom) {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (typeof system === 'undefined') {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"u1148712dc118eea":{"_id":"u1148712dc118eea","component":"sdbc51200e11z03","state":"click","action":"function click() { \n $('#designer-toolbar-item-copy').tooltip('hide');\n this.require('editor').copy(); \n this.require('message').success('The text has been copied to the clipboard.');\n}"},"l1c2d911d83104a2":{"_id":"l1c2d911d83104a2","component":"sdbc51200e11z04","state":"click","action":"function click() { \n $('#designer-toolbar-item-paste').tooltip('hide');\n this.require('editor').paste(); \n}"},"a194c816a861f58c":{"_id":"a194c816a861f58c","component":"sdbc51200e11z02","state":"click","action":"function click() { \n $('#designer-toolbar-item-select-all').tooltip('hide');\n this.require('editor').selectAll(); \n}"},"u1ad2a18ae7197d7":{"_id":"u1ad2a18ae7197d7","component":"sdbc51200e11z01","state":"click","action":"function click() { \n $('#designer-toolbar-item-redo').tooltip('hide');\n this.require('editor').redo(); \n}"},"m12f44111501c769":{"_id":"m12f44111501c769","component":"sdbc51200e11z00","state":"click","action":"function click() { \n $('#designer-toolbar-item-undo').tooltip('hide');\n this.require('editor').undo(); \n}"},"g1fcf31e19f15b6f":{"_id":"g1fcf31e19f15b6f","component":"1dbc51200e11z10","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n this.require('designer').open('https://system-designer.readme.io/docs/create-a-system', '_blank', true); \n}"},"j190d61dacc1fb05":{"_id":"j190d61dacc1fb05","component":"1dbc51200e116e4","state":"click","action":"function click() {\n $('#designer-toolbar-item-save').tooltip('hide');\n this.require('designer').save();\n}"},"c1076f15499194ba":{"_id":"c1076f15499194ba","component":"13a291c27f16311","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n\n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"a1b1d011fe31872d":{"_id":"a1b1d011fe31872d","component":"v1c4421834f1995a","state":"start","action":"function start() { \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"z1b2ed1f26c196e0":{"_id":"z1b2ed1f26c196e0","component":"MenuItem","state":"click","action":"function click() { \n this.require('state').menu(this.name());\n}","useCoreAPI":false,"core":false},"p1e0b1155ea1f248":{"_id":"p1e0b1155ea1f248","component":"1f1781882618115","state":"click","action":"function click() { \n var editor = this.require('editor'),\n designer = this.require('designer'),\n extra = {},\n data = {};\n\n if (editor.getValue().indexOf('{') === 0) {\n this.require('store').data(JSON.parse(editor.getValue()));\n } else {\n extra = this.require('store').extra();\n if (extra && extra.context) {\n data = this.require('store').data();\n data[extra.context] = editor.getValue();\n this.require('store').data(data);\n }\n }\n\n extra = {};\n extra.context = 'name';\n this.require('store').extra(extra);\n\n editor.setEditor('text', this.require('store').data().name, 1);\n}","useCoreAPI":false,"core":false},"r1edbf1004f16a37":{"_id":"r1edbf1004f16a37","component":"1f1781882618114","state":"click","action":"function click() { \n var editor = this.require('editor'),\n designer = this.require('designer'),\n extra = {},\n data = {};\n\n if (editor.getValue().indexOf('{') === 0) {\n this.require('store').data(JSON.parse(editor.getValue()));\n } else {\n extra = this.require('store').extra();\n if (extra && extra.context) {\n data = this.require('store').data();\n data[extra.context] = editor.getValue();\n this.require('store').data(data);\n }\n }\n\n extra = {};\n extra.context = 'description';\n this.require('store').extra(extra);\n\n editor.setEditor('text', this.require('store').data().description, 1);\n}","useCoreAPI":false,"core":false},"o1626e18db0119a9":{"_id":"o1626e18db0119a9","component":"1f1781882618116","state":"click","action":"function click() { \n var editor = this.require('editor'),\n extra = {},\n data = {};\n\n if (editor.getValue().indexOf('{') === 0) {\n this.require('store').data(JSON.parse(editor.getValue()));\n } else {\n extra = this.require('store').extra();\n if (extra && extra.context) {\n data = this.require('store').data();\n data[extra.context] = editor.getValue();\n this.require('store').data(data);\n }\n }\n\n extra = {};\n extra.context = 'version';\n this.require('store').extra(extra);\n\n editor.setEditor('text', this.require('store').data().version, 1);\n}","useCoreAPI":false,"core":false},"o1363f106aa19961":{"_id":"o1363f106aa19961","component":"1f1781882618102","state":"click","action":"function click() { \n var editor = this.require('editor'),\n data = this.require('store').data(),\n extra = this.require('store').extra();\n \n if (extra && extra.context) {\n data[extra.context] = editor.getValue();\n this.require('store').data(data);\n }\n \n delete data.classInfo;\n \n editor.setEditor('json', JSON.stringify(data, null, '\\t'), 2);\n}","useCoreAPI":false,"core":false},"n1a54b1da681f33e":{"_id":"n1a54b1da681f33e","component":"Workspace","state":"render","action":"function render() {\n var Editor = null,\n editor = null,\n designer = null;\n\n Editor = this.require('Editor');\n designer = this.require('designer');\n\n if (designer.isCordova()) {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'codemirror',\n 'context': 'system',\n 'editor': CodeMirror($('#designer-editor')[0], {\n lineNumbers: true,\n styleActiveLine: true,\n 'mode': 'text/x-textile',\n 'theme': 'eclipse',\n 'tabSize': 2,\n 'autoCloseBrackets': true\n })\n });\n } else {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'ace',\n 'context': 'system',\n 'editor': ace.edit('designer-editor')\n });\n }\n \n editor.render();\n}","useCoreAPI":false,"core":false},"g1e35b1112512787":{"_id":"g1e35b1112512787","component":"Designer","state":"render","action":"function render() {\n var id = '',\n system = null,\n extra = {};\n \n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1]);\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n \n // render\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('workspace').render();\n \n // get parameters\n id = document.location.href.split('#')[1].split('?')[0];\n \n // set editor\n system = this.require('storage').get(id);\n \n this.require('factory').create(system);\n \n // extensions\n this.installExtensions();\n\n this.require('store').uuid(id);\n this.require('store').data(system);\n\n document.title = 'system ' + system.name;\n\n extra.context = 'name';\n this.require('store').extra(extra);\n\n this.require('editor').initValue(this.require('store').data().name, 1);\n \n this.require('router').update();\n \n // shorcuts\n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"f199b4184ea1639d":{"_id":"f199b4184ea1639d","component":"Designer","state":"save","action":"function save() { \n var val = this.require('editor').getValue(),\n designer = this.require('designer'),\n store = this.require('store').data();\n\n switch (this.require('state').menu()) {\n case 'name':\n val = val.trim();\n val = val.replace(/\\s|\\t/gi, '-')\n .replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '')\n .replace(/\\r|\\n/gi,'');\n this.require('editor').setValue(val);\n store.name = val;\n document.title = 'system ' + store.name;\n break;\n case 'description':\n store.description = val.trim();\n break;\n case 'version':\n store.version = val.trim();\n break;\n case 'bundle':\n store = JSON.parse(val);\n document.title = 'system ' + store.name;\n break;\n default:\n break;\n }\n\n this.require('store').data(store);\n\n this.require('channel').$editorUpdateSystem(this.require('store').uuid(), this.require('store').data());\n this.require('message').clean();\n this.require('message').success('System saved.');\n}","useCoreAPI":false,"core":false},"x1645919b431ab61":{"_id":"x1645919b431ab61","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n href = '';\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1].split('?')[0];\n menubar[i].href = '#' + this.require('store').uuid() + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"g1c050192531348c":{"_id":"g1c050192531348c","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state');\n\n if (designer.isCordova()) {\n state.messages().push(message);\n }\n\n this.require('storage').set('system-designer-message', message);\n\n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\t\n}","useCoreAPI":false,"core":false},"k1473f1cbe41b194":{"_id":"k1473f1cbe41b194","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function (obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":false,"core":false},"w1aa16102d712d94":{"_id":"w1aa16102d712d94","component":"x1cfa910cac1f8da","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"l11b92128ce147e8":{"_id":"l11b92128ce147e8","component":"k13bb31b8681ba70","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"p1e6c41a4bc1b4d3":{"_id":"p1e6c41a4bc1b4d3","component":"Designer","state":"addShortcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component","diagram"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"2.9.0"}},"Diagram":{},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.1.1","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1d113198721599d":{"_id":"l1d113198721599d","_name":"MenuItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"u1f9a01abe31b3bf":{"_id":"u1f9a01abe31b3bf","_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"menuitem-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"name":{"type":"string","readOnly":false,"mandatory":false,"default":"template"},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"},"render":{},"click":{}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() { \n\tvar name = $('#modal-modeljson-name').val(),\n\t jsonText = $('#modal-modeljson-json').val(),\n\t json = null,\n\t schema = {},\n\t model = {},\n\t property = '',\n\t type = '',\n\t typeName = '',\n\t arrayType = '',\n\t that = this,\n\t createdTypes = [];\n\t \n\tfunction _getTypeName(parent, name) {\n\t var result = name;\n\t \n\t if (!_validType(name)) {\n\t if (parent) {\n\t result = parent + '_' + name;\n\t } else {\n\t result = name + Math.floor(Math.random() * 11);\n\t }\n\t }\n\t \n\t return result;\n\t} \n\n function _getType(value) {\n var type = '';\n \n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n \n return type;\n } \n \n function _validName(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n } \n \n function _validType(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n return result;\n } \n \n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = ''; \n \n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false); \n \n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n switch (type) {\n case 'object':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = {};\n break;\n case 'number':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'number';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = 0;\n break;\n case 'boolean':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'boolean';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = false;\n break;\n case 'array':\n typeDef.schema[property] = {};\n typeDef.schema[property].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n \n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n \t typeDef.schema[property].type = [_createTypeFromObject(name, property, obj[property][0])];\n \t typeDef.schema[property].default = [];\n \t } else {\n \t typeDef.schema[property].type = ['object'];\n \t typeDef.schema[property].default = [];\n \t }\n } else {\n typeDef.schema[property].type = [arrayType];\n typeDef.schema[property].default = [];\n }\n } else {\n typeDef.schema[property].type = ['any'];\n typeDef.schema[property].default = [];\n\t }\n break;\n default:\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'string';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n \n return typeName;\n }\n \n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n\tif (name && _validName(name) && jsonText) {\n\t try {\n\t json = JSON.parse(jsonText);\n\t if (json) {\n\t // schema\n\t schema = this.require('factory').addSchema(name.trim());\n\t \n\t schema._inherit = [];\n\t this.require('factory').updateSchema(schema._id, schema);\n\t \n\t this.require('designer').save();\n\t \n\t for (property in json) {\n\t if (property.indexOf('_') !== 0) {\n \t type = _getType(json[property]);\n \t if (type === 'array') {\n \t schema[property] = 'collection';\n \t } else {\n \t schema[property] = 'property';\n \t }\n\t }\n\t }\n\t \n\t this.require('factory').updateSchema(schema._id, schema);\n\t this.require('designer').save();\n\t \n\t // model\n\t model = this.require('factory').createModel(schema);\n\t this.require('designer').save();\n\n\t for (property in schema) {\n\t if (property.indexOf('_') !== 0) {\n\t type = _getType(json[property]);\n\t switch (type) {\n\t case 'object':\n\t if (json[property] !== null) {\n\t model[property].type = _createTypeFromObject('', property, json[property]);\n\t model[property].default = {};\n\t } else {\n\t model[property].type = 'object';\n\t model[property].default = {};\n\t }\n\t break;\n\t case 'number':\n\t model[property].type = 'number';\n\t model[property].default = 0;\n\t break;\n\t case 'boolean':\n\t model[property].type = 'boolean';\n\t model[property].default = false;\n\t break;\n\t case 'array':\n\t if (typeof json[property][0] !== 'undefined') {\n\t arrayType = _getType(json[property][0]);\n\t if (arrayType === 'object') {\n\t if (json[property][0] !== null) {\n \t model[property].type = [_createTypeFromObject('', property, json[property][0])];\n \t model[property].default = [];\n \t } else {\n \t model[property].type = ['object'];\n \t model[property].default = [];\n \t }\n\t } else {\n\t model[property].type = [arrayType];\n\t model[property].default = [];\n\t }\n\t } else {\n\t model[property].type = ['any'];\n\t model[property].default = [];\n\t }\n\t break;\n\t \tcase 'string':\n\t model[property].type = 'string';\n\t model[property].default = '';\n\t break;\n\t default:\n\t break;\n\t }\n\t }\n\t }\n\t \n\t this.require('factory').updateModel(model._id, model);\n\t this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\t \n\t this.require('message').success('A model has been created for the JSON.');\n\t }\n\t } catch(e) {\n\t this.hide();\n\t this.require('message').warning('Can not create the model: the JSON is invalid.');\n\t }\n\t} \n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"MenuItem":{},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2018 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v2.9.0"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"A behavior is the action to do when a method or an event is called."},"help-components.html":{"_id":"help-components.html","source":"Components are your classes instances. Their states are saved in a store, a JSON object."},"help-logs.html":{"_id":"help-logs.html","source":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "},"help-models.html":{"_id":"help-models.html","source":"A model is an UML representation of your classes. It is generated from a schema."},"help-schemas.html":{"_id":"help-schemas.html","source":"A schema is the definition of your model. Models are generated based on the schema definition."},"help-system.html":{"_id":"help-system.html","source":"An application is a system. Once you have created one, your next step is to create a schema."},"help-types.html":{"_id":"help-types.html","source":"A type is used in your model to define an enumeration or a structure."},"menu-action-search.html":{"_id":"menu-action-search.html","source":"
    \n
    \n \n
    \n
    "},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-guide.html":{"_id":"menu-item-guide.html","source":"Guide"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs0"},"menu-item-message-save.html":{"_id":"menu-item-message-save.html","source":" file saved!"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-quick-start.html":{"_id":"menu-item-quick-start.html","source":"Quick Start"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"},"toolbar-item-diagram.html":{"_id":"toolbar-item-diagram.html","source":""},"menu-item-diagram.html":{"_id":"menu-item-diagram.html","source":"Class diagram"},"toolbar-item-zoomout.html":{"_id":"toolbar-item-zoomout.html","source":""},"toolbar-item-zoomin.html":{"_id":"toolbar-item-zoomin.html","source":""},"toolbar-item-zoominit.html":{"_id":"toolbar-item-zoominit.html","source":""},"toolbar-item-export-diagram.html":{"_id":"toolbar-item-export-diagram.html","source":""}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.0.0","description":"Quick start\n\nThis system is taken from the quick start: https://system-designer.readme.io/docs/quick-start","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n var luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n var result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vador":{"_id":"vador","father":"","firstName":"Dark","lastName":"Vador"},"luke":{"_id":"luke","father":"vador","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"04-send-messages.json":{"_id":"04-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.0.0","description":"Send messages threw a channel\n\n\nYou can send messages from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. In '_Channel' 'send' method, define how to send the message to another channel (webRTC, XHR, ...).\n3. In another system, define how to get the message and send it to the system with: runtime.message().\n4. To send a message: this.require('channel').myevent(param1, param2, ...).\n5. To listen to the message, just add a behavior to the event.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.0.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"type":"css","readOnly":false,"mandatory":false,"default":""},"render":{}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{},"filter":{"type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n var html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n var div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n var items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n var author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.0.1","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n var http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"04-create-extension.json":{"_id":"04-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.1.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"05-listen-collection-events.json":{"_id":"05-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.0.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""},"field":{"type":"string","mandatory":true,"default":""},"value":{"type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"document":{"type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179be":{"_id":"1f8571164c179be","html":"menu-action-version.html","position":10,"type":"system"}},"MenuHeader":{"1fb101b99813a13":{"_id":"1fb101b99813a13","html":"menu-header-system.html","type":"system"}},"MenuItem":{"1f1781882618102":{"_id":"1f1781882618102","name":"bundle","html":"menu-item-bundle.html","position":50,"type":"system","platform":"all"},"1f1781882618114":{"_id":"1f1781882618114","name":"description","html":"menu-item-description.html","position":30,"type":"system","platform":"all"},"1f1781882618115":{"_id":"1f1781882618115","name":"name","html":"menu-item-name.html","position":10,"type":"system","platform":"all"},"1f1781882618116":{"_id":"1f1781882618116","name":"version","html":"menu-item-version.html","position":20,"type":"system","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"sdbc51200e11z03":{"_id":"sdbc51200e11z03","html":"toolbar-item-copy.html","position":50,"type":"system","platform":"electron"},"sdbc51200e11z04":{"_id":"sdbc51200e11z04","html":"toolbar-item-paste.html","position":60,"type":"system","platform":"electron"},"13a291c27f16311":{"_id":"13a291c27f16311","html":"toolbar-item-copyright.html","position":90,"type":"system","platform":"all"},"1dbc51200e116e4":{"_id":"1dbc51200e116e4","html":"toolbar-item-save.html","position":10,"type":"system","platform":"all"},"1dbc51200e11z10":{"_id":"1dbc51200e11z10","html":"toolbar-item-help.html","position":80,"type":"system","platform":"all"},"sdbc51200e11z00":{"_id":"sdbc51200e11z00","html":"toolbar-item-undo.html","position":20,"type":"system","platform":"all"},"sdbc51200e11z01":{"_id":"sdbc51200e11z01","html":"toolbar-item-redo.html","position":30,"type":"system","platform":"all"},"sdbc51200e11z02":{"_id":"sdbc51200e11z02","html":"toolbar-item-select-all.html","position":40,"type":"system","platform":"all"},"x1cfa910cac1f8da":{"_id":"x1cfa910cac1f8da","html":"toolbar-item-command.html","platform":"web","position":75,"type":"system"},"k13bb31b8681ba70":{"_id":"k13bb31b8681ba70","html":"toolbar-item-command.html","platform":"electron","position":75,"type":"system"}}},"_id":"v1c4421834f1995a"}); \ No newline at end of file diff --git a/designer/scripts/editor-type.js b/designer/scripts/editor-type.js index f7ca477..d83d00b 100644 --- a/designer/scripts/editor-type.js +++ b/designer/scripts/editor-type.js @@ -1,3 +1,3 @@ // System Designer - Copyright 2018 Erwan Carriou // Licensed under the Apache License, Version 2.0 (the "License") -runtime.install({"name":"editor-type","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"]},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"2.8.3"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"any","params":[{"name":"param","type":"any","mandatory":false,"default":null}]},"addShorcuts":{},"addShortcuts":{"params":[{"name":"param","type":"any","mandatory":false,"default":null}],"result":"any"}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}]}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":false}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57"},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null;\n \n if (extension.installed) { \n system = extension.source;\n \n try {\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n } catch (e) {\n this.require('message').danger('Can not install an extension.');\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n\n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').hide();\n }\n } else {\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').show();\n }\n }\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-file').attr('checked', false);\n $('#designer-dialog-import-modal-from-library').attr('checked', true);\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n that.data(JSON.parse(json));\n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').uninstall('ext_' + system._id)\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n downloadLink.click();\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n if (system.name === name) {\n result = false;\n break;\n }\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n \n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"snippet\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'snippet' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'snippet' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'snippet' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'snippet' });\n }\n \n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n \n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n \n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n \n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n \n // snippets\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet:'{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'snippet' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n \n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"snippet\" });\n }\n \n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n \n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n \n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n \n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n \n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n\n repo1.writeFile('master', system.name + '.json', JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html', htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js', jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^2.8.4';\n\n repo4.writeFile('master', 'package.json', JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.source());\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n \n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n });\n\n menuActions.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('afterbegin', '
  • ' + action.html().source() + '');\n });\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n this.require('state').messages(messages);\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n for (propName in this.document().schema) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n }\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n\n systemId = this.require('factory').system().id();\n schema = _getSchema(this.model());\n model = _getModel(this.model());\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = this.document()[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n if (modelName === '_Component') {\n modelName = _getModelFromComponent(propVal);\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n function gen() {\n return Math.floor((1 + Math.random()) * 0x10000).toString(16);\n }\n function getPrefix() {\n var validPrefix = 'abcdefghijklmnopqrstuvwxyz';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return getPrefix() + gen() + gen() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n\n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n \n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system !== 'undefined':\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && typeof system !== 'undefined':\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && typeof system !== 'undefined':\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && typeof system !== 'undefined' && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n default:\n break;\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin', \n template.source().replace(/{{message}}/gi, message));\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom) {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (typeof system === 'undefined') {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"m134c713c841c559":{"_id":"m134c713c841c559","component":"vdbc51200e11z03","state":"click","action":"function click() { \n $('#designer-toolbar-item-copy').tooltip('hide');\n this.require('editor').copy(); \n}"},"w1f5751bd9e15f00":{"_id":"w1f5751bd9e15f00","component":"vdbc51200e11z04","state":"click","action":"function click() { \n $('#designer-toolbar-item-paste').tooltip('hide');\n this.require('editor').paste(); \n}"},"s163371531d1ec0a":{"_id":"s163371531d1ec0a","component":"vdbc51200e11z02","state":"click","action":"function click() { \n $('#designer-toolbar-item-select-all').tooltip('hide');\n this.require('editor').selectAll(); \n}"},"e1eabd18b6717d03":{"_id":"e1eabd18b6717d03","component":"vdbc51200e11z01","state":"click","action":"function click() { \n $('#designer-toolbar-item-redo').tooltip('hide');\n this.require('editor').redo(); \n}"},"h1bee51638018e23":{"_id":"h1bee51638018e23","component":"vdbc51200e11z00","state":"click","action":"function click() { \n $('#designer-toolbar-item-undo').tooltip('hide');\n this.require('editor').undo(); \n}"},"t197d11eeee1e568":{"_id":"t197d11eeee1e568","component":"1dbc51200e116e6","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"g1dfae1d94d10ce1":{"_id":"g1dfae1d94d10ce1","component":"1dbc51200e116e5","state":"click","action":"function click() {\n $('#designer-toolbar-item-save').tooltip('hide');\n this.require('designer').save();\n}"},"y1fd9e171d717b39":{"_id":"y1fd9e171d717b39","component":"1dbc51200e116e10","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n this.require('designer').open('https://system-designer.readme.io/docs/create-a-type', '_blank', true); \n}"},"w108111c7dc1ca6b":{"_id":"w108111c7dc1ca6b","component":"Workspace","state":"render","action":"function render() { \n var Editor = null,\n designer = null,\n editor = null;\n\n Editor = this.require('Editor');\n designer = this.require('designer');\n\n if (designer.isCordova()) {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'codemirror',\n 'context': 'type',\n 'editor': CodeMirror($('#designer-editor')[0], {\n lineNumbers: true,\n styleActiveLine: true,\n 'mode': 'application/json',\n 'theme': 'eclipse',\n 'tabSize': 2,\n 'autoCloseBrackets': true\n })\n });\n } else {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'ace',\n 'context': 'type',\n 'editor': ace.edit('designer-editor')\n });\n }\n \n editor.render();\n}","useCoreAPI":false,"core":false},"t17faa1c1e816821":{"_id":"t17faa1c1e816821","component":"Designer","state":"render","action":"function render() {\n var id = '',\n systemId = '',\n system = '',\n type = '';\n \n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1]);\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n\n // render\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('workspace').render();\n \n // get parameters\n id = decodeURIComponent(document.location.href.split('#')[1].split('?')[0]);\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n // set editors\n system = this.require('storage').get(systemId);\n this.require('factory').create(system);\n \n // extensions\n this.installExtensions();\n \n type = system.types[id];\n this.require('store').uuid(id);\n this.require('store').data(type);\n\n document.title = 'type ' + id + ' · system ' + system.name;\n\n this.require('editor').initValue(JSON.stringify(type, null, '\\t'), 2);\n\n this.require('router').update();\n \n // shorcuts\n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"y14257199751564c":{"_id":"y14257199751564c","component":"Designer","state":"save","action":"function save() { \n var val = this.require('editor').getValue(),\n type = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n try {\n type = JSON.parse(val);\n } catch (e) {\n message.danger('Can not save your type: your type has an invalid structure.');\n return;\n }\n\n if (!type.name) {\n message.danger('The property \\'name\\' is missing.');\n return;\n }\n \n // clean name\n type.name = type.name.replace(/\\s|\\t/gi, '_')\n .replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '')\n .replace(/\\r|\\n/gi,'');\n\n if (!type.type) {\n message.danger('The property \\'type\\' is missing.');\n return;\n }\n\n if (type._id && type._id.indexOf(' ') !== -1) {\n message.danger('Invalid \\'_id\\'.
    Space is not authorized in the value of \\'_id\\'.');\n return;\n }\n\n this.require('store').data(type);\n\n // check if ID change\n if (this.require('store').uuid() !== this.require('store').data().name) {\n this.require('channel').$editorDeleteType(this.require('store').uuid());\n this.require('store').uuid(this.require('store').data().name);\n\n // update title\n document.title = 'type ' + this.require('store').uuid() + ' · ' + document.title.split('·')[1].trim();\n }\n\n this.require('channel').$editorUpdateType(this.require('store').uuid(), this.require('store').data());\n message.success('Type saved.');\n}","useCoreAPI":false,"core":false},"r1df8d1a54e1c14f":{"_id":"r1df8d1a54e1c14f","component":"w1667a15e2a1e2ef","state":"start","action":"function start() { \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"b182a81e1c7173c3":{"_id":"b182a81e1c7173c3","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n href = '';\n\n id = decodeURIComponent(document.location.href.split('#')[1]);\n collection = document.location.href.split('#')[2];\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1];\n menubar[i].href = '#' + id + '#' + collection + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"t1249a1a35319140":{"_id":"t1249a1a35319140","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state');\n \n if (designer.isCordova()) {\n state.messages().push(message);\n }\n \n this.require('storage').set('system-designer-message', message);\n \n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\n}","useCoreAPI":false,"core":false},"c1b2a41e5e61459c":{"_id":"c1b2a41e5e61459c","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function changed(obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n}, true);\n}","useCoreAPI":false,"core":false},"a1eabd1ce561031c":{"_id":"a1eabd1ce561031c","component":"y174dd1c4fb187ed","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"y133f11e82c1aad7":{"_id":"y133f11e82c1aad7","component":"k1423a15ea412f5d","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"s143c7194b515fb4":{"_id":"s143c7194b515fb4","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar result = {};\n\treturn result;\n}","useCoreAPI":false,"core":false},"x13d2a197b411642":{"_id":"x13d2a197b411642","component":"Designer","state":"addShortcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"2.8.3"}},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.1.1","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1d113198721599d":{"_id":"l1d113198721599d","_name":"MenuItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"u1f9a01abe31b3bf":{"_id":"u1f9a01abe31b3bf","_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"menuitem-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"name":{"type":"string","readOnly":false,"mandatory":false,"default":"template"},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"},"render":{},"click":{}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() { \n\tvar name = $('#modal-modeljson-name').val(),\n\t jsonText = $('#modal-modeljson-json').val(),\n\t json = null,\n\t schema = {},\n\t model = {},\n\t property = '',\n\t type = '',\n\t typeName = '',\n\t arrayType = '',\n\t that = this,\n\t createdTypes = [];\n\t \n\tfunction _getTypeName(parent, name) {\n\t var result = name;\n\t \n\t if (!_validType(name)) {\n\t if (parent) {\n\t result = parent + '_' + name;\n\t } else {\n\t result = name + Math.floor(Math.random() * 11);\n\t }\n\t }\n\t \n\t return result;\n\t} \n\n function _getType(value) {\n var type = '';\n \n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n \n return type;\n } \n \n function _validName(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n } \n \n function _validType(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n return result;\n } \n \n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = ''; \n \n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false); \n \n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n switch (type) {\n case 'object':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = {};\n break;\n case 'number':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'number';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = 0;\n break;\n case 'boolean':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'boolean';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = false;\n break;\n case 'array':\n typeDef.schema[property] = {};\n typeDef.schema[property].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n \n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n \t typeDef.schema[property].type = [_createTypeFromObject(name, property, obj[property][0])];\n \t typeDef.schema[property].default = [];\n \t } else {\n \t typeDef.schema[property].type = ['object'];\n \t typeDef.schema[property].default = [];\n \t }\n } else {\n typeDef.schema[property].type = [arrayType];\n typeDef.schema[property].default = [];\n }\n } else {\n typeDef.schema[property].type = ['any'];\n typeDef.schema[property].default = [];\n\t }\n break;\n default:\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'string';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n \n return typeName;\n }\n \n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n\tif (name && _validName(name) && jsonText) {\n\t try {\n\t json = JSON.parse(jsonText);\n\t if (json) {\n\t // schema\n\t schema = this.require('factory').addSchema(name.trim());\n\t \n\t schema._inherit = [];\n\t this.require('factory').updateSchema(schema._id, schema);\n\t \n\t this.require('designer').save();\n\t \n\t for (property in json) {\n\t if (property.indexOf('_') !== 0) {\n \t type = _getType(json[property]);\n \t if (type === 'array') {\n \t schema[property] = 'collection';\n \t } else {\n \t schema[property] = 'property';\n \t }\n\t }\n\t }\n\t \n\t this.require('factory').updateSchema(schema._id, schema);\n\t this.require('designer').save();\n\t \n\t // model\n\t model = this.require('factory').createModel(schema);\n\t this.require('designer').save();\n\n\t for (property in schema) {\n\t if (property.indexOf('_') !== 0) {\n\t type = _getType(json[property]);\n\t switch (type) {\n\t case 'object':\n\t if (json[property] !== null) {\n\t model[property].type = _createTypeFromObject('', property, json[property]);\n\t model[property].default = {};\n\t } else {\n\t model[property].type = 'object';\n\t model[property].default = {};\n\t }\n\t break;\n\t case 'number':\n\t model[property].type = 'number';\n\t model[property].default = 0;\n\t break;\n\t case 'boolean':\n\t model[property].type = 'boolean';\n\t model[property].default = false;\n\t break;\n\t case 'array':\n\t if (typeof json[property][0] !== 'undefined') {\n\t arrayType = _getType(json[property][0]);\n\t if (arrayType === 'object') {\n\t if (json[property][0] !== null) {\n \t model[property].type = [_createTypeFromObject('', property, json[property][0])];\n \t model[property].default = [];\n \t } else {\n \t model[property].type = ['object'];\n \t model[property].default = [];\n \t }\n\t } else {\n\t model[property].type = [arrayType];\n\t model[property].default = [];\n\t }\n\t } else {\n\t model[property].type = ['any'];\n\t model[property].default = [];\n\t }\n\t break;\n\t \tcase 'string':\n\t model[property].type = 'string';\n\t model[property].default = '';\n\t break;\n\t default:\n\t break;\n\t }\n\t }\n\t }\n\t \n\t this.require('factory').updateModel(model._id, model);\n\t this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\t \n\t this.require('message').success('A model has been created for the JSON.');\n\t }\n\t } catch(e) {\n\t this.hide();\n\t this.require('message').warning('Can not create the model: the JSON is invalid.');\n\t }\n\t} \n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"MenuItem":{},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2018 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v2.8.3"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"A behavior is the action to do when a method or an event is called."},"help-components.html":{"_id":"help-components.html","source":"Components are your classes instances. Their states are saved in a store, a JSON object."},"help-logs.html":{"_id":"help-logs.html","source":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "},"help-models.html":{"_id":"help-models.html","source":"A model is an UML representation of your classes. It is generated from a schema."},"help-schemas.html":{"_id":"help-schemas.html","source":"A schema is the definition of your model. Models are generated based on the schema definition."},"help-system.html":{"_id":"help-system.html","source":"An application is a system. Once you have created one, your next step is to create a schema."},"help-types.html":{"_id":"help-types.html","source":"A type is used in your model to define an enumeration or a structure."},"menu-action-search.html":{"_id":"menu-action-search.html","source":"
    \n
    \n \n
    \n
    "},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-guide.html":{"_id":"menu-item-guide.html","source":"Guide"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs"},"menu-item-message-save.html":{"_id":"menu-item-message-save.html","source":" file saved!"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-quick-start.html":{"_id":"menu-item-quick-start.html","source":"Quick Start"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.0.0","description":"Quick start\n\nThis system is taken from the quick start: https://system-designer.readme.io/docs/quick-start","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n var luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n var result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vador":{"_id":"vador","father":"","firstName":"Dark","lastName":"Vador"},"luke":{"_id":"luke","father":"vador","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"04-send-messages.json":{"_id":"04-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.0.0","description":"Send messages threw a channel\n\n\nYou can send messages from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. In '_Channel' 'send' method, define how to send the message to another channel (webRTC, XHR, ...).\n3. In another system, define how to get the message and send it to the system with: runtime.message().\n4. To send a message: this.require('channel').myevent(param1, param2, ...).\n5. To listen to the message, just add a behavior to the event.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.0.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"type":"css","readOnly":false,"mandatory":false,"default":""},"render":{}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{},"filter":{"type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n var html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n var div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n var items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n var author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.0.1","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n var http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"04-create-extension.json":{"_id":"04-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.1.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"05-listen-collection-events.json":{"_id":"05-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.0.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""},"field":{"type":"string","mandatory":true,"default":""},"value":{"type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"document":{"type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179bf":{"_id":"1f8571164c179bf","html":"menu-action-version.html","position":10,"type":"type"}},"MenuHeader":{"1fb101b99813a14":{"_id":"1fb101b99813a14","html":"menu-header-type.html","type":"type"}},"MenuItem":{"1f1781882618104":{"_id":"1f1781882618104","name":"type","html":"menu-item-type.html","position":10,"type":"type","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"vdbc51200e11z03":{"_id":"vdbc51200e11z03","html":"toolbar-item-copy.html","position":50,"type":"type","platform":"electron"},"vdbc51200e11z04":{"_id":"vdbc51200e11z04","html":"toolbar-item-paste.html","position":60,"type":"type","platform":"electron"},"1dbc51200e116e10":{"_id":"1dbc51200e116e10","html":"toolbar-item-help.html","position":80,"type":"type","platform":"all"},"1dbc51200e116e5":{"_id":"1dbc51200e116e5","html":"toolbar-item-save.html","position":10,"type":"type","platform":"all"},"1dbc51200e116e6":{"_id":"1dbc51200e116e6","html":"toolbar-item-copyright.html","position":90,"type":"type","platform":"all"},"vdbc51200e11z00":{"_id":"vdbc51200e11z00","html":"toolbar-item-undo.html","position":20,"type":"type","platform":"all"},"vdbc51200e11z01":{"_id":"vdbc51200e11z01","html":"toolbar-item-redo.html","position":30,"type":"type","platform":"all"},"vdbc51200e11z02":{"_id":"vdbc51200e11z02","html":"toolbar-item-select-all.html","position":40,"type":"type","platform":"all"},"y174dd1c4fb187ed":{"_id":"y174dd1c4fb187ed","html":"toolbar-item-command.html","platform":"web","position":75,"type":"type"},"k1423a15ea412f5d":{"_id":"k1423a15ea412f5d","html":"toolbar-item-command.html","platform":"electron","position":75,"type":"type"}}},"_id":"w1667a15e2a1e2ef"}); \ No newline at end of file +runtime.install({"name":"editor-type","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"v123b51abbb18712":{"_id":"v123b51abbb18712","_name":"Diagram","_inherit":["_Component"],"ref":"property","zoom":"property","render":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method","toGraphviz":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","isType":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"]},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"2.9.0"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"any","params":[{"name":"param","type":"any","mandatory":false,"default":null}]},"addShorcuts":{},"addShortcuts":{"params":[{"name":"param","type":"any","mandatory":false,"default":null}],"result":"any"}},"b169321637f19101":{"_id":"b169321637f19101","_name":"Diagram","_description":"","ref":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""},"zoom":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":1},"render":{"description":"","params":[],"result":"any"}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toGraphviz":{"description":"","params":[],"result":"string"}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":false}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57"},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"},"isType":{"description":"","params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null;\n \n if (extension.installed) { \n system = extension.source;\n \n try {\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n } catch (e) {\n this.require('message').danger('Can not install an extension.');\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n\n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').hide();\n }\n } else {\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').show();\n }\n }\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-file').attr('checked', false);\n $('#designer-dialog-import-modal-from-library').attr('checked', true);\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n that.data(JSON.parse(json));\n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-export-graphviz');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').uninstall('ext_' + system._id)\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-graphviz').prop('checked'):\n textToWrite = this.require('export').toGraphviz();\n fileNameToSaveAs = this.require('factory').system().name() + '.gv';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n downloadLink.click();\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n if (system.name === name) {\n result = false;\n break;\n }\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n \n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"snippet\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'snippet' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'snippet' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'snippet' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'snippet' });\n }\n \n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n \n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n \n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n \n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n \n // snippets\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet:'{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'snippet' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n \n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"snippet\" });\n }\n \n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n \n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n \n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n \n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n \n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"e13c7916b1a15fc4":{"_id":"e13c7916b1a15fc4","component":"Export","state":"toGraphviz","action":"function toGraphviz() {\n var schemas = this.require('factory').system().schemas();\n var models = this.require('factory').system().models();\n var inheritance = '';\n var modelId = '';\n var modelName = '';\n var modelDescription = '';\n var propName = '';\n var propVal = '';\n var attributes = '';\n var methods = '';\n var result = '';\n var links = '';\n var collections = '';\n var that = this;\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n // create model\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n modelDescription += '\\n\\n\\t' + modelName + ' [\\r\\t\\tlabel = \"{' + modelName + '|';\n \n attributes = '';\n methods = '';\n\n for (propName in models[modelId]) {\n if (models[modelId].hasOwnProperty(propName)) {\n propVal = models[modelId][propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (modelId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (modelId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n }\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n }\n }\n }\n break;\n \n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + params + ' : ' + result + '\\\\l';\n } else {\n methods += '+ ' + propName + params + ' : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + params + '\\\\l';\n } else {\n methods += '+ ' + propName + params + '\\\\l';\n }\n }\n break;\n \n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n \n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + '() : ' + result + '\\\\l';\n } else {\n methods += '+ ' + propName + '() : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + '()\\\\l';\n } else {\n methods += '+ ' + propName + '()\\\\l';\n }\n }\n break;\n }\n }\n }\n\n modelDescription += attributes + '|' + methods;\n modelDescription += '}\"\\r\\t]';\n }\n\n // create inheritance links\n for (var schema in schemas) {\n if (schemas[schema]._inherit && schemas[schema]._inherit.length) {\n schemas[schema]._inherit.forEach(function (parent) {\n inheritance += '\\n\\t' + schemas[schema]._name + ' -> ' + parent;\n });\n }\n }\n \n // case of Component\n if (inheritance.indexOf('_Component') !== -1) {\n modelDescription += `\\n\\t_Component [\n label = \"{_Component|+ id : string\\\\l|+ classInfo() : _ClassInfo\\\\l+ init(conf : object)\\\\l+ destroy()\\\\l+ on(state : string, action : function, useCoreAPI : boolean, isCore : boolean) : string\\\\l+ off(state : string, behaviorId : string)\\\\l+ require(id : string) : _Component\\\\l+ error(data : errorParam)\\\\l}\"\n ]` \n };\n\n let generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n \n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]${modelDescription}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"1\"\n taillabel = \"\"\n ]\n ${links}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"0..*\"\n taillabel = \"\"\n ]\n ${collections}\n\n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n arrowhead = \"empty\"\n headlabel = \"\"\n taillabel = \"\"\n ]\n ${inheritance}\n}`;\n\n return generatedDiagram;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n\n repo1.writeFile('master', system.name + '.json', JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html', htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js', jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^2.9.0';\n\n repo4.writeFile('master', 'package.json', JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.source());\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n \n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n });\n\n menuActions.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('afterbegin', '
  • ' + action.html().source() + '');\n });\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n this.require('state').messages(messages);\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n for (propName in this.document().schema) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n }\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n\n systemId = this.require('factory').system().id();\n schema = _getSchema(this.model());\n model = _getModel(this.model());\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = this.document()[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n if (modelName === '_Component') {\n modelName = _getModelFromComponent(propVal);\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n function gen() {\n return Math.floor((1 + Math.random()) * 0x10000).toString(16);\n }\n function getPrefix() {\n var validPrefix = 'abcdefghijklmnopqrstuvwxyz';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return getPrefix() + gen() + gen() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"v119e617ef513e94":{"_id":"v119e617ef513e94","component":"SystemFactory","state":"isType","action":"function isType(name) { \n var types = this.system().types(),\n result = false,\n prop = '';\n\n\tif (!result) {\n\t for (prop in types) {\n\t if (schemas[prop].name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n\n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n \n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system !== 'undefined':\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && typeof system !== 'undefined':\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && typeof system !== 'undefined':\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && typeof system !== 'undefined' && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n default:\n break;\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin', \n template.source().replace(/{{message}}/gi, message));\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom) {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (typeof system === 'undefined') {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"m134c713c841c559":{"_id":"m134c713c841c559","component":"vdbc51200e11z03","state":"click","action":"function click() { \n $('#designer-toolbar-item-copy').tooltip('hide');\n this.require('editor').copy();\n this.require('message').success('The text has been copied to the clipboard.');\n}"},"w1f5751bd9e15f00":{"_id":"w1f5751bd9e15f00","component":"vdbc51200e11z04","state":"click","action":"function click() { \n $('#designer-toolbar-item-paste').tooltip('hide');\n this.require('editor').paste(); \n}"},"s163371531d1ec0a":{"_id":"s163371531d1ec0a","component":"vdbc51200e11z02","state":"click","action":"function click() { \n $('#designer-toolbar-item-select-all').tooltip('hide');\n this.require('editor').selectAll(); \n}"},"e1eabd18b6717d03":{"_id":"e1eabd18b6717d03","component":"vdbc51200e11z01","state":"click","action":"function click() { \n $('#designer-toolbar-item-redo').tooltip('hide');\n this.require('editor').redo(); \n}"},"h1bee51638018e23":{"_id":"h1bee51638018e23","component":"vdbc51200e11z00","state":"click","action":"function click() { \n $('#designer-toolbar-item-undo').tooltip('hide');\n this.require('editor').undo(); \n}"},"t197d11eeee1e568":{"_id":"t197d11eeee1e568","component":"1dbc51200e116e6","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"g1dfae1d94d10ce1":{"_id":"g1dfae1d94d10ce1","component":"1dbc51200e116e5","state":"click","action":"function click() {\n $('#designer-toolbar-item-save').tooltip('hide');\n this.require('designer').save();\n}"},"y1fd9e171d717b39":{"_id":"y1fd9e171d717b39","component":"1dbc51200e116e10","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n this.require('designer').open('https://system-designer.readme.io/docs/create-a-type', '_blank', true); \n}"},"w108111c7dc1ca6b":{"_id":"w108111c7dc1ca6b","component":"Workspace","state":"render","action":"function render() { \n var Editor = null,\n designer = null,\n editor = null;\n\n Editor = this.require('Editor');\n designer = this.require('designer');\n\n if (designer.isCordova()) {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'codemirror',\n 'context': 'type',\n 'editor': CodeMirror($('#designer-editor')[0], {\n lineNumbers: true,\n styleActiveLine: true,\n 'mode': 'application/json',\n 'theme': 'eclipse',\n 'tabSize': 2,\n 'autoCloseBrackets': true\n })\n });\n } else {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'ace',\n 'context': 'type',\n 'editor': ace.edit('designer-editor')\n });\n }\n \n editor.render();\n}","useCoreAPI":false,"core":false},"t17faa1c1e816821":{"_id":"t17faa1c1e816821","component":"Designer","state":"render","action":"function render() {\n var id = '',\n systemId = '',\n system = '',\n type = '';\n \n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1]);\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n\n // render\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('workspace').render();\n \n // get parameters\n id = decodeURIComponent(document.location.href.split('#')[1].split('?')[0]);\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n // set editors\n system = this.require('storage').get(systemId);\n this.require('factory').create(system);\n \n // extensions\n this.installExtensions();\n \n type = system.types[id];\n this.require('store').uuid(id);\n this.require('store').data(type);\n\n document.title = 'type ' + id + ' · system ' + system.name;\n\n this.require('editor').initValue(JSON.stringify(type, null, '\\t'), 2);\n\n this.require('router').update();\n \n // shorcuts\n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"y14257199751564c":{"_id":"y14257199751564c","component":"Designer","state":"save","action":"function save() { \n var val = this.require('editor').getValue(),\n type = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n try {\n type = JSON.parse(val);\n } catch (e) {\n message.danger('Can not save your type: your type has an invalid structure.');\n return;\n }\n\n if (!type.name) {\n message.danger('The property \\'name\\' is missing.');\n return;\n }\n \n // clean name\n type.name = type.name.replace(/\\s|\\t/gi, '_')\n .replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '')\n .replace(/\\r|\\n/gi,'');\n\n if (!type.type) {\n message.danger('The property \\'type\\' is missing.');\n return;\n }\n\n if (type._id && type._id.indexOf(' ') !== -1) {\n message.danger('Invalid \\'_id\\'.
    Space is not authorized in the value of \\'_id\\'.');\n return;\n }\n\n this.require('store').data(type);\n\n // check if ID change\n if (this.require('store').uuid() !== this.require('store').data().name) {\n this.require('channel').$editorDeleteType(this.require('store').uuid());\n this.require('store').uuid(this.require('store').data().name);\n\n // update title\n document.title = 'type ' + this.require('store').uuid() + ' · ' + document.title.split('·')[1].trim();\n }\n\n this.require('channel').$editorUpdateType(this.require('store').uuid(), this.require('store').data());\n message.success('Type saved.');\n}","useCoreAPI":false,"core":false},"r1df8d1a54e1c14f":{"_id":"r1df8d1a54e1c14f","component":"w1667a15e2a1e2ef","state":"start","action":"function start() { \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"b182a81e1c7173c3":{"_id":"b182a81e1c7173c3","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n href = '';\n\n id = decodeURIComponent(document.location.href.split('#')[1]);\n collection = document.location.href.split('#')[2];\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1];\n menubar[i].href = '#' + id + '#' + collection + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"t1249a1a35319140":{"_id":"t1249a1a35319140","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state');\n \n if (designer.isCordova()) {\n state.messages().push(message);\n }\n \n this.require('storage').set('system-designer-message', message);\n \n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\n}","useCoreAPI":false,"core":false},"c1b2a41e5e61459c":{"_id":"c1b2a41e5e61459c","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function changed(obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n}, true);\n}","useCoreAPI":false,"core":false},"a1eabd1ce561031c":{"_id":"a1eabd1ce561031c","component":"y174dd1c4fb187ed","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"y133f11e82c1aad7":{"_id":"y133f11e82c1aad7","component":"k1423a15ea412f5d","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"x13d2a197b411642":{"_id":"x13d2a197b411642","component":"Designer","state":"addShortcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component","diagram"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"2.9.0"}},"Diagram":{},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.1.1","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1d113198721599d":{"_id":"l1d113198721599d","_name":"MenuItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"u1f9a01abe31b3bf":{"_id":"u1f9a01abe31b3bf","_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"menuitem-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"name":{"type":"string","readOnly":false,"mandatory":false,"default":"template"},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"},"render":{},"click":{}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() { \n\tvar name = $('#modal-modeljson-name').val(),\n\t jsonText = $('#modal-modeljson-json').val(),\n\t json = null,\n\t schema = {},\n\t model = {},\n\t property = '',\n\t type = '',\n\t typeName = '',\n\t arrayType = '',\n\t that = this,\n\t createdTypes = [];\n\t \n\tfunction _getTypeName(parent, name) {\n\t var result = name;\n\t \n\t if (!_validType(name)) {\n\t if (parent) {\n\t result = parent + '_' + name;\n\t } else {\n\t result = name + Math.floor(Math.random() * 11);\n\t }\n\t }\n\t \n\t return result;\n\t} \n\n function _getType(value) {\n var type = '';\n \n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n \n return type;\n } \n \n function _validName(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n } \n \n function _validType(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n return result;\n } \n \n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = ''; \n \n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false); \n \n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n switch (type) {\n case 'object':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = {};\n break;\n case 'number':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'number';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = 0;\n break;\n case 'boolean':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'boolean';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = false;\n break;\n case 'array':\n typeDef.schema[property] = {};\n typeDef.schema[property].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n \n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n \t typeDef.schema[property].type = [_createTypeFromObject(name, property, obj[property][0])];\n \t typeDef.schema[property].default = [];\n \t } else {\n \t typeDef.schema[property].type = ['object'];\n \t typeDef.schema[property].default = [];\n \t }\n } else {\n typeDef.schema[property].type = [arrayType];\n typeDef.schema[property].default = [];\n }\n } else {\n typeDef.schema[property].type = ['any'];\n typeDef.schema[property].default = [];\n\t }\n break;\n default:\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'string';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n \n return typeName;\n }\n \n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n\tif (name && _validName(name) && jsonText) {\n\t try {\n\t json = JSON.parse(jsonText);\n\t if (json) {\n\t // schema\n\t schema = this.require('factory').addSchema(name.trim());\n\t \n\t schema._inherit = [];\n\t this.require('factory').updateSchema(schema._id, schema);\n\t \n\t this.require('designer').save();\n\t \n\t for (property in json) {\n\t if (property.indexOf('_') !== 0) {\n \t type = _getType(json[property]);\n \t if (type === 'array') {\n \t schema[property] = 'collection';\n \t } else {\n \t schema[property] = 'property';\n \t }\n\t }\n\t }\n\t \n\t this.require('factory').updateSchema(schema._id, schema);\n\t this.require('designer').save();\n\t \n\t // model\n\t model = this.require('factory').createModel(schema);\n\t this.require('designer').save();\n\n\t for (property in schema) {\n\t if (property.indexOf('_') !== 0) {\n\t type = _getType(json[property]);\n\t switch (type) {\n\t case 'object':\n\t if (json[property] !== null) {\n\t model[property].type = _createTypeFromObject('', property, json[property]);\n\t model[property].default = {};\n\t } else {\n\t model[property].type = 'object';\n\t model[property].default = {};\n\t }\n\t break;\n\t case 'number':\n\t model[property].type = 'number';\n\t model[property].default = 0;\n\t break;\n\t case 'boolean':\n\t model[property].type = 'boolean';\n\t model[property].default = false;\n\t break;\n\t case 'array':\n\t if (typeof json[property][0] !== 'undefined') {\n\t arrayType = _getType(json[property][0]);\n\t if (arrayType === 'object') {\n\t if (json[property][0] !== null) {\n \t model[property].type = [_createTypeFromObject('', property, json[property][0])];\n \t model[property].default = [];\n \t } else {\n \t model[property].type = ['object'];\n \t model[property].default = [];\n \t }\n\t } else {\n\t model[property].type = [arrayType];\n\t model[property].default = [];\n\t }\n\t } else {\n\t model[property].type = ['any'];\n\t model[property].default = [];\n\t }\n\t break;\n\t \tcase 'string':\n\t model[property].type = 'string';\n\t model[property].default = '';\n\t break;\n\t default:\n\t break;\n\t }\n\t }\n\t }\n\t \n\t this.require('factory').updateModel(model._id, model);\n\t this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\t \n\t this.require('message').success('A model has been created for the JSON.');\n\t }\n\t } catch(e) {\n\t this.hide();\n\t this.require('message').warning('Can not create the model: the JSON is invalid.');\n\t }\n\t} \n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"MenuItem":{},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2018 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v2.9.0"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"A behavior is the action to do when a method or an event is called."},"help-components.html":{"_id":"help-components.html","source":"Components are your classes instances. Their states are saved in a store, a JSON object."},"help-logs.html":{"_id":"help-logs.html","source":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "},"help-models.html":{"_id":"help-models.html","source":"A model is an UML representation of your classes. It is generated from a schema."},"help-schemas.html":{"_id":"help-schemas.html","source":"A schema is the definition of your model. Models are generated based on the schema definition."},"help-system.html":{"_id":"help-system.html","source":"An application is a system. Once you have created one, your next step is to create a schema."},"help-types.html":{"_id":"help-types.html","source":"A type is used in your model to define an enumeration or a structure."},"menu-action-search.html":{"_id":"menu-action-search.html","source":"
    \n
    \n \n
    \n
    "},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-guide.html":{"_id":"menu-item-guide.html","source":"Guide"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs0"},"menu-item-message-save.html":{"_id":"menu-item-message-save.html","source":" file saved!"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-quick-start.html":{"_id":"menu-item-quick-start.html","source":"Quick Start"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"},"toolbar-item-diagram.html":{"_id":"toolbar-item-diagram.html","source":""},"menu-item-diagram.html":{"_id":"menu-item-diagram.html","source":"Class diagram"},"toolbar-item-zoomout.html":{"_id":"toolbar-item-zoomout.html","source":""},"toolbar-item-zoomin.html":{"_id":"toolbar-item-zoomin.html","source":""},"toolbar-item-zoominit.html":{"_id":"toolbar-item-zoominit.html","source":""},"toolbar-item-export-diagram.html":{"_id":"toolbar-item-export-diagram.html","source":""}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.0.0","description":"Quick start\n\nThis system is taken from the quick start: https://system-designer.readme.io/docs/quick-start","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n var luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n var result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vador":{"_id":"vador","father":"","firstName":"Dark","lastName":"Vador"},"luke":{"_id":"luke","father":"vador","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"04-send-messages.json":{"_id":"04-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.0.0","description":"Send messages threw a channel\n\n\nYou can send messages from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. In '_Channel' 'send' method, define how to send the message to another channel (webRTC, XHR, ...).\n3. In another system, define how to get the message and send it to the system with: runtime.message().\n4. To send a message: this.require('channel').myevent(param1, param2, ...).\n5. To listen to the message, just add a behavior to the event.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.0.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"type":"css","readOnly":false,"mandatory":false,"default":""},"render":{}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{},"filter":{"type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n var html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n var div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n var items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n var author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.0.1","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n var http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"04-create-extension.json":{"_id":"04-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.1.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"05-listen-collection-events.json":{"_id":"05-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.0.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""},"field":{"type":"string","mandatory":true,"default":""},"value":{"type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"document":{"type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179bf":{"_id":"1f8571164c179bf","html":"menu-action-version.html","position":10,"type":"type"}},"MenuHeader":{"1fb101b99813a14":{"_id":"1fb101b99813a14","html":"menu-header-type.html","type":"type"}},"MenuItem":{"1f1781882618104":{"_id":"1f1781882618104","name":"type","html":"menu-item-type.html","position":10,"type":"type","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"vdbc51200e11z03":{"_id":"vdbc51200e11z03","html":"toolbar-item-copy.html","position":50,"type":"type","platform":"electron"},"vdbc51200e11z04":{"_id":"vdbc51200e11z04","html":"toolbar-item-paste.html","position":60,"type":"type","platform":"electron"},"1dbc51200e116e10":{"_id":"1dbc51200e116e10","html":"toolbar-item-help.html","position":80,"type":"type","platform":"all"},"1dbc51200e116e5":{"_id":"1dbc51200e116e5","html":"toolbar-item-save.html","position":10,"type":"type","platform":"all"},"1dbc51200e116e6":{"_id":"1dbc51200e116e6","html":"toolbar-item-copyright.html","position":90,"type":"type","platform":"all"},"vdbc51200e11z00":{"_id":"vdbc51200e11z00","html":"toolbar-item-undo.html","position":20,"type":"type","platform":"all"},"vdbc51200e11z01":{"_id":"vdbc51200e11z01","html":"toolbar-item-redo.html","position":30,"type":"type","platform":"all"},"vdbc51200e11z02":{"_id":"vdbc51200e11z02","html":"toolbar-item-select-all.html","position":40,"type":"type","platform":"all"},"y174dd1c4fb187ed":{"_id":"y174dd1c4fb187ed","html":"toolbar-item-command.html","platform":"web","position":75,"type":"type"},"k1423a15ea412f5d":{"_id":"k1423a15ea412f5d","html":"toolbar-item-command.html","platform":"electron","position":75,"type":"type"}}},"_id":"w1667a15e2a1e2ef"}); \ No newline at end of file diff --git a/designer/scripts/system-designer.js b/designer/scripts/system-designer.js index c0fb44f..782f8e5 100644 --- a/designer/scripts/system-designer.js +++ b/designer/scripts/system-designer.js @@ -1,3 +1,3 @@ // System Designer - Copyright 2018 Erwan Carriou // Licensed under the Apache License, Version 2.0 (the "License") -runtime.install({"name":"system-designer","master":true,"version":"2.8.3","description":"A Designer for Systems","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$designerSetSystem":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","messages":"property"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"],"designer":"property"},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"]},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]},"$designerSetSystem":{"params":[{"name":"system","type":"object","mandatory":false,"default":{}}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"2.8.3"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}]}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":false}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57"},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10","designer":{"type":"Designer","readOnly":true,"mandatory":false,"default":{}}},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}},"j1311d115381b738":{"_id":"j1311d115381b738","_name":"State","type":{"type":"string","readOnly":false,"mandatory":false,"default":""},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null;\n \n if (extension.installed) { \n system = extension.source;\n \n try {\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n } catch (e) {\n this.require('message').danger('Can not install an extension.');\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n\n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').hide();\n }\n } else {\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').show();\n }\n }\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-file').attr('checked', false);\n $('#designer-dialog-import-modal-from-library').attr('checked', true);\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n that.data(JSON.parse(json));\n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').uninstall('ext_' + system._id)\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n downloadLink.click();\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n if (system.name === name) {\n result = false;\n break;\n }\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n \n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"snippet\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'snippet' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'snippet' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'snippet' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'snippet' });\n }\n \n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n \n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n \n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n \n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n \n // snippets\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet:'{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'snippet' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n \n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"snippet\" });\n }\n \n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n \n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n \n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n \n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n \n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n\n repo1.writeFile('master', system.name + '.json', JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html', htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js', jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^2.8.4';\n\n repo4.writeFile('master', 'package.json', JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.source());\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n \n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n });\n\n menuActions.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('afterbegin', '
  • ' + action.html().source() + '');\n });\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n this.require('state').messages(messages);\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n for (propName in this.document().schema) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n }\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n\n systemId = this.require('factory').system().id();\n schema = _getSchema(this.model());\n model = _getModel(this.model());\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = this.document()[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n if (modelName === '_Component') {\n modelName = _getModelFromComponent(propVal);\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n function gen() {\n return Math.floor((1 + Math.random()) * 0x10000).toString(16);\n }\n function getPrefix() {\n var validPrefix = 'abcdefghijklmnopqrstuvwxyz';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return getPrefix() + gen() + gen() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n\n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n \n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system !== 'undefined':\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && typeof system !== 'undefined':\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && typeof system !== 'undefined':\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && typeof system !== 'undefined' && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n default:\n break;\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin', \n template.source().replace(/{{message}}/gi, message));\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom) {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (typeof system === 'undefined') {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"z14cf91f7131c34d":{"_id":"z14cf91f7131c34d","component":"1dbc51300e11z17","state":"click","action":"function click() {\n $('#designer-toolbar-item-search').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n\n var message = this.require('message');\n var Dialog = this.require('DialogSearch');\n\n if (this.require('factory').system()) {\n var dialog = new Dialog({\n 'title': 'Search in the system',\n });\n dialog.show();\n } else {\n message.warning('There is no system.');\n }\n}"},"a13b711adba1c7d4":{"_id":"a13b711adba1c7d4","component":"163a01b7ca1935c","state":"click","action":"function click() {\n var debugWindow = this.require('designer').debugWindow(),\n config = this.require('storage').get('system-designer-config'),\n message = this.require('message');\n\n $('#designer-toolbar-item-refresh').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (config) {\n if (typeof config.debugType !== 'undefined' && config.debugType === 'client') {\n if (config.urlClient) {\n if (debugWindow && !debugWindow.closed) {\n message.success('Searching for a system...');\n this.require('channel').$designerSync();\n } else {\n message.success('Opening the page...');\n this.require('designer').debugWindow(this.require('designer').open(config.urlClient, 'debug'));\n }\n } else {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n }\n if (typeof config.debugType !== 'undefined' && config.debugType === 'server') {\n if (config.urlServer) {\n message.success('Searching for a server...');\n var self = this;\n $.getJSON(config.urlServer.replace(':8888', '') + ':8888/$designerSync', function (system) {\n var Dialog = null,\n dialog = null,\n message = runtime.require('message');\n \n if (system && system.name) {\n Dialog = self.require('DialogImport');\n dialog = new Dialog({\n 'title': 'A system has been found',\n 'message': 'Do you wan to import it ?',\n 'data': system\n });\n dialog.show();\n \n dialog.on('ok', function () {\n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n \n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n \n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n designer.save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n designer.save();\n \n message.success('Importation of the system is done.');\n });\n } else {\n message.warning('There is no system to import.');\n }\n });\n } else {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n }\n if (typeof config.debugType === 'undefined') {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n } else {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n}"},"e137f915b1b15f90":{"_id":"e137f915b1b15f90","component":"163a01b7ca1935e","state":"click","action":"function click() {\n $('#designer-toolbar-item-export').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var message = this.require('message');\n var Dialog = this.require('DialogExport');\n\n if (this.require('factory').system()) {\n var dialog = new Dialog({\n 'title': 'Export the current system',\n });\n dialog.show();\n } else {\n message.warning('There is no system to export.');\n }\n}"},"p1087a100821fa03":{"_id":"p1087a100821fa03","component":"1dbc51200e116e3","state":"click","action":"function click() {\n $('#designer-toolbar-item-config').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogConfig = this.require('DialogConfig');\n\n DialogConfig = new DialogConfig({\n 'title': 'Configuration'\n });\n DialogConfig.show();\n DialogConfig.on('ok', function () {\n var message = this.require('message');\n\n this.hide();\n message.success('Configuration saved.');\n });\n}"},"y1163b139241a596":{"_id":"y1163b139241a596","component":"1dbc51200e116e11","state":"click","action":"function click() {\n $('#designer-toolbar-item-sync').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogSync = this.require('DialogSync');\n\n DialogSync = new DialogSync({\n 'title': 'GitHub'\n });\n DialogSync.show();\n DialogSync.on('ok', function () {\n if ($('#designer-dialog-sync-refresh').prop('checked')) {\n this.require('github').refresh();\n } else {\n this.require('github').push(\n $('#designer-dialog-sync-comments').val(),\n $('#designer-dialog-type-creation-hasHTML').prop('checked'),\n false,\n $('#designer-dialog-sync-options-log-level-select').val(),\n $('#designer-dialog-type-creation-hasPackage').prop('checked')\n );\n }\n this.hide();\n });\n}"},"o1ec561a54015768":{"_id":"o1ec561a54015768","component":"163a01b7ca1935d","state":"click","action":"function click() {\n $('#designer-toolbar-item-import').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogImportFile = this.require('DialogImportFile');\n\n var dialogImportFile = new DialogImportFile({\n 'title': 'Import a system'\n });\n dialogImportFile.show();\n}"},"q178081a11712887":{"_id":"q178081a11712887","component":"13f70137b61b19b","state":"click","action":"function click() {\n var designer = this.require('designer'),\n message = this.require('message'),\n debugWindow = this.require('designer').debugWindow(),\n runWidow = this.require('designer').runWindow(),\n system = this.require('factory').system(),\n json = {},\n cleanJson = '',\n reg = null;\n\n $('#designer-toolbar-item-publish').tooltip('hide');\n if (system) {\n\n // force save befor running the app\n this.require('designer').save();\n\n\n switch(true) {\n // case of extension\n case system.name().indexOf('extension-') !== -1:\n json = this.require('factory').toJSON();\n\n cleanJson = JSON.stringify(json);\n reg = new RegExp(json._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + json._id);\n json = JSON.parse(cleanJson);\n\n runtime.uninstall(json._id);\n runtime.install(json);\n this.require('menubar').render();\n this.require('toolbar').render();\n message.success('The extension has been installed.');\n break;\n \n // case of remote debugging\n case debugWindow && !debugWindow.closed:\n this.require('channel').$designerSetSystem(this.require('factory').toJSON());\n // TODO Refresh the page\n message.success('Running the system in the remote page...');\n break;\n\n // reload the running page\n case runWidow && !runWidow.closed:\n runWidow.close();\n this.require('designer').runWindow(this.require('designer').open('app/index.html#' + this.require('factory').system().id(), 'app'));\n message.success('Running the system...');\n\n /*if (typeof require === 'undefined') {\n runWidow.document.location.reload();\n message.success('Running the system...');\n } else {\n // TODO \n // to reload when implemented in electron\n message.info('info: to run again the system, click the widow where your system is running and go to the menu \\'View > Refresh\\’.');\n }*/\n break;\n\n // we load for the first time the page\n default:\n this.require('designer').runWindow(this.require('designer').open('app/index.html#' + this.require('factory').system().id(), 'app'));\n message.success('Running the system...');\n break;\n }\n } else {\n message.warning('There is no system to run.');\n }\n}","useCoreAPI":true},"k1a9e11cd571d17c":{"_id":"k1a9e11cd571d17c","component":"13a291c27f16314","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n \n switch (this.require('state').menu()) {\n case 'systems':\n this.require('designer').open('https://system-designer.readme.io/docs/create-a-system', '_blank', true); \n break;\n case 'schemas':\n this.require('designer').open('https://system-designer.readme.io/docs/create-a-schema', '_blank', true); \n break;\n case 'models':\n this.require('designer').open('https://system-designer.readme.io/docs/edit-a-model', '_blank', true); \n break;\n case 'types':\n this.require('designer').open('https://system-designer.readme.io/docs/create-a-type', '_blank', true); \n break;\n case 'behaviors':\n this.require('designer').open('https://system-designer.readme.io/docs/create-a-behavior', '_blank', true); \n break;\n case 'components':\n this.require('designer').open('https://system-designer.readme.io/docs/create-a-component', '_blank', true); \n break;\n case 'logs':\n this.require('designer').open('https://system-designer.readme.io/docs/run-your-system', '_blank', true);\n break;\n default:\n this.require('designer').open('https://system-designer.readme.io/docs/quick-start', '_blank', true); \n break;\n }\n}"},"o1ff8e17e1c1bcd7":{"_id":"o1ff8e17e1c1bcd7","component":"13a291c27f16310","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"c15ea3176d5139e8":{"_id":"c15ea3176d5139e8","component":"10bcb1a0511e09f","state":"click","action":"function click() { \n $('#designer-toolbar-item-create').tooltip('hide');\n var message = this.require('message'),\n designer = this.require('designer');\n \n if (!this.require('factory').system() && this.require('state').menu() !== 'systems') {\n message.warning('There is no system: create first a system to continue.');\n } else {\n if (this.require('factory').system() && Object.keys(this.require('factory').system().schemas()).length === 0 && this.require('state').menu() === 'components') {\n message.warning('There is no schema: create first a schema to continue.');\n } else {\n this.require('workspace').create();\n }\n }\n}"},"l19fda1461e1d86c":{"_id":"l19fda1461e1d86c","component":"Spaces","state":"clear","action":"function clear() { \n this.require('state').space('');\n $('#designer-spaces-items').empty();\n}","useCoreAPI":false,"core":false},"a16e02190b216769":{"_id":"a16e02190b216769","component":"Spaces","state":"render","action":"function render() { \n var item = null,\n items = [],\n components = [],\n systemItems = [],\n system = this.require('factory').system(),\n SpaceItem = this.require('SpaceItem'),\n spaceItem = null,\n space = '',\n id = '',\n domItems = document.getElementById('designer-spaces-items'),\n systemdomItems = document.getElementById('designer-spaces-system-items'),\n componentdomItems = document.getElementById('designer-spaces-components-items'),\n self = this,\n name = '',\n callback = null,\n modelsName = [],\n showComponents = false,\n modelName = '',\n componentId = '';\n\n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n\n function _findModel(compId, components) {\n var result = '',\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n $('#designer-spaces-help').empty();\n\n // update header and help\n switch (this.require('state').menu()) {\n case 'systems':\n $('#designer-spaces-spaces-system').hide();\n $('#designer-spaces-spaces-components').hide();\n document.getElementById('designer-spaces-type').innerHTML = 'Systems';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-system.html').source());\n break;\n case 'schemas':\n $('#designer-spaces-spaces-system').hide();\n $('#designer-spaces-spaces-components').hide();\n document.getElementById('designer-spaces-type').innerHTML = 'Schemas';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-schemas.html').source());\n break;\n case 'models':\n $('#designer-spaces-spaces-system').hide();\n $('#designer-spaces-spaces-components').hide();\n document.getElementById('designer-spaces-type').innerHTML = 'Models';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-models.html').source());\n break;\n case 'types':\n $('#designer-spaces-spaces-system').hide();\n $('#designer-spaces-spaces-components').hide();\n document.getElementById('designer-spaces-type').innerHTML = 'Types';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-types.html').source());\n break;\n case 'behaviors':\n $('#designer-spaces-spaces-system').show();\n $('#designer-spaces-spaces-components').show();\n document.getElementById('designer-spaces-type').innerHTML = 'Models';\n document.getElementById('designer-spaces-system-header').innerHTML = 'System';\n document.getElementById('designer-spaces-components-header').innerHTML = 'Components';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-behaviors.html').source());\n break;\n case 'components':\n $('#designer-spaces-spaces-system').hide();\n $('#designer-spaces-spaces-components').hide();\n document.getElementById('designer-spaces-type').innerHTML = 'Models';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-components.html').source());\n break;\n case 'logs':\n $('#designer-spaces-spaces-system').hide();\n $('#designer-spaces-spaces-components').hide();\n document.getElementById('designer-spaces-type').innerHTML = 'Logs';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-logs.html').source());\n break;\n default:\n break;\n }\n\n // update spaces\n // clear\n $('#designer-spaces-items').empty();\n $('#designer-spaces-system-items').empty();\n $('#designer-spaces-components-items').empty();\n if (system) {\n switch (this.require('state').menu()) {\n case 'systems':\n // items \n var systems = this.require('storage').get('system-designer-systems'),\n systemIds = [],\n length = 0,\n i = 0;\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n spaceItem = new SpaceItem({\n 'name': system.name,\n 'uuid': system._id\n });\n items.push(spaceItem);\n }\n \n this.items(items);\n\n // sort\n this.items().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n \n this.require('state').navigation().spaces([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.name() + '
  • ');\n this.require('state').navigation().spaces().push('designer-space-' + item.name());\n }.bind(this));\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n\n this.items().forEach(function (item) {\n item.on('click', function () {\n var designer = this.require('designer'),\n system = this.require('storage').get(this.uuid()),\n System = this.require('System');\n \n if (system) {\n this.require('factory').create(system);\n }\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n });\n });\n\n // focus\n if (length > 0) {\n if ($('#designer-space-' + this.require('state').space()).length) {\n $('#designer-space-' + this.require('state').space()).addClass('active');\n } else {\n if (this.require('factory').system()) {\n if ($('#designer-space-' + this.require('factory').system().name()).length) {\n $('#designer-space-' + this.require('factory').system().name()).addClass('active');\n this.require('state').space(this.require('factory').system().name());\n }\n } else {\n item = domItems.children[0];\n $(item).addClass('active');\n this.require('state').space(this.items(0).name());\n }\n }\n }\n\n break;\n case 'schemas':\n // items \n for (name in system.schemas()) {\n spaceItem = new SpaceItem({\n 'name': system.schemas()[name]._name,\n 'uuid': name\n });\n items.push(spaceItem);\n }\n \n this.items(items);\n\n // sort\n this.items().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n\n this.require('state').navigation().spaces([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.name() + '
  • ');\n this.require('state').navigation().spaces().push('designer-space-' + item.uuid());\n }.bind(this));\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n // focus\n if (length > 0) {\n if ($('#designer-space-' + this.require('state').space()).length) {\n $('#designer-space-' + this.require('state').space()).addClass('active');\n } else {\n item = domItems.children[0];\n $(item).addClass('active');\n this.require('state').space(this.items(0).uuid());\n }\n } else {\n this.require('state').space('');\n }\n break;\n \n case 'models':\n // items \n for (name in system.models()) {\n spaceItem = new SpaceItem({\n 'name': system.models()[name]._name,\n 'uuid': name\n });\n items.push(spaceItem);\n }\n \n this.items(items);\n\n // sort\n this.items().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n\n this.require('state').navigation().spaces([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.name() + '
  • ');\n this.require('state').navigation().spaces().push('designer-space-' + item.uuid());\n }.bind(this));\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n // focus\n if (length > 0) {\n if ($('#designer-space-' + this.require('state').space()).length) {\n $('#designer-space-' + this.require('state').space()).addClass('active');\n } else {\n item = domItems.children[0];\n $(item).addClass('active');\n this.require('state').space(this.items(0).uuid());\n }\n } else {\n this.require('state').space('');\n }\n break;\n case 'types':\n // items\n for (name in system.types()) {\n spaceItem = new SpaceItem({\n 'name': name\n });\n items.push(spaceItem);\n }\n \n this.items(items);\n\n // sort\n this.items().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n\n this.require('state').navigation().spaces([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.name() + '
  • ');\n this.require('state').navigation().spaces().push('designer-space-' + item.name());\n }.bind(this));\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n // focus\n if (length > 0) {\n if ($('#designer-space-' + this.require('state').space()).length) {\n $('#designer-space-' + this.require('state').space()).addClass('active');\n } else {\n item = domItems.children[0];\n $(item).addClass('active');\n this.require('state').space(this.items(0).name());\n }\n }\n break;\n case 'behaviors':\n // items\n for (name in system.models()) {\n spaceItem = new SpaceItem({\n 'name': system.models()[name]._name,\n 'uuid': name\n });\n items.push(spaceItem);\n }\n \n this.items(items);\n\n // sort\n this.items().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n\n //this.items().reverse();\n\n this.require('state').navigation().spaces([]);\n this.items().forEach(function (item) {\n modelsName.push(item.name());\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.name() + '
  • ');\n this.require('state').navigation().spaces().push('designer-space-' + item.name());\n }.bind(this));\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n\n // systems\n systemItems = []\n\n if (this.require('storage').get('system-designer-systems') && this.require('storage').get('system-designer-systems').systems.length) {\n spaceItem = new SpaceItem({\n 'name': this.require('factory').system().name(),\n 'uuid': this.require('factory').system().id()\n });\n systemItems.push(spaceItem);\n }\n \n this.systems(systemItems);\n\n this.systems().forEach(function (item) {\n systemdomItems.insertAdjacentHTML('beforeend', '
  • ' + item.name() + '
  • ');\n this.require('state').navigation().spaces().unshift('designer-space-' + item.name());\n }.bind(this));\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = systemdomItems.children.length;\n for (i = 0; i < length; i++) {\n item = systemdomItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.systems(i)));\n }\n\n space = this.require('state').space();\n if (modelsName.indexOf(space) !== -1) {\n showComponents = true;\n modelName = space;\n } else {\n modelName = _findModel(space, this.require('factory').system().components());\n if (modelName) {\n showComponents = true;\n }\n }\n\n if (showComponents) {\n\n // components\n components = [];\n\n // components\n for (id in system.components()[modelName]) {\n spaceItem = new SpaceItem({\n 'name': id,\n 'uuid': id\n });\n components.push(spaceItem);\n }\n\n this.components(components);\n\n // sort\n this.components().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n\n //this.components().reverse();\n\n this.components().forEach(function (item) {\n modelsName.push(item.name());\n componentdomItems.insertAdjacentHTML('beforeend', '
  • ' + item.name() + '
  • ');\n this.require('state').navigation().spaces().push('designer-space-' + item.name());\n }.bind(this));\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = componentdomItems.children.length;\n for (i = 0; i < length; i++) {\n item = componentdomItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.components(i)));\n }\n }\n\n // focus\n if (this.items().length > 0) {\n if ($('#designer-space-' + this.require('state').space().replace(/\\./g, '-')).length) {\n $('#designer-space-' + this.require('state').space().replace(/\\./g, '-')).addClass('active');\n } else {\n item = systemdomItems.children[0];\n $(item).addClass('active');\n this.require('state').space(this.systems(0).name());\n }\n } else {\n item = systemdomItems.children[0];\n $(item).addClass('active');\n this.require('state').space(this.systems(0).name());\n }\n\n break;\n \n case 'components':\n // items\n for (name in system.models()) {\n spaceItem = new SpaceItem({\n 'name': system.models()[name]._name,\n 'uuid': name\n });\n items.push(spaceItem);\n }\n this.items(items);\n\n // sort\n this.items().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n\n this.require('state').navigation().spaces([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.name() + '
  • ');\n this.require('state').navigation().spaces().push('designer-space-' + item.name());\n }.bind(this));\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n // focus\n if (length > 0) {\n if ($('#designer-space-' + this.require('state').space()).length) {\n $('#designer-space-' + this.require('state').space()).addClass('active');\n } else {\n item = domItems.children[0];\n $(item).addClass('active');\n this.require('state').space(this.items(0).name());\n }\n }\n\n break;\n case 'logs':\n this.require('state').navigation().spaces([]);\n\n domItems.insertAdjacentHTML('beforeend', '
  • All logs
  • ');\n this.require('state').navigation().spaces().push('designer-space-all');\n domItems.insertAdjacentHTML('beforeend', '
  • Error logs
  • ');\n this.require('state').navigation().spaces().push('designer-space-error');\n domItems.insertAdjacentHTML('beforeend', '
  • Warning logs
  • ');\n this.require('state').navigation().spaces().push('designer-space-warn');\n domItems.insertAdjacentHTML('beforeend', '
  • Info logs
  • ');\n this.require('state').navigation().spaces().push('designer-space-info');\n domItems.insertAdjacentHTML('beforeend', '
  • Debug logs
  • ');\n this.require('state').navigation().spaces().push('designer-space-debug');\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n }\n // focus\n if (length > 0) {\n if ($('#designer-space-' + this.require('state').space()).length) {\n $('#designer-space-' + this.require('state').space()).addClass('active');\n } else {\n item = domItems.children[0];\n $(item).addClass('active');\n this.require('state').space('all');\n }\n }\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"d1cb2d156c513e03":{"_id":"d1cb2d156c513e03","component":"Workspace","state":"init","action":"function init(conf) { \n var that = this;\n\n $('html')\n .on('dragenter dragover', false)\n .on('drop', function (e) {\n e.stopPropagation();\n e.preventDefault();\n var files = e.originalEvent.dataTransfer.files;\n var reader = new FileReader();\n var json = '';\n reader.onload = function (event) {\n json += event.target.result;\n };\n reader.onloadend = function () {\n var sys = JSON.parse(json);\n var DialogDropFile = that.require('DialogDropFile');\n \n if (!that.require('factory').system()) {\n DialogDropFile = new DialogDropFile({\n 'title': 'A system has been found',\n 'message': 'You can import the system.'\n });\n } else {\n DialogDropFile = new DialogDropFile({\n 'title': 'A system has been found',\n 'message': 'You can import the system or compose it with the current system.'\n });\n }\n\n DialogDropFile.data(sys);\n DialogDropFile.show();\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n });\n}","useCoreAPI":false,"core":false},"v1090710e8e1d9f9":{"_id":"v1090710e8e1d9f9","component":"Workspace","state":"create","action":"function create() {\n var id = '',\n Dialog = null,\n dialog = null,\n factory = this.require('factory'),\n system = this.require('factory').system();\n\n switch (this.require('state').menu()) {\n case 'systems':\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n break;\n case 'schemas':\n if (system && Object.keys(system).length) {\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n }\n break;\n case 'models':\n if (system && Object.keys(system).length) {\n Dialog = this.require('DialogModelCreation');\n dialog = new Dialog({\n 'title': 'Create a new model',\n });\n dialog.show();\n }\n break;\n case 'types':\n if (system && Object.keys(system).length) {\n Dialog = this.require('DialogTypeCreation');\n dialog = new Dialog({\n 'title': 'Create a new type',\n });\n dialog.show();\n }\n break;\n case 'components':\n if (system && Object.keys(system).length) {\n var models = this.require('factory').system().models(),\n component = {},\n ModelComponent = null,\n modelComponent = null,\n modelName = '';\n\n modelName = this.require('state').space();\n\n if (typeof models[modelName] === 'undefined') {\n \n this.require('message-help').remove();\n\n component = this.require('factory').addComponent(modelName);\n\n ModelComponent = this.require('ModelComponent');\n\n modelComponent = new ModelComponent({\n title: component._id\n });\n modelComponent.model(modelName);\n modelComponent.uuid(component._id);\n modelComponent.document(JSON.parse(JSON.stringify(component)));\n modelComponent.content(JSON.stringify(component));\n\n modelComponent.render();\n\n // little effect\n $('#designer-component-' + component._id).hide();\n $('#designer-component-' + component._id).fadeIn(1000);\n\n this.require('designer').save();\n\n this.require('channel').$designerCreateComponent(modelName, component);\n this.require('message').success('Component created.');\n } else {\n this.require('message').warning('There is no schema. Create a schema before creating a component.');\n }\n }\n break;\n case 'behaviors':\n if (system && Object.keys(system).length) {\n Dialog = this.require('DialogBehaviorCreation');\n dialog = new Dialog({\n 'title': 'Create a new behavior',\n });\n dialog.show();\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"f134d11639b1c4fe":{"_id":"f134d11639b1c4fe","component":"Workspace","state":"clear","action":"function clear() { \n $('#designer-workspace').empty();\n jsPlumb.ready(function () {\n jsPlumb.deleteEveryEndpoint();\n });\n}","useCoreAPI":false,"core":false},"i131bd1870a18e7a":{"_id":"i131bd1870a18e7a","component":"e89c617b6b15d28","state":"start","action":"function start() { \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"l1b9611fc10168ec":{"_id":"l1b9611fc10168ec","component":"State","state":"logs","action":"function logs(value, type) { \n var html = '';\n var filter = this.require('state').space();\n\n if (type === 'add' && this.require('state').menu() === 'logs') {\n switch (value.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n html = '

    ' + value.log() + '

    ';\n } \n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n html = '

    ' + value.log() + '

    ';\n } \n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n html = '

    ' + value.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n html = '

    ' + value.log() + '

    ';\n }\n break;\n default:\n break;\n }\n\n document.querySelector('#designer-loug-output').insertAdjacentHTML('beforeend',\n html\n );\n }\n}","useCoreAPI":false,"core":false},"p1d00311ad51ef9a":{"_id":"p1d00311ad51ef9a","component":"Designer","state":"welcome","action":"function welcome() { \n var Dialog = null,\n dialog = null,\n config = null;\n\n config = this.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n\n if (typeof config.welcomeScreen === 'undefined') {\n Dialog = this.require('DialogWelcome');\n dialog = new Dialog({\n 'title': 'Welcome to System Designer'\n });\n dialog.show();\n dialog.on('ok', function ok() {\n var config = this.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n config.welcomeScreen = false;\n this.require('storage').set('system-designer-config', config);\n this.hide();\n });\n }\n}","useCoreAPI":false,"core":false},"o12c7d1448a1dc16":{"_id":"o12c7d1448a1dc16","component":"Designer","state":"render","action":"function render() {\n var System = null,\n systemId = '';\n\n // message\n this.require('logger').on('warn', function warn(message) {\n this.require('message').warning(message);\n });\n this.require('logger').on('error', function error(message) {\n this.require('message').danger(message);\n });\n \n // extensions\n this.installExtensions();\n\n // system\n System = this.require('System');\n var systems = this.require('storage').get('system-designer-systems');\n\n // case of url\n switch (true) {\n case window.location.href.split('#').length > 1 && window.location.href.split('#')[1].length > 0:\n systemId = window.location.href.split('#')[1];\n if (this.require('storage').get(systemId)) {\n this.require('factory').create(this.require('storage').get(systemId));\n }\n break;\n default:\n if (systems && systems.systems && systems.systems.length && systems.systems[0].length) {\n systems.systems.sort(function (sysA, sysB) {\n var a = this.require('storage').get(sysA),\n b = this.require('storage').get(sysB),\n result = 0;\n\n if (a.name > b.name) {\n result = 1;\n }\n if (a.name < b.name) {\n result = -1;\n }\n return result;\n }.bind(this));\n\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n break;\n }\n \n this.welcome();\n\n this.require('router').start();\n \n // resize event\n $(window).resize(function () {\n jsPlumb.repaintEverything();\n });\n\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('spaces').render();\n \n this.addShorcuts();\n \n // run messages if any\n this.runMessages(this.require('state').messages());\n this.require('state').messages([]);\n}","useCoreAPI":false,"core":false},"x196fc166ef17a85":{"_id":"x196fc166ef17a85","component":"Designer","state":"linkModel","action":"function linkModel(source, target) { \n jsPlumb.ready(function () {\n jsPlumb.setContainer('body');\n\n jsPlumb.connect({\n paintStyle: {\n stroke: '#7F949D',\n strokeWidth: 3\n },\n source: 'designer-model-panel-' + source,\n target: 'designer-model-panel-' + target,\n overlays: [\n ['Arrow', {\n location: 1\n }]\n ]\n }, {\n connector: ['Flowchart'],\n anchor: ['Left', 'Right'],\n endpoint: 'Blank'\n });\n });\n}","useCoreAPI":false,"core":false},"k13951153851cc3a":{"_id":"k13951153851cc3a","component":"Designer","state":"save","action":"function save() { \n var systems = this.require('storage').get('system-designer-systems'),\n system = this.require('factory').toJSON(),\n systemId = system._id;\n\n // save system\n this.require('storage').set(systemId, system);\n\n // save index\n if (!systems) {\n systems = { 'systems': [systemId] };\n } else {\n if (systems.systems.indexOf(systemId) === -1) {\n systems.systems.push(systemId);\n }\n }\n this.require('storage').set('system-designer-systems', systems);\n}","useCoreAPI":false,"core":false},"u1cf0e155fb1e53f":{"_id":"u1cf0e155fb1e53f","component":"Workspace","state":"render","action":"function render() { \n var ModelSystem = null,\n ModelSchema = null,\n ModelClass = null,\n modelSchema = null,\n ModelLog = null,\n sys = null,\n name = '',\n id = '',\n schemaId = '',\n modelclass = null,\n modellog = null,\n ModelType = null,\n type = null,\n ModelComponent = null,\n component = null,\n ModelBehavior = null,\n behavior = null,\n system = this.require('factory').system(),\n space = this.require('state').space(),\n menu = this.require('state').menu(),\n parentId = '',\n parentsId = [],\n parents = null,\n systems = null,\n systemIds = [],\n i = 0,\n length = 0,\n title = 0,\n nbElement = 0;\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas()) {\n if (system.schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models()) {\n if (system.models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (system) {\n this.clear();\n\n window.scrollTo(0, 0);\n\n title = 'system ' + system.name();\n if (title !== document.title) {\n document.title = title;\n }\n\n switch (this.require('state').menu()) {\n case 'systems':\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n if (system.name === space) {\n ModelSystem = this.require('ModelSystem');\n sys = new ModelSystem({\n 'title': system.name\n });\n sys.uuid(system._id);\n sys.document(JSON.parse(JSON.stringify(system)));\n sys.content(JSON.stringify(system));\n sys.render();\n }\n }\n\n if (space === '' && length > 0) {\n this.require('message').warning('System not found.');\n }\n\n break;\n case 'schemas':\n if (space) {\n for (id in system.schemas()) {\n if (system.schemas()[id]._id === space) {\n ModelSchema = this.require('ModelSchema');\n\n // create parent if any\n parentsId = [];\n if (system.schemas()[id]._inherit) {\n parents = system.schemas()[id]._inherit.slice();\n parents.reverse();\n }\n length = 0;\n if (parents) {\n length = parents.length;\n }\n\n for (i = 0; i < length; i++) {\n parentId = _getSchemaId(parents[i]);\n\n modelSchema = new ModelSchema({\n 'title': parents[i]\n });\n \n if (parents[i] !== system.schemas()[id]._name) {\n if (parents[i] === '_Component') {\n parentId = \"111df11e2b19fde\";\n \n var schemaRuntime = {\n \"_id\": \"_Component\",\n \"_name\": \"_Component\",\n \"_core\": true,\n \"id\": \"property\",\n \"classInfo\": \"method\",\n \"init\": \"method\",\n \"destroy\": \"method\",\n \"on\": \"method\",\n \"off\": \"method\",\n \"require\": \"method\",\n \"error\": \"event\"\n };\n \n modelSchema.document(schemaRuntime);\n modelSchema.content(JSON.stringify(schemaRuntime));\n parentsId.push(parentId);\n modelSchema.uuid(parentId);\n } else {\n if (system.schemas()[_getSchemaId(parents[i])]) {\n modelSchema.document(JSON.parse(JSON.stringify(system.schemas()[_getSchemaId(parents[i])])));\n modelSchema.content(JSON.stringify(system.schemas()[_getSchemaId(parents[i])]));\n parentsId.push(_getSchemaId(parents[i]));\n modelSchema.uuid(_getSchemaId(parents[i]));\n } else {\n parentsId.push(parents[i]);\n modelSchema.uuid(parents[i]);\n }\n }\n modelSchema.render();\n }\n }\n\n modelSchema = new ModelSchema({\n 'title': system.schemas()[id]._name\n });\n modelSchema.uuid(id);\n modelSchema.document(JSON.parse(JSON.stringify(system.schemas()[id])));\n modelSchema.content(JSON.stringify(system.schemas()[id]));\n modelSchema.editable(true);\n modelSchema.render();\n\n length = parentsId.length;\n for (i = 0; i < length; i++) {\n this.require('designer').linkModel(id, parentsId[i]);\n }\n }\n }\n if (Object.keys(system.schemas()).length === 0) {\n this.require('message-help').render();\n }\n } else {\n if (Object.keys(system.schemas()).length === 0) {\n this.require('message-help').render();\n }\n }\n break;\n case 'models':\n if (space) {\n for (id in system.models()) {\n if (system.models()[id]._id === space) {\n ModelClass = this.require('ModelClass');\n\n // create parent if any\n // parents are search from the schema\n schemaId = _getSchemaId(system.models()[id]._name);\n parentsId = [];\n if (schemaId && system.schemas()[schemaId]._inherit) {\n parents = system.schemas()[schemaId]._inherit.slice();\n parents.reverse();\n }\n length = 0;\n if (parents) {\n length = parents.length;\n }\n\n for (i = 0; i < length; i++) {\n\n parentId = _getSchemaId(parents[i]);\n\n modelclass = new ModelClass({\n 'title': parents[i]\n });\n\n if (parents[i] === '_Component') {\n parentId = '123751cb591de26';\n\n var modelRuntime = {\n \"_name\": \"_Component\",\n \"_core\": true,\n \"id\": {\n \"description\": \"get the unique ID of a component\",\n \"type\": \"string\",\n \"readOnly\": true,\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"classInfo\": {\n \"description\": \"get the model of the component\",\n \"result\": \"_ClassInfo\"\n },\n \"init\": {\n \"description\": \"action to do when the component is created\",\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n },\n \"destroy\": {\n \"description\": \"action to do when the component is destroyed\",\n \"params\": []\n },\n \"on\": {\n \"description\": \"add a behavior to a component\",\n \"params\": [{\n \"name\": \"state\",\n \"type\": \"string\"\n },\n {\n \"name\": \"action\",\n \"type\": \"function\"\n },\n {\n \"name\": \"useCoreAPI\",\n \"type\": \"boolean\",\n \"mandatory\": false\n },\n {\n \"name\": \"isCore\",\n \"type\": \"boolean\",\n \"mandatory\": false\n }\n ],\n \"result\": \"string\"\n },\n \"off\": {\n \"description\": \"remove a behavior from a component\",\n \"params\": [{\n \"name\": \"state\",\n \"type\": \"string\"\n },\n {\n \"name\": \"behaviorId\",\n \"type\": \"string\",\n \"mandatory\": false\n }]\n },\n \"require\": {\n \"description\": \"require a component\",\n \"params\": [{\n \"name\": \"id\",\n \"type\": \"string\"\n }],\n \"result\": \"_Component\"\n },\n \"error\": {\n \"description\": \"action to do when an error happened\",\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n }\n };\n\n modelclass.document(modelRuntime);\n modelclass.content(JSON.stringify(modelRuntime));\n parentsId.push(parentId);\n modelclass.uuid(parentId);\n } else {\n if (system.models()[_getModelId(parents[i])]) {\n modelclass.document(JSON.parse(JSON.stringify(system.models()[_getModelId(parents[i])])));\n modelclass.content(JSON.stringify(system.models()[_getModelId(parents[i])]));\n parentsId.push(_getModelId(parents[i]));\n modelclass.uuid(_getModelId(parents[i]));\n } else {\n parentsId.push(parents[i]);\n modelclass.uuid(parentId);\n }\n }\n modelclass.render();\n }\n\n modelclass = new ModelClass({\n 'title': system.models()[id]._name\n });\n modelclass.uuid(id);\n modelclass.document(JSON.parse(JSON.stringify(system.models()[id])));\n modelclass.content(JSON.stringify(system.models()[id]));\n modelclass.editable(true);\n modelclass.render();\n\n length = parentsId.length;\n for (i = 0; i < length; i++) {\n this.require('designer').linkModel(id, parentsId[i]);\n }\n }\n }\n } else {\n if (Object.keys(system.schemas()).length === 0) {\n this.require('message-help').render();\n }\n }\n break;\n case 'types':\n if (space) {\n for (name in system.types())\n if (system.types()[name].name === space) {\n ModelType = this.require('ModelType');\n type = new ModelType({\n 'title': name\n });\n type.uuid(name);\n type.document(JSON.parse(JSON.stringify(system.types()[space])));\n type.content(JSON.stringify(system.types()[space]));\n type.render();\n }\n if (Object.keys(system.types()).length === 0) {\n this.require('message-help').render();\n }\n } else {\n if (Object.keys(system.types()).length === 0) {\n this.require('message-help').render();\n }\n }\n break;\n case 'components':\n var nbComponents = 0;\n if (space) {\n if (this.require('state').component()) {\n name = this.require('state').component();\n if (system.components()[space][name]) {\n ModelComponent = this.require('ModelComponent');\n component = new ModelComponent({\n 'title': name\n });\n component.uuid(name);\n component.model(space);\n component.document(JSON.parse(JSON.stringify(system.components()[space][name])));\n component.content(JSON.stringify(system.components()[space][name]));\n component.render();\n } else {\n this.require('message-help').render();\n }\n } else {\n for (name in system.components()[space]) {\n ModelComponent = this.require('ModelComponent');\n component = new ModelComponent({\n 'title': name\n });\n component.uuid(name);\n component.model(space);\n component.document(JSON.parse(JSON.stringify(system.components()[space][name])));\n component.content(JSON.stringify(system.components()[space][name]));\n component.render();\n nbComponents = nbComponents + 1;\n \n if (nbComponents === 50) {\n this.require('message').warning('For performance reason you will only see the first 50 components.');\n break;\n }\n }\n \n if (system.components()) {\n if (system.components()[space]) {\n if (Object.keys(system.components()[space]).length === 0) {\n this.require('message-help').render();\n }\n } else {\n this.require('message-help').render();\n }\n } else {\n this.require('message-help').render();\n }\n }\n } else {\n if (Object.keys(system.components()).length === 0) {\n this.require('message-help').render();\n }\n }\n break;\n case 'behaviors':\n if (space) {\n name = this.require('state').component();\n var behaviorDef = {};\n var behaviorsId = Object.keys(system.behaviors());\n var systemName = this.require('factory').system().name();\n var systemId = this.require('factory').system().id();\n ModelBehavior = this.require('ModelBehavior');\n \n behaviorsId.forEach(function(id) {\n behaviorDef = system.behaviors()[id];\n if (behaviorDef.component === space) {\n if ((name && behaviorDef.state === name) || name === '') {\n behavior = new ModelBehavior({\n 'uuid': system.behaviors()[id]._id\n });\n behavior.title(behaviorDef.state);\n behavior.document(behaviorDef);\n behavior.content(JSON.parse(JSON.stringify(behaviorDef.action)));\n behavior.render();\n \n nbElement = nbElement + 1;\n }\n }\n\n // system\n if (space === systemName) {\n if (behaviorDef.component === systemId) {\n behavior = new ModelBehavior({\n 'uuid': behaviorDef._id\n });\n behavior.title(behaviorDef.state);\n behavior.document(behaviorDef);\n behavior.content(JSON.parse(JSON.stringify(behaviorDef.action)));\n behavior.render();\n \n nbElement = nbElement + 1;\n }\n }\n }.bind(this));\n \n if (nbElement === 0) {\n this.require('message-help').render();\n } else {\n Prism.highlightAll();\n }\n } else {\n if (Object.keys(system.behaviors()).length === 0) {\n this.require('message-help').render();\n }\n }\n break;\n case 'logs':\n ModelLog = this.require('ModelLog');\n\n modelLog = new ModelLog();\n modelLog.render();\n\n break;\n default:\n break;\n }\n } else {\n\n document.title = 'System Designer';\n \n this.require('message-help').render();\n\n systems = this.require('storage').get('system-designer-systems');\n if (systems && systems.systems && systems.systems.length) {\n this.require('message').warning('System not found.');\n }\n }\n}","useCoreAPI":false,"core":false},"s1876e1b64c1251e":{"_id":"s1876e1b64c1251e","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n collection = '',\n href = '',\n context = '',\n space = '',\n schemaName = '',\n schemaId = '',\n modelName = '',\n modelId = '';\n \n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelName(id, models) {\n var result = '',\n modelId = '';\n\n for (modelId in models) {\n if (modelId === id) {\n result = models[id]._name;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaName(id, schemas) {\n var result = '',\n schemaId = '';\n\n for (schemaId in schemas) {\n if (schemaId === id) {\n result = schemas[id]._name;\n break;\n }\n }\n return result;\n }\n\n function _getCollection(href) {\n var result = '';\n\n if (href.split('#').length === 2) {\n result = href.split('#')[1];\n }\n if (href.split('#').length > 2) {\n result = href.split('#')[2];\n }\n\n result = result.split('#')[0];\n result = result.trim();\n\n return result;\n }\n\n context = this.require('state').menu();\n space = this.require('state').space();\n\n switch (context) {\n case 'schemas':\n if (this.require('factory').system()) {\n if (space) {\n schemaName = _getSchemaName(space, this.require('factory').system().schemas());\n modelId = _getModelId(schemaName, this.require('factory').system().models());\n }\n\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '#' + this.require('factory').system().id() + '#' + collection;\n\n if (collection === 'models' && modelId) {\n menubar[i].href = menubar[i].href + '#' + modelId;\n }\n if (collection === 'components' && schemaName) {\n menubar[i].href = menubar[i].href + '#' + schemaName;\n }\n if (collection === 'behaviors' && schemaName) {\n menubar[i].href = menubar[i].href + '#' + schemaName;\n }\n }\n } else {\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '##' + collection;\n }\n }\n break;\n case 'models':\n if (this.require('factory').system()) {\n if (space) {\n modelName = _getModelName(space, this.require('factory').system().models());\n schemaId = _getSchemaId(modelName, this.require('factory').system().schemas());\n }\n\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '#' + this.require('factory').system().id() + '#' + collection;\n\n if (collection === 'schemas' && schemaId) {\n menubar[i].href = menubar[i].href + '#' + schemaId;\n }\n if (collection === 'components' && modelName) {\n menubar[i].href = menubar[i].href + '#' + modelName;\n }\n if (collection === 'behaviors' && modelName) {\n menubar[i].href = menubar[i].href + '#' + modelName;\n }\n }\n } else {\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '##' + collection;\n }\n }\n break;\n case 'behaviors':\n if (this.require('factory').system()) {\n if (space) {\n modelId = _getModelId(space, this.require('factory').system().models());\n schemaId = _getSchemaId(space, this.require('factory').system().schemas());\n schemaName = _getSchemaName(schemaId, this.require('factory').system().schemas());\n }\n\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '#' + this.require('factory').system().id() + '#' + collection;\n\n if (collection === 'schemas' && schemaId) {\n menubar[i].href = menubar[i].href + '#' + schemaId;\n }\n if (collection === 'models' && modelId) {\n menubar[i].href = menubar[i].href + '#' + modelId;\n }\n if (collection === 'components' && modelId) {\n menubar[i].href = menubar[i].href + '#' + schemaName;\n }\n }\n } else {\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '##' + collection;\n }\n }\n break;\n case 'components':\n if (this.require('factory').system()) {\n if (space) {\n modelId = _getModelId(space, this.require('factory').system().models());\n schemaId = _getSchemaId(space, this.require('factory').system().schemas());\n schemaName = _getSchemaName(schemaId, this.require('factory').system().schemas());\n }\n\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '#' + this.require('factory').system().id() + '#' + collection;\n\n if (collection === 'schemas' && schemaId) {\n menubar[i].href = menubar[i].href + '#' + schemaId;\n }\n if (collection === 'models' && modelId) {\n menubar[i].href = menubar[i].href + '#' + modelId;\n }\n if (collection === 'behaviors' && modelId) {\n menubar[i].href = menubar[i].href + '#' + schemaName;\n }\n }\n } else {\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '##' + collection;\n }\n }\n break;\n default:\n if (this.require('factory').system()) {\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '#' + this.require('factory').system().id() + '#' + collection;\n }\n } else {\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '##' + collection;\n }\n }\n break;\n }\n}","useCoreAPI":false,"core":false},"a1e92e1b7d6162ab":{"_id":"a1e92e1b7d6162ab","component":"Router","state":"start","action":"function start() { \n var that = this;\n \n window.onhashchange = function (e) {\n var arr = window.location.href.split('#'),\n system = '',\n collection = 'systems',\n component = '',\n i = 0,\n length = 0,\n item = null,\n domItems = null,\n System = that.require('System'),\n systems = that.require('storage').get('system-designer-systems');\n\n if (arr.length > 1) {\n system = arr[1];\n system = system.split('?')[0];\n }\n\n if (arr.length > 2) {\n collection = arr[2];\n collection = collection.split('?')[0];\n }\n\n if (arr.length > 3) {\n component = arr[3];\n component = component.split('?')[0];\n }\n\n if (arr.length > 4) {\n that.require('state').component(arr[4].split('?')[0]);\n } else {\n that.require('state').component('');\n }\n \n if (arr.length > 1 && system) {\n that.require('factory').create(that.require('storage').get(system));\n } else {\n if (systems && systems.systems && systems.systems.length) {\n that.require('factory').create(that.require('storage').get(systems.systems[0]));\n }\n }\n \n that.require('state').space(decodeURIComponent(component));\n that.require('state').menu(decodeURIComponent(collection));\n\n // focus\n domItems = document.getElementById('designer-menubar-items');\n length = that.require('menubar').items().length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n for (i = 0; i < length; i++) {\n if (that.require('menubar').items(i).name() === collection) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n\n that.update();\n };\t\n}","useCoreAPI":false,"core":false},"v10ccc18f431a78e":{"_id":"v10ccc18f431a78e","component":"State","state":"menu","action":"function menu(value) { \n jsPlumb.ready(function () {\n jsPlumb.deleteEveryEndpoint();\n });\n\n this.require('spaces').render();\n this.require('workspace').clear();\n this.require('workspace').render();\n}","useCoreAPI":false,"core":false},"n17df1112301e0cf":{"_id":"n17df1112301e0cf","component":"State","state":"space","action":"function space(value) { \n if (this.menu() === 'systems') {\n this.require('router').update();\n }\n}","useCoreAPI":false,"core":false},"j1fc1a152e61a7b9":{"_id":"j1fc1a152e61a7b9","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config');\n // message for other windows\n this.require('storage').set('system-designer-message', message);\n\n // message for client debug\n if (this.require('designer').debugWindow()) {\n this.require('designer').debugWindow().postMessage(JSON.stringify(message), '*');\n }\n\n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\t\n}","useCoreAPI":false,"core":false},"s11b84108ec12d82":{"_id":"s11b84108ec12d82","component":"_Channel","state":"$appLogDebug","action":"function $appLogDebug(message) { \n var log = '',\n Log = null;\n\n Log = this.require('Log');\n log = new Log({\n 'type': 'debug',\n 'log': message.replace('runtime:', '').replace(/\\[[^\\]]+\\]/, 'debug: ')\n });\n\n this.require('state').logs().push(log);\n this.require('message').info(message.replace(/\\[[^\\]]+\\]/, 'runtime: '));\t\n}","useCoreAPI":false,"core":false},"s1274812bab1ab3d":{"_id":"s1274812bab1ab3d","component":"_Channel","state":"$appLogInfo","action":"function $appLogInfo(message) { \n var log = '',\n Log = null;\n\n Log = this.require('Log');\n log = new Log({\n 'type': 'info',\n 'log': message.replace('runtime:', '').replace(/\\[[^\\]]+\\]/, 'info: ')\n });\n\n this.require('state').logs().push(log);\n this.require('message').info(message.replace(/\\[[^\\]]+\\]/, 'runtime: '));\t\n}","useCoreAPI":false,"core":false},"b1c5cb1ee0b195fc":{"_id":"b1c5cb1ee0b195fc","component":"_Channel","state":"$appLogWarn","action":"function $appLogWarn(message) { \n var log = '',\n Log = null;\n\n Log = this.require('Log');\n log = new Log({\n 'type': 'warn',\n 'log': message.replace('runtime:', '').replace(/\\[[^\\]]+\\]/, 'warning: ')\n });\n\n this.require('state').logs().push(log);\n this.require('message').warning(message.replace(/\\[[^\\]]+\\]/, 'runtime: '));\t\n}","useCoreAPI":false,"core":false},"i1b8de1d60316328":{"_id":"i1b8de1d60316328","component":"_Channel","state":"$appLogError","action":"function $appLogError(message) { \n var log = '',\n Log = null;\n\n Log = this.require('Log');\n log = new Log({\n 'type': 'error',\n 'log': message.replace('runtime:', '').replace(/\\[[^\\]]+\\]/, 'error: ')\n });\n\n this.require('state').logs().push(log);\n this.require('message').danger(message.replace(/\\[[^\\]]+\\]/, 'runtime: '));\t\n}","useCoreAPI":false,"core":false},"h1ad061990d1bcc5":{"_id":"h1ad061990d1bcc5","component":"_Channel","state":"$editorUpdateType","action":"function $editorUpdateType(id, type) { \n this.require('factory').updateType(id, type);\n\n this.require('designer').save();\n\n this.require('state').space(type.name);\n \n this.require('spaces').render();\n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"h1275e1a9791051a":{"_id":"h1275e1a9791051a","component":"_Channel","state":"$editorDeleteType","action":"function $editorDeleteType(id) { \n var dbTypes = [],\n type = null;\n\n dbTypes = this.require('db').collections().ModelType.find({\n 'uuid': id\n });\n if (dbTypes.length) {\n type = this.require(dbTypes[0]._id);\n if (type) {\n type.hide();\n type.destroy();\n }\n }\n\n this.require('factory').deleteType(id);\n\n this.require('designer').save();\n \n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"u1b3231dd52189ee":{"_id":"u1b3231dd52189ee","component":"_Channel","state":"$editorUpdateSchemaName","action":"function $editorUpdateSchemaName(name, id) { \n this.require('factory').updateSchemaName(name, id);\n \n this.require('designer').save();\t\n}","useCoreAPI":false,"core":false},"w17e86178ff1ac10":{"_id":"w17e86178ff1ac10","component":"_Channel","state":"$editorUpdateSchema","action":"function $editorUpdateSchema(id, schema) { \n var schemas = this.require('factory').system().schemas(),\n models = null,\n model = null,\n modelId = '';\n\n jsPlumb.deleteEveryEndpoint();\n\n this.require('factory').syncModel(schema);\n \n this.require('designer').save();\n \n this.require('factory').updateSchema(id, schema);\n \n this.require('designer').save();\n\n // sync other components\n models = this.require('factory').system().models();\n for (modelId in models) {\n if (models[modelId]._name !== schema._name) {\n model = models[modelId];\n this.require('factory').syncComponent(model, true);\n }\n }\n \n this.require('designer').save();\n\n this.require('state').space(id);\n \n this.require('spaces').render();\n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"f14bae11650167a7":{"_id":"f14bae11650167a7","component":"_Channel","state":"$editorUpdateSchemaId","action":"function $editorUpdateSchemaId(oldId, newId) { \n this.require('factory').updateSchemaId(oldId, newId);\n\n this.require('designer').save();\n \n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"n1cd861eb1d1d0a5":{"_id":"n1cd861eb1d1d0a5","component":"_Channel","state":"$editorUpdateModel","action":"function $editorUpdateModel(id, model) { \n jsPlumb.deleteEveryEndpoint();\n\n this.require('factory').updateModel(id, model);\n\n this.require('designer').save();\n\n this.require('factory').syncBehavior(model);\n \n this.require('designer').save();\n\n this.require('state').space(id);\n \n this.require('spaces').render();\n this.require('workspace').render();\t\n \n $(function () {\n $('[role=\"tooltip\"]').hide();\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"n1a1a113960107dd":{"_id":"n1a1a113960107dd","component":"_Channel","state":"$editorUpdateModelId","action":"function $editorUpdateModelId(oldId, newId) { \n this.require('factory').updateModelId(oldId, newId);\n\n this.require('designer').save();\n \n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"m1219c18bd215028":{"_id":"m1219c18bd215028","component":"_Channel","state":"$designerUpdateBehavior","action":"function $designerUpdateBehavior(id, behavior) { \n this.require('factory').udpdateBehavior(id, behavior);\n\n this.require('designer').save();\n \n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"g1271811dd61f96f":{"_id":"g1271811dd61f96f","component":"_Channel","state":"$editorDeleteBehavior","action":"function $editorDeleteBehavior(id) { \n var dbBehaviors = [],\n behavior = null;\n\n dbBehaviors = this.require('db').collections().ModelBehavior.find({\n 'uuid': id\n });\n if (dbBehaviors.length) {\n behavior = this.require(dbBehaviors[0]._id);\n if (behavior) {\n behavior.hide();\n behavior.destroy();\n }\n }\n\n this.require('factory').deleteBehavior(id);\n\n this.require('designer').save();\n \n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"m1433e1b8e71050a":{"_id":"m1433e1b8e71050a","component":"_Channel","state":"$editorUpdateComponent","action":"function $editorUpdateComponent(id, collection, component) { \n this.require('factory').overwriteComponent(id, collection, component);\n\n this.require('designer').save();\n\n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"e1acfa1989b122ec":{"_id":"e1acfa1989b122ec","component":"_Channel","state":"$editorDeleteComponent","action":"function $editorDeleteComponent(id, collection) { \n var models = [],\n model = null;\n\n models = this.require('db').collections().ModelComponent.find({\n 'uuid': id\n });\n if (models.length) {\n model = this.require(models[0]._id);\n if (model) {\n model.hide();\n model.destroy();\n }\n }\n\n this.require('factory').deleteComponent(id, collection);\n\n this.require('designer').save();\n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"x11f721f8111c41a":{"_id":"x11f721f8111c41a","component":"_Channel","state":"$editorUpdateSystem","action":"function $editorUpdateSystem(id, system) { \n this.require('factory').updateSystem(id, system);\n \n this.require('designer').save();\n\n this.require('state').space(system.name);\n \n this.require('spaces').render();\n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"d180f31873a19ef7":{"_id":"d180f31873a19ef7","component":"_Channel","state":"$appLoadSystem","action":"function $appLoadSystem(system) { \n var Dialog = null,\n dialog = null,\n message = this.require('message');\n\n if (system.name) {\n if (system.name !== 'designer-runtime') {\n Dialog = this.require('DialogImport');\n dialog = new Dialog({\n 'title': 'A system has been found',\n 'message': 'Do you want to import the system ?',\n 'data': system\n });\n dialog.show();\n \n dialog.on('ok', function () {\n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n \n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n \n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n designer.save();\n \n this.require('state').space(sys.name());\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n designer.save();\n \n message.success('Importation of the system is done.');\n });\n }\n } else {\n message.warning('There is no system to import.');\n }\n}","useCoreAPI":false,"core":false},"r1318213d401b598":{"_id":"r1318213d401b598","component":"_Channel","state":"$runtimeCreateComponent","action":"function $runtimeCreateComponent(collection, component) { \n this.require('factory').createComponent(collection, component);\n\n this.require('designer').save();\n\n if (this.require('state').menu() === 'components') {\n this.require('workspace').render();\n }\t\n}","useCoreAPI":false,"core":false},"a125ea107d41f237":{"_id":"a125ea107d41f237","component":"_Channel","state":"$runtimeDeleteComponent","action":"function $runtimeDeleteComponent(id, collection) { \n this.require('factory').deleteComponent(id, collection);\n\n this.require('designer').save();\n\n if (this.require('state').menu() === 'components') {\n this.require('workspace').render();\n }\n}","useCoreAPI":false,"core":false},"n1636d1853518a09":{"_id":"n1636d1853518a09","component":"_Channel","state":"$runtimeUpdateComponent","action":"function $runtimeUpdateComponent(id, collection, field, value) { \n this.require('factory').updateComponent(id, collection, field, value);\n \n this.require('designer').save();\n \n if (this.require('state').menu() === 'components') {\n this.require('workspace').render();\n }\n}","useCoreAPI":false,"core":false},"v165f81ca0d1bd5f":{"_id":"v165f81ca0d1bd5f","component":"_Channel","state":"$designerDeleteSchema","action":"function $designerDeleteSchema(id) { \n var dbSchemas = [],\n schema = null;\n\n dbSchemas = this.require('db').collections().ModelSchema.find({\n 'uuid': id\n });\n if (dbSchemas.length) {\n schema = this.require(dbSchemas[0]._id);\n if (schema) {\n schema.hide();\n schema.destroy();\n }\n }\n\n this.require('factory').deleteSchema(id, false);\n \n this.require('designer').save();\n \n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"u1a9411d65313eb8":{"_id":"u1a9411d65313eb8","component":"_Channel","state":"$editorUpdateBehavior","action":"function $editorUpdateBehavior(id, behavior) { \n this.require('factory').updateBehavior(id, behavior);\n\n this.require('designer').save();\n \n this.require('workspace').render();\n}","useCoreAPI":false,"core":false},"s192131208d1553f":{"_id":"s192131208d1553f","component":"_Channel","state":"init","action":"function init(conf) { \n window.addEventListener('message', function message(event) {\n var data = null,\n config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n data = JSON.parse(event.data);\n if (data &&\n typeof data.event !== 'undefined' &&\n typeof data.from !== 'undefined' &&\n typeof data.data !== 'undefined') {\n $db._Message.insert(data);\n }\n }.bind(this), false);\n\n this.require('_Storage').on('changed', function changed(obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n if (this.require('designer').debugWindow()) {\n this.require('designer').debugWindow().postMessage(JSON.stringify(obj['system-designer-message'].newValue), '*');\n }\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":true,"core":false},"i1fa311dc26116f8":{"_id":"i1fa311dc26116f8","component":"y187401decb196c4","state":"click","action":"function click() {\n $('#designer-toolbar-item-export').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var message = this.require('message');\n var Dialog = this.require('DialogExport');\n\n if (this.require('factory').system()) {\n var dialog = new Dialog({\n 'title': 'Export the current system',\n });\n dialog.show();\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"f1ae6e164301b982":{"_id":"f1ae6e164301b982","component":"x1371910b7812e58","state":"click","action":"function click() {\n var debugWindow = this.require('designer').debugWindow(),\n config = this.require('storage').get('system-designer-config'),\n message = this.require('message');\n\n $('#designer-toolbar-item-refresh').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (config) {\n if (typeof config.debugType !== 'undefined' && config.debugType === 'client') {\n if (config.urlClient) {\n if (debugWindow && !debugWindow.closed) {\n message.success('Searching for a system...');\n this.require('channel').$designerSync();\n } else {\n message.success('Opening the page...');\n this.require('designer').debugWindow(this.require('designer').open(config.urlClient, 'debug'));\n }\n } else {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n }\n if (typeof config.debugType !== 'undefined' && config.debugType === 'server') {\n if (config.urlServer) {\n message.success('Searching for a server...');\n var self = this;\n $.getJSON(config.urlServer.replace(':8888', '') + ':8888/$designerSync', function (system) {\n var Dialog = null,\n dialog = null,\n message = runtime.require('message');\n \n if (system && system.name) {\n Dialog = self.require('DialogImport');\n dialog = new Dialog({\n 'title': 'A system has been found',\n 'message': 'Do you wan to import it ?',\n 'data': system\n });\n dialog.show();\n \n dialog.on('ok', function () {\n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n \n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n \n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n designer.save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n designer.save();\n \n message.success('Importation of the system is done.');\n });\n } else {\n message.warning('There is no system to import.');\n }\n });\n } else {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n }\n if (typeof config.debugType === 'undefined') {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n } else {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"q141da1eb5d1916b":{"_id":"q141da1eb5d1916b","component":"g12f9e166c71cf91","state":"click","action":"function click() {\n $('#designer-toolbar-item-extension').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogExtension = this.require('DialogExtension');\n\n DialogExtension = new DialogExtension({\n 'title': 'Manage your extensions'\n });\n DialogExtension.show();\n}","useCoreAPI":false,"core":false},"k1f66b12b5f1b625":{"_id":"k1f66b12b5f1b625","component":"l1f2871e69b1b85e","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"w19413126bf1bf40":{"_id":"w19413126bf1bf40","component":"s1aa5c1170e1eba3","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"y1eaaf1fe0719457":{"_id":"y1eaaf1fe0719457","component":"_Channel","state":"$editorUpdateComponentId","action":"function $editorUpdateComponentId(oldId, newId) { \n this.require('factory').updateComponentId(oldId, newId);\n\n this.require('designer').save();\n \n this.require('workspace').render();\t\t\n}","useCoreAPI":false,"core":false},"w1875419b271fb1c":{"_id":"w1875419b271fb1c","component":"Designer","state":"addShorcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null,\n position = 0;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if (this.require('factory').system()) {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n } else {\n message.warning('There is no system.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + F\n case key === 70 && command:\n if (this.require('factory').system()) {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogSearch');\n dialog = new Dialog({\n 'title': 'Search in the system',\n });\n dialog.show();\n } else {\n message.warning('There is no system.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + '+'\n case (key === 187 || key === 43) && command:\n if (!this.require('factory').system() && this.require('state').menu() !== 'systems') {\n message.warning('There is no system: create first a system to continue.');\n } else {\n if (this.require('factory').system() && Object.keys(this.require('factory').system().schemas()).length === 0 && this.require('state').menu() === 'components') {\n message.warning('There is no schema: create first a schema to continue.');\n } else {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n this.require('workspace').create();\n }\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + I\n case key === 73 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n var DialogImportFile = this.require('DialogImportFile');\n \n DialogImportFile = new DialogImportFile({\n 'title': 'Import a system'\n });\n DialogImportFile.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + E\n case key === 69 && command:\n if (this.require('factory').system()) {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = this.require('DialogExport');\n dialog = new Dialog({\n 'title': 'Export the current system',\n });\n dialog.show();\n } else {\n message.warning('There is no system to export.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + ->\n case key === 39 && command:\n position = this.require('state').navigation().menu().indexOf('designer-menu-item-' + this.require('state').menu());\n if (position !== -1) {\n position = position + 1;\n if (position === this.require('state').navigation().menu().length) {\n position = 0;\n }\n document.getElementById(this.require('state').navigation().menu(position)).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + <-\n case key === 37 && command:\n position = this.require('state').navigation().menu().indexOf('designer-menu-item-' + this.require('state').menu());\n if (position !== -1) {\n position = position - 1;\n if (position === -1) {\n position = this.require('state').navigation().menu().length -1;\n }\n document.getElementById(this.require('state').navigation().menu(position)).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + v\n case key === 40 && command:\n position = this.require('state').navigation().spaces().indexOf('designer-space-' + this.require('state').space());\n if (position !== -1) {\n position = position + 1;\n if (position === this.require('state').navigation().spaces().length) {\n position = 0;\n }\n $('#' + this.require('state').navigation().spaces(position)).children()[0].click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false; \n break;\n // Command + ^\n case key === 38 && command:\n position = this.require('state').navigation().spaces().indexOf('designer-space-' + this.require('state').space());\n if (position !== -1) {\n position = position - 1;\n if (position === -1) {\n position = this.require('state').navigation().spaces().length - 1;\n }\n $('#' + this.require('state').navigation().spaces(position)).children()[0].click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false; \n break; \n // Command + Enter\n case key === 13 && command:\n this.require('13f70137b61b19b').click();\n event.stopPropagation();\n event.preventDefault();\n return false; \n break;\n // Enter \n case key === 13 && !command:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if (this.require('factory').system()) {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n } else {\n message.warning('There is no system.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + F\n case key === 70 && ctrl:\n if (this.require('factory').system()) {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogSearch');\n dialog = new Dialog({\n 'title': 'Search in the system',\n });\n dialog.show();\n } else {\n message.warning('There is no system.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + '+' \n case (key === 187 || key === 43) && ctrl:\n if (!this.require('factory').system() && this.require('state').menu() !== 'systems') {\n message.warning('There is no system: create first a system to continue.');\n } else {\n if (this.require('factory').system() && Object.keys(this.require('factory').system().schemas()).length === 0 && this.require('state').menu() === 'components') {\n message.warning('There is no schema: create first a schema to continue.');\n } else {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n this.require('workspace').create();\n }\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + I\n case key === 73 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n var DialogImportFile = this.require('DialogImportFile');\n \n DialogImportFile = new DialogImportFile({\n 'title': 'Import a system'\n });\n DialogImportFile.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + E\n case key === 69 && ctrl:\n if (this.require('factory').system()) {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = this.require('DialogExport');\n dialog = new Dialog({\n 'title': 'Export the current system',\n });\n dialog.show();\n } else {\n message.warning('There is no system to export.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + ->\n case key === 39 && ctrl:\n position = this.require('state').navigation().menu().indexOf('designer-menu-item-' + this.require('state').menu());\n if (position !== -1) {\n position = position + 1;\n if (position === this.require('state').navigation().menu().length) {\n position = 0;\n }\n document.getElementById(this.require('state').navigation().menu(position)).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + <-\n case key === 37 && ctrl:\n position = this.require('state').navigation().menu().indexOf('designer-menu-item-' + this.require('state').menu());\n if (position !== -1) {\n position = position - 1;\n if (position === -1) {\n position = this.require('state').navigation().menu().length -1;\n }\n document.getElementById(this.require('state').navigation().menu(position)).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + v\n case key === 40 && ctrl:\n position = this.require('state').navigation().spaces().indexOf('designer-space-' + this.require('state').space());\n if (position !== -1) {\n position = position + 1;\n if (position === this.require('state').navigation().spaces().length) {\n position = 0;\n }\n $('#' + this.require('state').navigation().spaces(position)).children()[0].click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false; \n break;\n // Ctrl + ^\n case key === 38 && ctrl:\n position = this.require('state').navigation().spaces().indexOf('designer-space-' + this.require('state').space());\n if (position !== -1) {\n position = position - 1;\n if (position === -1) {\n position = this.require('state').navigation().spaces().length - 1;\n }\n $('#' + this.require('state').navigation().spaces(position)).children()[0].click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false; \n break; \n // Ctrl + Enter\n case key === 13 && ctrl:\n this.require('13f70137b61b19b').click();\n event.stopPropagation();\n event.preventDefault();\n return false; \n break;\n // Enter \n case key === 13 && !command:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break; \n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false},"q1e05f1c28c13d04":{"_id":"q1e05f1c28c13d04","component":"Designer","state":"runMessages","action":"function runMessages(messages) { \n messages.forEach(function (message) {\n if (message && message.event && message.event.indexOf('$system') === -1) {\n $db._Message.insert(message);\n }\n });\t\n}","useCoreAPI":true,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"2.8.3"}},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.1.1","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1d113198721599d":{"_id":"l1d113198721599d","_name":"MenuItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"u1f9a01abe31b3bf":{"_id":"u1f9a01abe31b3bf","_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"menuitem-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"name":{"type":"string","readOnly":false,"mandatory":false,"default":"template"},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"},"render":{},"click":{}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() { \n\tvar name = $('#modal-modeljson-name').val(),\n\t jsonText = $('#modal-modeljson-json').val(),\n\t json = null,\n\t schema = {},\n\t model = {},\n\t property = '',\n\t type = '',\n\t typeName = '',\n\t arrayType = '',\n\t that = this,\n\t createdTypes = [];\n\t \n\tfunction _getTypeName(parent, name) {\n\t var result = name;\n\t \n\t if (!_validType(name)) {\n\t if (parent) {\n\t result = parent + '_' + name;\n\t } else {\n\t result = name + Math.floor(Math.random() * 11);\n\t }\n\t }\n\t \n\t return result;\n\t} \n\n function _getType(value) {\n var type = '';\n \n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n \n return type;\n } \n \n function _validName(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n } \n \n function _validType(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n return result;\n } \n \n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = ''; \n \n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false); \n \n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n switch (type) {\n case 'object':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = {};\n break;\n case 'number':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'number';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = 0;\n break;\n case 'boolean':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'boolean';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = false;\n break;\n case 'array':\n typeDef.schema[property] = {};\n typeDef.schema[property].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n \n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n \t typeDef.schema[property].type = [_createTypeFromObject(name, property, obj[property][0])];\n \t typeDef.schema[property].default = [];\n \t } else {\n \t typeDef.schema[property].type = ['object'];\n \t typeDef.schema[property].default = [];\n \t }\n } else {\n typeDef.schema[property].type = [arrayType];\n typeDef.schema[property].default = [];\n }\n } else {\n typeDef.schema[property].type = ['any'];\n typeDef.schema[property].default = [];\n\t }\n break;\n default:\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'string';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n \n return typeName;\n }\n \n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n\tif (name && _validName(name) && jsonText) {\n\t try {\n\t json = JSON.parse(jsonText);\n\t if (json) {\n\t // schema\n\t schema = this.require('factory').addSchema(name.trim());\n\t \n\t schema._inherit = [];\n\t this.require('factory').updateSchema(schema._id, schema);\n\t \n\t this.require('designer').save();\n\t \n\t for (property in json) {\n\t if (property.indexOf('_') !== 0) {\n \t type = _getType(json[property]);\n \t if (type === 'array') {\n \t schema[property] = 'collection';\n \t } else {\n \t schema[property] = 'property';\n \t }\n\t }\n\t }\n\t \n\t this.require('factory').updateSchema(schema._id, schema);\n\t this.require('designer').save();\n\t \n\t // model\n\t model = this.require('factory').createModel(schema);\n\t this.require('designer').save();\n\n\t for (property in schema) {\n\t if (property.indexOf('_') !== 0) {\n\t type = _getType(json[property]);\n\t switch (type) {\n\t case 'object':\n\t if (json[property] !== null) {\n\t model[property].type = _createTypeFromObject('', property, json[property]);\n\t model[property].default = {};\n\t } else {\n\t model[property].type = 'object';\n\t model[property].default = {};\n\t }\n\t break;\n\t case 'number':\n\t model[property].type = 'number';\n\t model[property].default = 0;\n\t break;\n\t case 'boolean':\n\t model[property].type = 'boolean';\n\t model[property].default = false;\n\t break;\n\t case 'array':\n\t if (typeof json[property][0] !== 'undefined') {\n\t arrayType = _getType(json[property][0]);\n\t if (arrayType === 'object') {\n\t if (json[property][0] !== null) {\n \t model[property].type = [_createTypeFromObject('', property, json[property][0])];\n \t model[property].default = [];\n \t } else {\n \t model[property].type = ['object'];\n \t model[property].default = [];\n \t }\n\t } else {\n\t model[property].type = [arrayType];\n\t model[property].default = [];\n\t }\n\t } else {\n\t model[property].type = ['any'];\n\t model[property].default = [];\n\t }\n\t break;\n\t \tcase 'string':\n\t model[property].type = 'string';\n\t model[property].default = '';\n\t break;\n\t default:\n\t break;\n\t }\n\t }\n\t }\n\t \n\t this.require('factory').updateModel(model._id, model);\n\t this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\t \n\t this.require('message').success('A model has been created for the JSON.');\n\t }\n\t } catch(e) {\n\t this.hide();\n\t this.require('message').warning('Can not create the model: the JSON is invalid.');\n\t }\n\t} \n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"MenuItem":{},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2018 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v2.8.3"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"A behavior is the action to do when a method or an event is called."},"help-components.html":{"_id":"help-components.html","source":"Components are your classes instances. Their states are saved in a store, a JSON object."},"help-logs.html":{"_id":"help-logs.html","source":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "},"help-models.html":{"_id":"help-models.html","source":"A model is an UML representation of your classes. It is generated from a schema."},"help-schemas.html":{"_id":"help-schemas.html","source":"A schema is the definition of your model. Models are generated based on the schema definition."},"help-system.html":{"_id":"help-system.html","source":"An application is a system. Once you have created one, your next step is to create a schema."},"help-types.html":{"_id":"help-types.html","source":"A type is used in your model to define an enumeration or a structure."},"menu-action-search.html":{"_id":"menu-action-search.html","source":"
    \n
    \n \n
    \n
    "},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-guide.html":{"_id":"menu-item-guide.html","source":"Guide"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs"},"menu-item-message-save.html":{"_id":"menu-item-message-save.html","source":" file saved!"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-quick-start.html":{"_id":"menu-item-quick-start.html","source":"Quick Start"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.0.0","description":"Quick start\n\nThis system is taken from the quick start: https://system-designer.readme.io/docs/quick-start","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n var luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n var result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vador":{"_id":"vador","father":"","firstName":"Dark","lastName":"Vador"},"luke":{"_id":"luke","father":"vador","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"04-send-messages.json":{"_id":"04-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.0.0","description":"Send messages threw a channel\n\n\nYou can send messages from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. In '_Channel' 'send' method, define how to send the message to another channel (webRTC, XHR, ...).\n3. In another system, define how to get the message and send it to the system with: runtime.message().\n4. To send a message: this.require('channel').myevent(param1, param2, ...).\n5. To listen to the message, just add a behavior to the event.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.0.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"type":"css","readOnly":false,"mandatory":false,"default":""},"render":{}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{},"filter":{"type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n var html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n var div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n var items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n var author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.0.1","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n var http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"04-create-extension.json":{"_id":"04-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.1.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"05-listen-collection-events.json":{"_id":"05-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.0.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""},"field":{"type":"string","mandatory":true,"default":""},"value":{"type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"document":{"type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179ba":{"_id":"1f8571164c179ba","html":"menu-action-version.html","position":10,"type":"designer"}},"MenuHeader":{"1fb101b99813a12":{"_id":"1fb101b99813a12","html":"menu-header.html","type":"designer"}},"MenuItem":{"14f481302c106e6":{"_id":"14f481302c106e6","name":"models","html":"menu-item-models.html","position":20,"type":"designer","platform":"all"},"14f481302c106e7":{"_id":"14f481302c106e7","name":"logs","html":"menu-item-logs.html","position":60,"type":"designer","platform":"all"},"154dd1323f1ffg0a":{"_id":"154dd1323f1ffg0a","name":"systems","html":"menu-item-system.html","position":10,"type":"designer","platform":"all"},"154dd1323f1ffg1a":{"_id":"154dd1323f1ffg1a","name":"schemas","html":"menu-item-schemas.html","position":10,"type":"designer","platform":"all"},"19ec81ce751e196":{"_id":"19ec81ce751e196","name":"components","html":"menu-item-components.html","position":50,"type":"designer","platform":"all"},"1eb9d188b11824c":{"_id":"1eb9d188b11824c","name":"behaviors","html":"menu-item-behaviors.html","position":40,"type":"designer","platform":"all"},"1fd911618e18ea9":{"_id":"1fd911618e18ea9","name":"types","html":"menu-item-types.html","position":30,"type":"designer","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"1dbc51300e11z17":{"_id":"1dbc51300e11z17","html":"toolbar-item-search.html","position":35,"type":"designer","platform":"all"},"163a01b7ca1935c":{"_id":"163a01b7ca1935c","html":"toolbar-item-refresh.html","position":40,"type":"designer","platform":"web"},"163a01b7ca1935e":{"_id":"163a01b7ca1935e","html":"toolbar-item-export.html","position":50,"type":"designer","platform":"web"},"10bcb1a0511e09f":{"_id":"10bcb1a0511e09f","html":"toolbar-item-create.html","position":20,"type":"designer","platform":"all"},"13a291c27f16310":{"_id":"13a291c27f16310","html":"toolbar-item-copyright.html","position":90,"type":"designer","platform":"all"},"13a291c27f16314":{"_id":"13a291c27f16314","html":"toolbar-item-help.html","position":80,"type":"designer","platform":"all"},"13f70137b61b19b":{"_id":"13f70137b61b19b","html":"toolbar-item-publish.html","position":30,"type":"designer","platform":"all"},"163a01b7ca1935d":{"_id":"163a01b7ca1935d","html":"toolbar-item-import.html","position":45,"type":"designer","platform":"all"},"1dbc51200e116e11":{"_id":"1dbc51200e116e11","html":"toolbar-item-sync.html","position":65,"type":"designer","platform":"all"},"1dbc51200e116e3":{"_id":"1dbc51200e116e3","html":"toolbar-item-config.html","position":70,"type":"designer","platform":"all"},"y187401decb196c4":{"_id":"y187401decb196c4","html":"toolbar-item-export.html","position":50,"type":"designer","platform":"electron"},"x1371910b7812e58":{"_id":"x1371910b7812e58","html":"toolbar-item-refresh.html","position":40,"type":"designer","platform":"electron"},"g12f9e166c71cf91":{"_id":"g12f9e166c71cf91","html":"toolbar-item-extension.html","platform":"all","position":67,"type":"designer"},"l1f2871e69b1b85e":{"_id":"l1f2871e69b1b85e","html":"toolbar-item-command.html","platform":"web","position":37,"type":"designer"},"s1aa5c1170e1eba3":{"_id":"s1aa5c1170e1eba3","html":"toolbar-item-command.html","platform":"electron","position":37,"type":"designer"}}},"_id":"e89c617b6b15d28"}); \ No newline at end of file +runtime.install({"name":"system-designer","master":true,"version":"2.9.0","description":"A Designer for Systems","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$designerSetSystem":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","messages":"property"},"v123b51abbb18712":{"_id":"v123b51abbb18712","_name":"Diagram","_inherit":["_Component"],"ref":"property","zoom":"property","render":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method","toGraphviz":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"],"designer":"property"},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","isType":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"]},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]},"$designerSetSystem":{"params":[{"name":"system","type":"object","mandatory":false,"default":{}}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"2.9.0"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]}},"b169321637f19101":{"_id":"b169321637f19101","_name":"Diagram","_description":"","ref":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""},"zoom":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":1},"render":{"description":"","params":[],"result":"any"}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toGraphviz":{"description":"","params":[],"result":"string"}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":false}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57"},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10","designer":{"type":"Designer","readOnly":true,"mandatory":false,"default":{}}},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"},"isType":{"description":"","params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}},"j1311d115381b738":{"_id":"j1311d115381b738","_name":"State","type":{"type":"string","readOnly":false,"mandatory":false,"default":""},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null;\n \n if (extension.installed) { \n system = extension.source;\n \n try {\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n } catch (e) {\n this.require('message').danger('Can not install an extension.');\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n\n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').hide();\n }\n } else {\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-type-import').show();\n }\n }\n if (this.require('designer').isCordova()) {\n $('#designer-dialog-import-modal-from-file').attr('checked', false);\n $('#designer-dialog-import-modal-from-library').attr('checked', true);\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n that.data(JSON.parse(json));\n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-export-graphviz');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').uninstall('ext_' + system._id)\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-graphviz').prop('checked'):\n textToWrite = this.require('export').toGraphviz();\n fileNameToSaveAs = this.require('factory').system().name() + '.gv';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n downloadLink.click();\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n if (system.name === name) {\n result = false;\n break;\n }\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n \n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"snippet\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'snippet' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'snippet' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'snippet' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'snippet' });\n }\n \n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n \n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n \n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n \n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n \n // snippets\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet:'{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'snippet' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n \n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"snippet\" });\n }\n \n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n \n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n \n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n \n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n \n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"e13c7916b1a15fc4":{"_id":"e13c7916b1a15fc4","component":"Export","state":"toGraphviz","action":"function toGraphviz() {\n var schemas = this.require('factory').system().schemas();\n var models = this.require('factory').system().models();\n var inheritance = '';\n var modelId = '';\n var modelName = '';\n var modelDescription = '';\n var propName = '';\n var propVal = '';\n var attributes = '';\n var methods = '';\n var result = '';\n var links = '';\n var collections = '';\n var that = this;\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n // create model\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n modelDescription += '\\n\\n\\t' + modelName + ' [\\r\\t\\tlabel = \"{' + modelName + '|';\n \n attributes = '';\n methods = '';\n\n for (propName in models[modelId]) {\n if (models[modelId].hasOwnProperty(propName)) {\n propVal = models[modelId][propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (modelId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (modelId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n }\n } else {\n attributes += '+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n }\n }\n }\n break;\n \n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + params + ' : ' + result + '\\\\l';\n } else {\n methods += '+ ' + propName + params + ' : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + params + '\\\\l';\n } else {\n methods += '+ ' + propName + params + '\\\\l';\n }\n }\n break;\n \n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n \n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + '() : ' + result + '\\\\l';\n } else {\n methods += '+ ' + propName + '() : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '+ ' + propName + '()\\\\l';\n } else {\n methods += '+ ' + propName + '()\\\\l';\n }\n }\n break;\n }\n }\n }\n\n modelDescription += attributes + '|' + methods;\n modelDescription += '}\"\\r\\t]';\n }\n\n // create inheritance links\n for (var schema in schemas) {\n if (schemas[schema]._inherit && schemas[schema]._inherit.length) {\n schemas[schema]._inherit.forEach(function (parent) {\n inheritance += '\\n\\t' + schemas[schema]._name + ' -> ' + parent;\n });\n }\n }\n \n // case of Component\n if (inheritance.indexOf('_Component') !== -1) {\n modelDescription += `\\n\\t_Component [\n label = \"{_Component|+ id : string\\\\l|+ classInfo() : _ClassInfo\\\\l+ init(conf : object)\\\\l+ destroy()\\\\l+ on(state : string, action : function, useCoreAPI : boolean, isCore : boolean) : string\\\\l+ off(state : string, behaviorId : string)\\\\l+ require(id : string) : _Component\\\\l+ error(data : errorParam)\\\\l}\"\n ]` \n };\n\n let generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n \n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]${modelDescription}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"1\"\n taillabel = \"\"\n ]\n ${links}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"0..*\"\n taillabel = \"\"\n ]\n ${collections}\n\n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n arrowhead = \"empty\"\n headlabel = \"\"\n taillabel = \"\"\n ]\n ${inheritance}\n}`;\n\n return generatedDiagram;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n\n repo1.writeFile('master', system.name + '.json', JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html', htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js', jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^2.9.0';\n\n repo4.writeFile('master', 'package.json', JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.source());\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n \n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n });\n\n menuActions.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('afterbegin', '
  • ' + action.html().source() + '');\n });\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n this.require('state').messages(messages);\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n for (propName in this.document().schema) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '';\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n }\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n\n systemId = this.require('factory').system().id();\n schema = _getSchema(this.model());\n model = _getModel(this.model());\n\n for (propName in this.document()) {\n if (this.document().hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = this.document()[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n if (modelName === '_Component') {\n modelName = _getModelFromComponent(propVal);\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n function gen() {\n return Math.floor((1 + Math.random()) * 0x10000).toString(16);\n }\n function getPrefix() {\n var validPrefix = 'abcdefghijklmnopqrstuvwxyz';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return getPrefix() + gen() + gen() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"v119e617ef513e94":{"_id":"v119e617ef513e94","component":"SystemFactory","state":"isType","action":"function isType(name) { \n var types = this.system().types(),\n result = false,\n prop = '';\n\n\tif (!result) {\n\t for (prop in types) {\n\t if (schemas[prop].name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n\n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n \n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system !== 'undefined':\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && typeof system !== 'undefined':\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && typeof system !== 'undefined':\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && typeof system !== 'undefined' && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && typeof system !== 'undefined' && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && typeof system === 'undefined':\n message = \"To create a system, click here.\";\n break;\n default:\n break;\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin', \n template.source().replace(/{{message}}/gi, message));\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom) {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n if (typeof system !== 'undefined') {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (typeof system === 'undefined') {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"z14cf91f7131c34d":{"_id":"z14cf91f7131c34d","component":"1dbc51300e11z17","state":"click","action":"function click() {\n $('#designer-toolbar-item-search').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n\n var message = this.require('message');\n var Dialog = this.require('DialogSearch');\n\n if (this.require('factory').system()) {\n var dialog = new Dialog({\n 'title': 'Search in the system',\n });\n dialog.show();\n } else {\n message.warning('There is no system.');\n }\n}"},"a13b711adba1c7d4":{"_id":"a13b711adba1c7d4","component":"163a01b7ca1935c","state":"click","action":"function click() {\n var debugWindow = this.require('designer').debugWindow(),\n config = this.require('storage').get('system-designer-config'),\n message = this.require('message');\n\n $('#designer-toolbar-item-refresh').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (config) {\n if (typeof config.debugType !== 'undefined' && config.debugType === 'client') {\n if (config.urlClient) {\n if (debugWindow && !debugWindow.closed) {\n message.success('Searching for a system...');\n this.require('channel').$designerSync();\n } else {\n message.success('Opening the page...');\n this.require('designer').debugWindow(this.require('designer').open(config.urlClient, 'debug'));\n }\n } else {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n }\n if (typeof config.debugType !== 'undefined' && config.debugType === 'server') {\n if (config.urlServer) {\n message.success('Searching for a server...');\n var self = this;\n $.getJSON(config.urlServer.replace(':8888', '') + ':8888/$designerSync', function (system) {\n var Dialog = null,\n dialog = null,\n message = runtime.require('message');\n \n if (system && system.name) {\n Dialog = self.require('DialogImport');\n dialog = new Dialog({\n 'title': 'A system has been found',\n 'message': 'Do you wan to import it ?',\n 'data': system\n });\n dialog.show();\n \n dialog.on('ok', function () {\n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n \n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n \n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n designer.save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n designer.save();\n \n message.success('Importation of the system is done.');\n });\n } else {\n message.warning('There is no system to import.');\n }\n });\n } else {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n }\n if (typeof config.debugType === 'undefined') {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n } else {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n}"},"e137f915b1b15f90":{"_id":"e137f915b1b15f90","component":"163a01b7ca1935e","state":"click","action":"function click() {\n $('#designer-toolbar-item-export').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var message = this.require('message');\n var Dialog = this.require('DialogExport');\n\n if (this.require('factory').system()) {\n var dialog = new Dialog({\n 'title': 'Export the current system',\n });\n dialog.show();\n } else {\n message.warning('There is no system to export.');\n }\n}"},"p1087a100821fa03":{"_id":"p1087a100821fa03","component":"1dbc51200e116e3","state":"click","action":"function click() {\n $('#designer-toolbar-item-config').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogConfig = this.require('DialogConfig');\n\n DialogConfig = new DialogConfig({\n 'title': 'Configuration'\n });\n DialogConfig.show();\n DialogConfig.on('ok', function () {\n var message = this.require('message');\n\n this.hide();\n message.success('Configuration saved.');\n });\n}"},"y1163b139241a596":{"_id":"y1163b139241a596","component":"1dbc51200e116e11","state":"click","action":"function click() {\n $('#designer-toolbar-item-sync').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogSync = this.require('DialogSync');\n\n DialogSync = new DialogSync({\n 'title': 'GitHub'\n });\n DialogSync.show();\n DialogSync.on('ok', function () {\n if ($('#designer-dialog-sync-refresh').prop('checked')) {\n this.require('github').refresh();\n } else {\n this.require('github').push(\n $('#designer-dialog-sync-comments').val(),\n $('#designer-dialog-type-creation-hasHTML').prop('checked'),\n false,\n $('#designer-dialog-sync-options-log-level-select').val(),\n $('#designer-dialog-type-creation-hasPackage').prop('checked')\n );\n }\n this.hide();\n });\n}"},"o1ec561a54015768":{"_id":"o1ec561a54015768","component":"163a01b7ca1935d","state":"click","action":"function click() {\n $('#designer-toolbar-item-import').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogImportFile = this.require('DialogImportFile');\n\n var dialogImportFile = new DialogImportFile({\n 'title': 'Import a system'\n });\n dialogImportFile.show();\n}"},"q178081a11712887":{"_id":"q178081a11712887","component":"13f70137b61b19b","state":"click","action":"function click() {\n var designer = this.require('designer'),\n message = this.require('message'),\n debugWindow = this.require('designer').debugWindow(),\n runWidow = this.require('designer').runWindow(),\n system = this.require('factory').system(),\n json = {},\n cleanJson = '',\n reg = null;\n\n $('#designer-toolbar-item-publish').tooltip('hide');\n if (system) {\n\n // force save befor running the app\n this.require('designer').save();\n\n\n switch(true) {\n // case of extension\n case system.name().indexOf('extension-') !== -1:\n json = this.require('factory').toJSON();\n\n cleanJson = JSON.stringify(json);\n reg = new RegExp(json._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + json._id);\n json = JSON.parse(cleanJson);\n\n runtime.uninstall(json._id);\n runtime.install(json);\n this.require('menubar').render();\n this.require('toolbar').render();\n message.success('The extension has been installed.');\n break;\n \n // case of remote debugging\n case debugWindow && !debugWindow.closed:\n this.require('channel').$designerSetSystem(this.require('factory').toJSON());\n // TODO Refresh the page\n message.success('Running the system in the remote page...');\n break;\n\n // reload the running page\n case runWidow && !runWidow.closed:\n runWidow.close();\n this.require('designer').runWindow(this.require('designer').open('app/index.html#' + this.require('factory').system().id(), 'app'));\n message.success('Running the system...');\n\n /*if (typeof require === 'undefined') {\n runWidow.document.location.reload();\n message.success('Running the system...');\n } else {\n // TODO \n // to reload when implemented in electron\n message.info('info: to run again the system, click the widow where your system is running and go to the menu \\'View > Refresh\\’.');\n }*/\n break;\n\n // we load for the first time the page\n default:\n this.require('designer').runWindow(this.require('designer').open('app/index.html#' + this.require('factory').system().id(), 'app'));\n message.success('Running the system...');\n break;\n }\n } else {\n message.warning('There is no system to run.');\n }\n}","useCoreAPI":true},"k1a9e11cd571d17c":{"_id":"k1a9e11cd571d17c","component":"13a291c27f16314","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n \n switch (this.require('state').menu()) {\n case 'systems':\n this.require('designer').open('https://system-designer.readme.io/docs/create-a-system', '_blank', true); \n break;\n case 'schemas':\n this.require('designer').open('https://system-designer.readme.io/docs/create-a-schema', '_blank', true); \n break;\n case 'models':\n this.require('designer').open('https://system-designer.readme.io/docs/edit-a-model', '_blank', true); \n break;\n case 'types':\n this.require('designer').open('https://system-designer.readme.io/docs/create-a-type', '_blank', true); \n break;\n case 'behaviors':\n this.require('designer').open('https://system-designer.readme.io/docs/create-a-behavior', '_blank', true); \n break;\n case 'components':\n this.require('designer').open('https://system-designer.readme.io/docs/create-a-component', '_blank', true); \n break;\n case 'logs':\n this.require('designer').open('https://system-designer.readme.io/docs/run-your-system', '_blank', true);\n break;\n default:\n this.require('designer').open('https://system-designer.readme.io/docs/quick-start', '_blank', true); \n break;\n }\n}"},"o1ff8e17e1c1bcd7":{"_id":"o1ff8e17e1c1bcd7","component":"13a291c27f16310","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"c15ea3176d5139e8":{"_id":"c15ea3176d5139e8","component":"10bcb1a0511e09f","state":"click","action":"function click() { \n $('#designer-toolbar-item-create').tooltip('hide');\n var message = this.require('message'),\n designer = this.require('designer');\n \n if (!this.require('factory').system() && this.require('state').menu() !== 'systems') {\n message.warning('There is no system: create first a system to continue.');\n } else {\n if (this.require('factory').system() && Object.keys(this.require('factory').system().schemas()).length === 0 && this.require('state').menu() === 'components') {\n message.warning('There is no schema: create first a schema to continue.');\n } else {\n this.require('workspace').create();\n }\n }\n}"},"l19fda1461e1d86c":{"_id":"l19fda1461e1d86c","component":"Spaces","state":"clear","action":"function clear() { \n this.require('state').space('');\n $('#designer-spaces-items').empty();\n}","useCoreAPI":false,"core":false},"a16e02190b216769":{"_id":"a16e02190b216769","component":"Spaces","state":"render","action":"function render() { \n var item = null,\n items = [],\n components = [],\n systemItems = [],\n system = this.require('factory').system(),\n SpaceItem = this.require('SpaceItem'),\n spaceItem = null,\n space = '',\n id = '',\n domItems = document.getElementById('designer-spaces-items'),\n systemdomItems = document.getElementById('designer-spaces-system-items'),\n componentdomItems = document.getElementById('designer-spaces-components-items'),\n self = this,\n name = '',\n callback = null,\n modelsName = [],\n showComponents = false,\n modelName = '',\n componentId = '';\n\n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n\n function _findModel(compId, components) {\n var result = '',\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n $('#designer-spaces-help').empty();\n\n // update header and help\n switch (this.require('state').menu()) {\n case 'systems':\n $('#designer-spaces-spaces-system').hide();\n $('#designer-spaces-spaces-components').hide();\n document.getElementById('designer-spaces-type').innerHTML = 'Systems';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-system.html').source());\n break;\n case 'schemas':\n $('#designer-spaces-spaces-system').hide();\n $('#designer-spaces-spaces-components').hide();\n document.getElementById('designer-spaces-type').innerHTML = 'Schemas';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-schemas.html').source());\n break;\n case 'models':\n $('#designer-spaces-spaces-system').hide();\n $('#designer-spaces-spaces-components').hide();\n document.getElementById('designer-spaces-type').innerHTML = 'Models';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-models.html').source());\n break;\n case 'types':\n $('#designer-spaces-spaces-system').hide();\n $('#designer-spaces-spaces-components').hide();\n document.getElementById('designer-spaces-type').innerHTML = 'Types';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-types.html').source());\n break;\n case 'behaviors':\n $('#designer-spaces-spaces-system').show();\n $('#designer-spaces-spaces-components').show();\n document.getElementById('designer-spaces-type').innerHTML = 'Models';\n document.getElementById('designer-spaces-system-header').innerHTML = 'System';\n document.getElementById('designer-spaces-components-header').innerHTML = 'Components';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-behaviors.html').source());\n break;\n case 'components':\n $('#designer-spaces-spaces-system').hide();\n $('#designer-spaces-spaces-components').hide();\n document.getElementById('designer-spaces-type').innerHTML = 'Models';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-components.html').source());\n break;\n case 'logs':\n $('#designer-spaces-spaces-system').hide();\n $('#designer-spaces-spaces-components').hide();\n document.getElementById('designer-spaces-type').innerHTML = 'Logs';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-logs.html').source());\n break;\n default:\n break;\n }\n\n // update spaces\n // clear\n $('#designer-spaces-items').empty();\n $('#designer-spaces-system-items').empty();\n $('#designer-spaces-components-items').empty();\n if (system) {\n switch (this.require('state').menu()) {\n case 'systems':\n // items \n var systems = this.require('storage').get('system-designer-systems'),\n systemIds = [],\n length = 0,\n i = 0;\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n spaceItem = new SpaceItem({\n 'name': system.name,\n 'uuid': system._id\n });\n items.push(spaceItem);\n }\n \n this.items(items);\n\n // sort\n this.items().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n \n this.require('state').navigation().spaces([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.name() + '
  • ');\n this.require('state').navigation().spaces().push('designer-space-' + item.name());\n }.bind(this));\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n\n this.items().forEach(function (item) {\n item.on('click', function () {\n var designer = this.require('designer'),\n system = this.require('storage').get(this.uuid()),\n System = this.require('System');\n \n if (system) {\n this.require('factory').create(system);\n }\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n });\n });\n\n // focus\n if (length > 0) {\n if ($('#designer-space-' + this.require('state').space()).length) {\n $('#designer-space-' + this.require('state').space()).addClass('active');\n } else {\n if (this.require('factory').system()) {\n if ($('#designer-space-' + this.require('factory').system().name()).length) {\n $('#designer-space-' + this.require('factory').system().name()).addClass('active');\n this.require('state').space(this.require('factory').system().name());\n }\n } else {\n item = domItems.children[0];\n $(item).addClass('active');\n this.require('state').space(this.items(0).name());\n }\n }\n }\n\n break;\n case 'schemas':\n // items \n for (name in system.schemas()) {\n spaceItem = new SpaceItem({\n 'name': system.schemas()[name]._name,\n 'uuid': name\n });\n items.push(spaceItem);\n }\n \n this.items(items);\n\n // sort\n this.items().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n\n this.require('state').navigation().spaces([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.name() + '
  • ');\n this.require('state').navigation().spaces().push('designer-space-' + item.uuid());\n }.bind(this));\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n // focus\n if (length > 0) {\n if ($('#designer-space-' + this.require('state').space()).length) {\n $('#designer-space-' + this.require('state').space()).addClass('active');\n } else {\n item = domItems.children[0];\n $(item).addClass('active');\n this.require('state').space(this.items(0).uuid());\n }\n } else {\n this.require('state').space('');\n }\n break;\n \n case 'models':\n // items \n for (name in system.models()) {\n spaceItem = new SpaceItem({\n 'name': system.models()[name]._name,\n 'uuid': name\n });\n items.push(spaceItem);\n }\n \n this.items(items);\n\n // sort\n this.items().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n\n this.require('state').navigation().spaces([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.name() + '
  • ');\n this.require('state').navigation().spaces().push('designer-space-' + item.uuid());\n }.bind(this));\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n // focus\n if (length > 0) {\n if ($('#designer-space-' + this.require('state').space()).length) {\n $('#designer-space-' + this.require('state').space()).addClass('active');\n } else {\n item = domItems.children[0];\n $(item).addClass('active');\n this.require('state').space(this.items(0).uuid());\n }\n } else {\n this.require('state').space('');\n }\n break;\n case 'types':\n // items\n for (name in system.types()) {\n spaceItem = new SpaceItem({\n 'name': name\n });\n items.push(spaceItem);\n }\n \n this.items(items);\n\n // sort\n this.items().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n\n this.require('state').navigation().spaces([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.name() + '
  • ');\n this.require('state').navigation().spaces().push('designer-space-' + item.name());\n }.bind(this));\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n // focus\n if (length > 0) {\n if ($('#designer-space-' + this.require('state').space()).length) {\n $('#designer-space-' + this.require('state').space()).addClass('active');\n } else {\n item = domItems.children[0];\n $(item).addClass('active');\n this.require('state').space(this.items(0).name());\n }\n }\n break;\n case 'behaviors':\n // items\n for (name in system.models()) {\n spaceItem = new SpaceItem({\n 'name': system.models()[name]._name,\n 'uuid': name\n });\n items.push(spaceItem);\n }\n \n this.items(items);\n\n // sort\n this.items().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n\n //this.items().reverse();\n\n this.require('state').navigation().spaces([]);\n this.items().forEach(function (item) {\n modelsName.push(item.name());\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.name() + '
  • ');\n this.require('state').navigation().spaces().push('designer-space-' + item.name());\n }.bind(this));\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n\n // systems\n systemItems = []\n\n if (this.require('storage').get('system-designer-systems') && this.require('storage').get('system-designer-systems').systems.length) {\n spaceItem = new SpaceItem({\n 'name': this.require('factory').system().name(),\n 'uuid': this.require('factory').system().id()\n });\n systemItems.push(spaceItem);\n }\n \n this.systems(systemItems);\n\n this.systems().forEach(function (item) {\n systemdomItems.insertAdjacentHTML('beforeend', '
  • ' + item.name() + '
  • ');\n this.require('state').navigation().spaces().unshift('designer-space-' + item.name());\n }.bind(this));\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = systemdomItems.children.length;\n for (i = 0; i < length; i++) {\n item = systemdomItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.systems(i)));\n }\n\n space = this.require('state').space();\n if (modelsName.indexOf(space) !== -1) {\n showComponents = true;\n modelName = space;\n } else {\n modelName = _findModel(space, this.require('factory').system().components());\n if (modelName) {\n showComponents = true;\n }\n }\n\n if (showComponents) {\n\n // components\n components = [];\n\n // components\n for (id in system.components()[modelName]) {\n spaceItem = new SpaceItem({\n 'name': id,\n 'uuid': id\n });\n components.push(spaceItem);\n }\n\n this.components(components);\n\n // sort\n this.components().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n\n //this.components().reverse();\n\n this.components().forEach(function (item) {\n modelsName.push(item.name());\n componentdomItems.insertAdjacentHTML('beforeend', '
  • ' + item.name() + '
  • ');\n this.require('state').navigation().spaces().push('designer-space-' + item.name());\n }.bind(this));\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = componentdomItems.children.length;\n for (i = 0; i < length; i++) {\n item = componentdomItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.components(i)));\n }\n }\n\n // focus\n if (this.items().length > 0) {\n if ($('#designer-space-' + this.require('state').space().replace(/\\./g, '-')).length) {\n $('#designer-space-' + this.require('state').space().replace(/\\./g, '-')).addClass('active');\n } else {\n item = systemdomItems.children[0];\n $(item).addClass('active');\n this.require('state').space(this.systems(0).name());\n }\n } else {\n item = systemdomItems.children[0];\n $(item).addClass('active');\n this.require('state').space(this.systems(0).name());\n }\n\n break;\n \n case 'components':\n // items\n for (name in system.models()) {\n spaceItem = new SpaceItem({\n 'name': system.models()[name]._name,\n 'uuid': name\n });\n items.push(spaceItem);\n }\n this.items(items);\n\n // sort\n this.items().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n\n this.require('state').navigation().spaces([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.name() + '
  • ');\n this.require('state').navigation().spaces().push('designer-space-' + item.name());\n }.bind(this));\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n // focus\n if (length > 0) {\n if ($('#designer-space-' + this.require('state').space()).length) {\n $('#designer-space-' + this.require('state').space()).addClass('active');\n } else {\n item = domItems.children[0];\n $(item).addClass('active');\n this.require('state').space(this.items(0).name());\n }\n }\n\n break;\n case 'logs':\n this.require('state').navigation().spaces([]);\n\n domItems.insertAdjacentHTML('beforeend', '
  • All logs
  • ');\n this.require('state').navigation().spaces().push('designer-space-all');\n domItems.insertAdjacentHTML('beforeend', '
  • Error logs
  • ');\n this.require('state').navigation().spaces().push('designer-space-error');\n domItems.insertAdjacentHTML('beforeend', '
  • Warning logs
  • ');\n this.require('state').navigation().spaces().push('designer-space-warn');\n domItems.insertAdjacentHTML('beforeend', '
  • Info logs
  • ');\n this.require('state').navigation().spaces().push('designer-space-info');\n domItems.insertAdjacentHTML('beforeend', '
  • Debug logs
  • ');\n this.require('state').navigation().spaces().push('designer-space-debug');\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n }\n // focus\n if (length > 0) {\n if ($('#designer-space-' + this.require('state').space()).length) {\n $('#designer-space-' + this.require('state').space()).addClass('active');\n } else {\n item = domItems.children[0];\n $(item).addClass('active');\n this.require('state').space('all');\n }\n }\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"d1cb2d156c513e03":{"_id":"d1cb2d156c513e03","component":"Workspace","state":"init","action":"function init(conf) { \n var that = this;\n\n $('html')\n .on('dragenter dragover', false)\n .on('drop', function (e) {\n e.stopPropagation();\n e.preventDefault();\n var files = e.originalEvent.dataTransfer.files;\n var reader = new FileReader();\n var json = '';\n reader.onload = function (event) {\n json += event.target.result;\n };\n reader.onloadend = function () {\n var sys = JSON.parse(json);\n var DialogDropFile = that.require('DialogDropFile');\n \n if (!that.require('factory').system()) {\n DialogDropFile = new DialogDropFile({\n 'title': 'A system has been found',\n 'message': 'You can import the system.'\n });\n } else {\n DialogDropFile = new DialogDropFile({\n 'title': 'A system has been found',\n 'message': 'You can import the system or compose it with the current system.'\n });\n }\n\n DialogDropFile.data(sys);\n DialogDropFile.show();\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n });\n}","useCoreAPI":false,"core":false},"v1090710e8e1d9f9":{"_id":"v1090710e8e1d9f9","component":"Workspace","state":"create","action":"function create() {\n var id = '',\n Dialog = null,\n dialog = null,\n factory = this.require('factory'),\n system = this.require('factory').system();\n\n switch (this.require('state').menu()) {\n case 'systems':\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n break;\n case 'schemas':\n if (system && Object.keys(system).length) {\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n }\n break;\n case 'models':\n if (system && Object.keys(system).length) {\n Dialog = this.require('DialogModelCreation');\n dialog = new Dialog({\n 'title': 'Create a new model',\n });\n dialog.show();\n }\n break;\n case 'types':\n if (system && Object.keys(system).length) {\n Dialog = this.require('DialogTypeCreation');\n dialog = new Dialog({\n 'title': 'Create a new type',\n });\n dialog.show();\n }\n break;\n case 'components':\n if (system && Object.keys(system).length) {\n var models = this.require('factory').system().models(),\n component = {},\n ModelComponent = null,\n modelComponent = null,\n modelName = '';\n\n modelName = this.require('state').space();\n\n if (typeof models[modelName] === 'undefined') {\n \n this.require('message-help').remove();\n\n component = this.require('factory').addComponent(modelName);\n\n ModelComponent = this.require('ModelComponent');\n\n modelComponent = new ModelComponent({\n title: component._id\n });\n modelComponent.model(modelName);\n modelComponent.uuid(component._id);\n modelComponent.document(JSON.parse(JSON.stringify(component)));\n modelComponent.content(JSON.stringify(component));\n\n modelComponent.render();\n\n // little effect\n $('#designer-component-' + component._id).hide();\n $('#designer-component-' + component._id).fadeIn(1000);\n\n this.require('designer').save();\n\n this.require('channel').$designerCreateComponent(modelName, component);\n this.require('message').success('Component created.');\n } else {\n this.require('message').warning('There is no schema. Create a schema before creating a component.');\n }\n }\n break;\n case 'behaviors':\n if (system && Object.keys(system).length) {\n Dialog = this.require('DialogBehaviorCreation');\n dialog = new Dialog({\n 'title': 'Create a new behavior',\n });\n dialog.show();\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"f134d11639b1c4fe":{"_id":"f134d11639b1c4fe","component":"Workspace","state":"clear","action":"function clear() { \n $('#designer-workspace').empty();\n jsPlumb.ready(function () {\n jsPlumb.deleteEveryEndpoint();\n });\n}","useCoreAPI":false,"core":false},"i131bd1870a18e7a":{"_id":"i131bd1870a18e7a","component":"e89c617b6b15d28","state":"start","action":"function start() { \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"l1b9611fc10168ec":{"_id":"l1b9611fc10168ec","component":"State","state":"logs","action":"function logs(value, type) { \n var html = '';\n var filter = this.require('state').space();\n var logNumber = 0;\n \n if (type === 'add') {\n if (this.require('state').menu() === 'logs') {\n switch (value.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n html = '

    ' + value.log() + '

    ';\n } \n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n html = '

    ' + value.log() + '

    ';\n } \n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n html = '

    ' + value.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n html = '

    ' + value.log() + '

    ';\n }\n break;\n default:\n break;\n }\n \n document.querySelector('#designer-loug-output').insertAdjacentHTML('beforeend',\n html\n );\n } else {\n // increment log number\n logNumber = parseInt(document.querySelector('#designer-menu-item-logs-number').innerHTML, 10);\n document.querySelector('#designer-menu-item-logs-number').innerHTML = logNumber + 1;\n if (logNumber === 0) {\n $('#designer-menu-item-logs-number').show();\n }\n }\n }\n}","useCoreAPI":false,"core":false},"p1d00311ad51ef9a":{"_id":"p1d00311ad51ef9a","component":"Designer","state":"welcome","action":"function welcome() { \n var Dialog = null,\n dialog = null,\n config = null;\n\n config = this.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n\n if (typeof config.welcomeScreen === 'undefined') {\n Dialog = this.require('DialogWelcome');\n dialog = new Dialog({\n 'title': 'Welcome to System Designer'\n });\n dialog.show();\n dialog.on('ok', function ok() {\n var config = this.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n config.welcomeScreen = false;\n this.require('storage').set('system-designer-config', config);\n this.hide();\n });\n }\n}","useCoreAPI":false,"core":false},"o12c7d1448a1dc16":{"_id":"o12c7d1448a1dc16","component":"Designer","state":"render","action":"function render() {\n var System = null,\n systemId = '';\n\n // message\n this.require('logger').on('warn', function warn(message) {\n this.require('message').warning(message);\n });\n this.require('logger').on('error', function error(message) {\n this.require('message').danger(message);\n });\n \n // extensions\n this.installExtensions();\n\n // system\n System = this.require('System');\n var systems = this.require('storage').get('system-designer-systems');\n\n // case of url\n switch (true) {\n case window.location.href.split('#').length > 1 && window.location.href.split('#')[1].length > 0:\n systemId = window.location.href.split('#')[1];\n if (this.require('storage').get(systemId)) {\n this.require('factory').create(this.require('storage').get(systemId));\n }\n break;\n default:\n if (systems && systems.systems && systems.systems.length && systems.systems[0].length) {\n systems.systems.sort(function (sysA, sysB) {\n var a = this.require('storage').get(sysA),\n b = this.require('storage').get(sysB),\n result = 0;\n\n if (a.name > b.name) {\n result = 1;\n }\n if (a.name < b.name) {\n result = -1;\n }\n return result;\n }.bind(this));\n\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n break;\n }\n \n this.welcome();\n\n this.require('router').start();\n \n // resize event\n $(window).resize(function () {\n jsPlumb.repaintEverything();\n });\n\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('spaces').render();\n \n this.addShorcuts();\n \n // run messages if any\n this.runMessages(this.require('state').messages());\n this.require('state').messages([]);\n}","useCoreAPI":false,"core":false},"x196fc166ef17a85":{"_id":"x196fc166ef17a85","component":"Designer","state":"linkModel","action":"function linkModel(source, target) { \n jsPlumb.ready(function () {\n jsPlumb.setContainer('body');\n\n jsPlumb.connect({\n paintStyle: {\n stroke: '#7F949D',\n strokeWidth: 3\n },\n source: 'designer-model-panel-' + source,\n target: 'designer-model-panel-' + target,\n overlays: [\n ['Arrow', {\n location: 1\n }]\n ]\n }, {\n connector: ['Flowchart'],\n anchor: ['Left', 'Right'],\n endpoint: 'Blank'\n });\n });\n}","useCoreAPI":false,"core":false},"k13951153851cc3a":{"_id":"k13951153851cc3a","component":"Designer","state":"save","action":"function save() { \n var systems = this.require('storage').get('system-designer-systems'),\n system = this.require('factory').toJSON(),\n systemId = system._id;\n\n // save system\n this.require('storage').set(systemId, system);\n\n // save index\n if (!systems) {\n systems = { 'systems': [systemId] };\n } else {\n if (systems.systems.indexOf(systemId) === -1) {\n systems.systems.push(systemId);\n }\n }\n this.require('storage').set('system-designer-systems', systems);\n}","useCoreAPI":false,"core":false},"u1cf0e155fb1e53f":{"_id":"u1cf0e155fb1e53f","component":"Workspace","state":"render","action":"function render() { \n var ModelSystem = null,\n ModelSchema = null,\n ModelClass = null,\n modelSchema = null,\n ModelLog = null,\n sys = null,\n name = '',\n id = '',\n schemaId = '',\n modelclass = null,\n modellog = null,\n ModelType = null,\n type = null,\n ModelComponent = null,\n component = null,\n ModelBehavior = null,\n behavior = null,\n system = this.require('factory').system(),\n space = this.require('state').space(),\n menu = this.require('state').menu(),\n parentId = '',\n parentsId = [],\n parents = null,\n systems = null,\n systemIds = [],\n i = 0,\n length = 0,\n title = 0,\n nbElement = 0;\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas()) {\n if (system.schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models()) {\n if (system.models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (system) {\n this.clear();\n\n window.scrollTo(0, 0);\n\n title = 'system ' + system.name();\n if (title !== document.title) {\n document.title = title;\n }\n\n switch (this.require('state').menu()) {\n case 'systems':\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n if (system.name === space) {\n ModelSystem = this.require('ModelSystem');\n sys = new ModelSystem({\n 'title': system.name\n });\n sys.uuid(system._id);\n sys.document(JSON.parse(JSON.stringify(system)));\n sys.content(JSON.stringify(system));\n sys.render();\n }\n }\n\n if (space === '' && length > 0) {\n this.require('message').warning('System not found.');\n }\n\n break;\n case 'schemas':\n if (space) {\n for (id in system.schemas()) {\n if (system.schemas()[id]._id === space) {\n ModelSchema = this.require('ModelSchema');\n\n // create parent if any\n parentsId = [];\n if (system.schemas()[id]._inherit) {\n parents = system.schemas()[id]._inherit.slice();\n parents.reverse();\n }\n length = 0;\n if (parents) {\n length = parents.length;\n }\n\n for (i = 0; i < length; i++) {\n parentId = _getSchemaId(parents[i]);\n\n modelSchema = new ModelSchema({\n 'title': parents[i]\n });\n \n if (parents[i] !== system.schemas()[id]._name) {\n if (parents[i] === '_Component') {\n parentId = \"111df11e2b19fde\";\n \n var schemaRuntime = {\n \"_id\": \"_Component\",\n \"_name\": \"_Component\",\n \"_core\": true,\n \"id\": \"property\",\n \"classInfo\": \"method\",\n \"init\": \"method\",\n \"destroy\": \"method\",\n \"on\": \"method\",\n \"off\": \"method\",\n \"require\": \"method\",\n \"error\": \"event\"\n };\n \n modelSchema.document(schemaRuntime);\n modelSchema.content(JSON.stringify(schemaRuntime));\n parentsId.push(parentId);\n modelSchema.uuid(parentId);\n } else {\n if (system.schemas()[_getSchemaId(parents[i])]) {\n modelSchema.document(JSON.parse(JSON.stringify(system.schemas()[_getSchemaId(parents[i])])));\n modelSchema.content(JSON.stringify(system.schemas()[_getSchemaId(parents[i])]));\n parentsId.push(_getSchemaId(parents[i]));\n modelSchema.uuid(_getSchemaId(parents[i]));\n } else {\n parentsId.push(parents[i]);\n modelSchema.uuid(parents[i]);\n }\n }\n modelSchema.render();\n }\n }\n\n modelSchema = new ModelSchema({\n 'title': system.schemas()[id]._name\n });\n modelSchema.uuid(id);\n modelSchema.document(JSON.parse(JSON.stringify(system.schemas()[id])));\n modelSchema.content(JSON.stringify(system.schemas()[id]));\n modelSchema.editable(true);\n modelSchema.render();\n\n length = parentsId.length;\n for (i = 0; i < length; i++) {\n this.require('designer').linkModel(id, parentsId[i]);\n }\n }\n }\n if (Object.keys(system.schemas()).length === 0) {\n this.require('message-help').render();\n }\n } else {\n if (Object.keys(system.schemas()).length === 0) {\n this.require('message-help').render();\n }\n }\n break;\n case 'models':\n if (space) {\n for (id in system.models()) {\n if (system.models()[id]._id === space) {\n ModelClass = this.require('ModelClass');\n\n // create parent if any\n // parents are search from the schema\n schemaId = _getSchemaId(system.models()[id]._name);\n parentsId = [];\n if (schemaId && system.schemas()[schemaId]._inherit) {\n parents = system.schemas()[schemaId]._inherit.slice();\n parents.reverse();\n }\n length = 0;\n if (parents) {\n length = parents.length;\n }\n\n for (i = 0; i < length; i++) {\n\n parentId = _getSchemaId(parents[i]);\n\n modelclass = new ModelClass({\n 'title': parents[i]\n });\n\n if (parents[i] === '_Component') {\n parentId = '123751cb591de26';\n\n var modelRuntime = {\n \"_name\": \"_Component\",\n \"_core\": true,\n \"id\": {\n \"description\": \"get the unique ID of a component\",\n \"type\": \"string\",\n \"readOnly\": true,\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"classInfo\": {\n \"description\": \"get the model of the component\",\n \"result\": \"_ClassInfo\"\n },\n \"init\": {\n \"description\": \"action to do when the component is created\",\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n },\n \"destroy\": {\n \"description\": \"action to do when the component is destroyed\",\n \"params\": []\n },\n \"on\": {\n \"description\": \"add a behavior to a component\",\n \"params\": [{\n \"name\": \"state\",\n \"type\": \"string\"\n },\n {\n \"name\": \"action\",\n \"type\": \"function\"\n },\n {\n \"name\": \"useCoreAPI\",\n \"type\": \"boolean\",\n \"mandatory\": false\n },\n {\n \"name\": \"isCore\",\n \"type\": \"boolean\",\n \"mandatory\": false\n }\n ],\n \"result\": \"string\"\n },\n \"off\": {\n \"description\": \"remove a behavior from a component\",\n \"params\": [{\n \"name\": \"state\",\n \"type\": \"string\"\n },\n {\n \"name\": \"behaviorId\",\n \"type\": \"string\",\n \"mandatory\": false\n }]\n },\n \"require\": {\n \"description\": \"require a component\",\n \"params\": [{\n \"name\": \"id\",\n \"type\": \"string\"\n }],\n \"result\": \"_Component\"\n },\n \"error\": {\n \"description\": \"action to do when an error happened\",\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n }\n };\n\n modelclass.document(modelRuntime);\n modelclass.content(JSON.stringify(modelRuntime));\n parentsId.push(parentId);\n modelclass.uuid(parentId);\n } else {\n if (system.models()[_getModelId(parents[i])]) {\n modelclass.document(JSON.parse(JSON.stringify(system.models()[_getModelId(parents[i])])));\n modelclass.content(JSON.stringify(system.models()[_getModelId(parents[i])]));\n parentsId.push(_getModelId(parents[i]));\n modelclass.uuid(_getModelId(parents[i]));\n } else {\n parentsId.push(parents[i]);\n modelclass.uuid(parentId);\n }\n }\n modelclass.render();\n }\n\n modelclass = new ModelClass({\n 'title': system.models()[id]._name\n });\n modelclass.uuid(id);\n modelclass.document(JSON.parse(JSON.stringify(system.models()[id])));\n modelclass.content(JSON.stringify(system.models()[id]));\n modelclass.editable(true);\n modelclass.render();\n\n length = parentsId.length;\n for (i = 0; i < length; i++) {\n this.require('designer').linkModel(id, parentsId[i]);\n }\n }\n }\n } else {\n if (Object.keys(system.schemas()).length === 0) {\n this.require('message-help').render();\n }\n }\n break;\n case 'types':\n if (space) {\n for (name in system.types())\n if (system.types()[name].name === space) {\n ModelType = this.require('ModelType');\n type = new ModelType({\n 'title': name\n });\n type.uuid(name);\n type.document(JSON.parse(JSON.stringify(system.types()[space])));\n type.content(JSON.stringify(system.types()[space]));\n type.render();\n }\n if (Object.keys(system.types()).length === 0) {\n this.require('message-help').render();\n }\n } else {\n if (Object.keys(system.types()).length === 0) {\n this.require('message-help').render();\n }\n }\n break;\n case 'components':\n var nbComponents = 0;\n if (space) {\n if (this.require('state').component()) {\n name = this.require('state').component();\n if (system.components()[space][name]) {\n ModelComponent = this.require('ModelComponent');\n component = new ModelComponent({\n 'title': name\n });\n component.uuid(name);\n component.model(space);\n component.document(JSON.parse(JSON.stringify(system.components()[space][name])));\n component.content(JSON.stringify(system.components()[space][name]));\n component.render();\n } else {\n this.require('message-help').render();\n }\n } else {\n for (name in system.components()[space]) {\n ModelComponent = this.require('ModelComponent');\n component = new ModelComponent({\n 'title': name\n });\n component.uuid(name);\n component.model(space);\n component.document(JSON.parse(JSON.stringify(system.components()[space][name])));\n component.content(JSON.stringify(system.components()[space][name]));\n component.render();\n nbComponents = nbComponents + 1;\n \n if (nbComponents === 50) {\n this.require('message').warning('For performance reason you will only see the first 50 components.');\n break;\n }\n }\n \n if (system.components()) {\n if (system.components()[space]) {\n if (Object.keys(system.components()[space]).length === 0) {\n this.require('message-help').render();\n }\n } else {\n this.require('message-help').render();\n }\n } else {\n this.require('message-help').render();\n }\n }\n } else {\n if (Object.keys(system.components()).length === 0) {\n this.require('message-help').render();\n }\n }\n break;\n case 'behaviors':\n if (space) {\n name = this.require('state').component();\n var behaviorDef = {};\n var behaviorsId = Object.keys(system.behaviors());\n var systemName = this.require('factory').system().name();\n var systemId = this.require('factory').system().id();\n ModelBehavior = this.require('ModelBehavior');\n \n behaviorsId.forEach(function(id) {\n behaviorDef = system.behaviors()[id];\n if (behaviorDef.component === space) {\n if ((name && behaviorDef.state === name) || name === '') {\n behavior = new ModelBehavior({\n 'uuid': system.behaviors()[id]._id\n });\n behavior.title(behaviorDef.state);\n behavior.document(behaviorDef);\n behavior.content(JSON.parse(JSON.stringify(behaviorDef.action)));\n behavior.render();\n \n nbElement = nbElement + 1;\n }\n }\n\n // system\n if (space === systemName) {\n if (behaviorDef.component === systemId) {\n behavior = new ModelBehavior({\n 'uuid': behaviorDef._id\n });\n behavior.title(behaviorDef.state);\n behavior.document(behaviorDef);\n behavior.content(JSON.parse(JSON.stringify(behaviorDef.action)));\n behavior.render();\n \n nbElement = nbElement + 1;\n }\n }\n }.bind(this));\n \n if (nbElement === 0) {\n this.require('message-help').render();\n } else {\n Prism.highlightAll();\n }\n } else {\n if (Object.keys(system.behaviors()).length === 0) {\n this.require('message-help').render();\n }\n }\n break;\n case 'logs':\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n $('#designer-menu-item-logs-number').hide();\n \n ModelLog = this.require('ModelLog');\n\n modelLog = new ModelLog();\n modelLog.render();\n\n break;\n default:\n break;\n }\n } else {\n\n document.title = 'System Designer';\n \n this.require('message-help').render();\n\n systems = this.require('storage').get('system-designer-systems');\n if (systems && systems.systems && systems.systems.length) {\n this.require('message').warning('System not found.');\n }\n }\n}","useCoreAPI":false,"core":false},"s1876e1b64c1251e":{"_id":"s1876e1b64c1251e","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n collection = '',\n href = '',\n context = '',\n space = '',\n schemaName = '',\n schemaId = '',\n modelName = '',\n modelId = '';\n \n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelName(id, models) {\n var result = '',\n modelId = '';\n\n for (modelId in models) {\n if (modelId === id) {\n result = models[id]._name;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaName(id, schemas) {\n var result = '',\n schemaId = '';\n\n for (schemaId in schemas) {\n if (schemaId === id) {\n result = schemas[id]._name;\n break;\n }\n }\n return result;\n }\n\n function _getCollection(href) {\n var result = '';\n\n if (href.split('#').length === 2) {\n result = href.split('#')[1];\n }\n if (href.split('#').length > 2) {\n result = href.split('#')[2];\n }\n\n result = result.split('#')[0];\n result = result.trim();\n\n return result;\n }\n\n context = this.require('state').menu();\n space = this.require('state').space();\n\n switch (context) {\n case 'schemas':\n if (this.require('factory').system()) {\n if (space) {\n schemaName = _getSchemaName(space, this.require('factory').system().schemas());\n modelId = _getModelId(schemaName, this.require('factory').system().models());\n }\n\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '#' + this.require('factory').system().id() + '#' + collection;\n\n if (collection === 'models' && modelId) {\n menubar[i].href = menubar[i].href + '#' + modelId;\n }\n if (collection === 'components' && schemaName) {\n menubar[i].href = menubar[i].href + '#' + schemaName;\n }\n if (collection === 'behaviors' && schemaName) {\n menubar[i].href = menubar[i].href + '#' + schemaName;\n }\n }\n } else {\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '##' + collection;\n }\n }\n break;\n case 'models':\n if (this.require('factory').system()) {\n if (space) {\n modelName = _getModelName(space, this.require('factory').system().models());\n schemaId = _getSchemaId(modelName, this.require('factory').system().schemas());\n }\n\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '#' + this.require('factory').system().id() + '#' + collection;\n\n if (collection === 'schemas' && schemaId) {\n menubar[i].href = menubar[i].href + '#' + schemaId;\n }\n if (collection === 'components' && modelName) {\n menubar[i].href = menubar[i].href + '#' + modelName;\n }\n if (collection === 'behaviors' && modelName) {\n menubar[i].href = menubar[i].href + '#' + modelName;\n }\n }\n } else {\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '##' + collection;\n }\n }\n break;\n case 'behaviors':\n if (this.require('factory').system()) {\n if (space) {\n modelId = _getModelId(space, this.require('factory').system().models());\n schemaId = _getSchemaId(space, this.require('factory').system().schemas());\n schemaName = _getSchemaName(schemaId, this.require('factory').system().schemas());\n }\n\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '#' + this.require('factory').system().id() + '#' + collection;\n\n if (collection === 'schemas' && schemaId) {\n menubar[i].href = menubar[i].href + '#' + schemaId;\n }\n if (collection === 'models' && modelId) {\n menubar[i].href = menubar[i].href + '#' + modelId;\n }\n if (collection === 'components' && modelId) {\n menubar[i].href = menubar[i].href + '#' + schemaName;\n }\n }\n } else {\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '##' + collection;\n }\n }\n break;\n case 'components':\n if (this.require('factory').system()) {\n if (space) {\n modelId = _getModelId(space, this.require('factory').system().models());\n schemaId = _getSchemaId(space, this.require('factory').system().schemas());\n schemaName = _getSchemaName(schemaId, this.require('factory').system().schemas());\n }\n\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '#' + this.require('factory').system().id() + '#' + collection;\n\n if (collection === 'schemas' && schemaId) {\n menubar[i].href = menubar[i].href + '#' + schemaId;\n }\n if (collection === 'models' && modelId) {\n menubar[i].href = menubar[i].href + '#' + modelId;\n }\n if (collection === 'behaviors' && modelId) {\n menubar[i].href = menubar[i].href + '#' + schemaName;\n }\n }\n } else {\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '##' + collection;\n }\n }\n break;\n default:\n if (this.require('factory').system()) {\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '#' + this.require('factory').system().id() + '#' + collection;\n }\n } else {\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '##' + collection;\n }\n }\n break;\n }\n}","useCoreAPI":false,"core":false},"a1e92e1b7d6162ab":{"_id":"a1e92e1b7d6162ab","component":"Router","state":"start","action":"function start() { \n var that = this;\n \n window.onhashchange = function (e) {\n var arr = window.location.href.split('#'),\n system = '',\n collection = 'systems',\n component = '',\n i = 0,\n length = 0,\n item = null,\n domItems = null,\n System = that.require('System'),\n systems = that.require('storage').get('system-designer-systems');\n\n if (arr.length > 1) {\n system = arr[1];\n system = system.split('?')[0];\n }\n\n if (arr.length > 2) {\n collection = arr[2];\n collection = collection.split('?')[0];\n }\n\n if (arr.length > 3) {\n component = arr[3];\n component = component.split('?')[0];\n }\n\n if (arr.length > 4) {\n that.require('state').component(arr[4].split('?')[0]);\n } else {\n that.require('state').component('');\n }\n \n if (arr.length > 1 && system) {\n that.require('factory').create(that.require('storage').get(system));\n } else {\n if (systems && systems.systems && systems.systems.length) {\n that.require('factory').create(that.require('storage').get(systems.systems[0]));\n }\n }\n \n that.require('state').space(decodeURIComponent(component));\n that.require('state').menu(decodeURIComponent(collection));\n\n // focus\n domItems = document.getElementById('designer-menubar-items');\n length = that.require('menubar').items().length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n for (i = 0; i < length; i++) {\n if (that.require('menubar').items(i).name() === collection) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n\n that.update();\n };\t\n}","useCoreAPI":false,"core":false},"v10ccc18f431a78e":{"_id":"v10ccc18f431a78e","component":"State","state":"menu","action":"function menu(value) { \n jsPlumb.ready(function () {\n jsPlumb.deleteEveryEndpoint();\n });\n\n this.require('spaces').render();\n this.require('workspace').clear();\n this.require('workspace').render();\n}","useCoreAPI":false,"core":false},"n17df1112301e0cf":{"_id":"n17df1112301e0cf","component":"State","state":"space","action":"function space(value) { \n if (this.menu() === 'systems') {\n this.require('router').update();\n }\n}","useCoreAPI":false,"core":false},"j1fc1a152e61a7b9":{"_id":"j1fc1a152e61a7b9","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config');\n // message for other windows\n this.require('storage').set('system-designer-message', message);\n\n // message for client debug\n if (this.require('designer').debugWindow()) {\n this.require('designer').debugWindow().postMessage(JSON.stringify(message), '*');\n }\n\n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\t\n}","useCoreAPI":false,"core":false},"s11b84108ec12d82":{"_id":"s11b84108ec12d82","component":"_Channel","state":"$appLogDebug","action":"function $appLogDebug(message) { \n var log = '',\n Log = null;\n\n Log = this.require('Log');\n log = new Log({\n 'type': 'debug',\n 'log': message.replace('runtime:', '').replace(/\\[[^\\]]+\\]/, 'debug: ')\n });\n\n this.require('state').logs().push(log);\n this.require('message').info(message.replace(/\\[[^\\]]+\\]/, 'runtime: '));\t\n}","useCoreAPI":false,"core":false},"s1274812bab1ab3d":{"_id":"s1274812bab1ab3d","component":"_Channel","state":"$appLogInfo","action":"function $appLogInfo(message) { \n var log = '',\n Log = null;\n\n Log = this.require('Log');\n log = new Log({\n 'type': 'info',\n 'log': message.replace('runtime:', '').replace(/\\[[^\\]]+\\]/, 'info: ')\n });\n\n this.require('state').logs().push(log);\n this.require('message').info(message.replace(/\\[[^\\]]+\\]/, 'runtime: '));\t\n}","useCoreAPI":false,"core":false},"b1c5cb1ee0b195fc":{"_id":"b1c5cb1ee0b195fc","component":"_Channel","state":"$appLogWarn","action":"function $appLogWarn(message) { \n var log = '',\n Log = null;\n\n Log = this.require('Log');\n log = new Log({\n 'type': 'warn',\n 'log': message.replace('runtime:', '').replace(/\\[[^\\]]+\\]/, 'warning: ')\n });\n\n this.require('state').logs().push(log);\n this.require('message').warning(message.replace(/\\[[^\\]]+\\]/, 'runtime: '));\t\n}","useCoreAPI":false,"core":false},"i1b8de1d60316328":{"_id":"i1b8de1d60316328","component":"_Channel","state":"$appLogError","action":"function $appLogError(message) { \n var log = '',\n Log = null;\n\n Log = this.require('Log');\n log = new Log({\n 'type': 'error',\n 'log': message.replace('runtime:', '').replace(/\\[[^\\]]+\\]/, 'error: ')\n });\n\n this.require('state').logs().push(log);\n this.require('message').danger(message.replace(/\\[[^\\]]+\\]/, 'runtime: '));\t\n}","useCoreAPI":false,"core":false},"h1ad061990d1bcc5":{"_id":"h1ad061990d1bcc5","component":"_Channel","state":"$editorUpdateType","action":"function $editorUpdateType(id, type) { \n this.require('factory').updateType(id, type);\n\n this.require('designer').save();\n\n this.require('state').space(type.name);\n \n this.require('spaces').render();\n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"h1275e1a9791051a":{"_id":"h1275e1a9791051a","component":"_Channel","state":"$editorDeleteType","action":"function $editorDeleteType(id) { \n var dbTypes = [],\n type = null;\n\n dbTypes = this.require('db').collections().ModelType.find({\n 'uuid': id\n });\n if (dbTypes.length) {\n type = this.require(dbTypes[0]._id);\n if (type) {\n type.hide();\n type.destroy();\n }\n }\n\n this.require('factory').deleteType(id);\n\n this.require('designer').save();\n \n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"u1b3231dd52189ee":{"_id":"u1b3231dd52189ee","component":"_Channel","state":"$editorUpdateSchemaName","action":"function $editorUpdateSchemaName(name, id) { \n this.require('factory').updateSchemaName(name, id);\n \n this.require('designer').save();\t\n}","useCoreAPI":false,"core":false},"w17e86178ff1ac10":{"_id":"w17e86178ff1ac10","component":"_Channel","state":"$editorUpdateSchema","action":"function $editorUpdateSchema(id, schema) { \n var schemas = this.require('factory').system().schemas(),\n models = null,\n model = null,\n modelId = '';\n\n jsPlumb.deleteEveryEndpoint();\n\n this.require('factory').syncModel(schema);\n \n this.require('designer').save();\n \n this.require('factory').updateSchema(id, schema);\n \n this.require('designer').save();\n\n // sync other components\n models = this.require('factory').system().models();\n for (modelId in models) {\n if (models[modelId]._name !== schema._name) {\n model = models[modelId];\n this.require('factory').syncComponent(model, true);\n }\n }\n \n this.require('designer').save();\n\n this.require('state').space(id);\n \n this.require('spaces').render();\n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"f14bae11650167a7":{"_id":"f14bae11650167a7","component":"_Channel","state":"$editorUpdateSchemaId","action":"function $editorUpdateSchemaId(oldId, newId) { \n this.require('factory').updateSchemaId(oldId, newId);\n\n this.require('designer').save();\n \n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"n1cd861eb1d1d0a5":{"_id":"n1cd861eb1d1d0a5","component":"_Channel","state":"$editorUpdateModel","action":"function $editorUpdateModel(id, model) { \n jsPlumb.deleteEveryEndpoint();\n\n this.require('factory').updateModel(id, model);\n\n this.require('designer').save();\n\n this.require('factory').syncBehavior(model);\n \n this.require('designer').save();\n\n this.require('state').space(id);\n \n this.require('spaces').render();\n this.require('workspace').render();\t\n \n $(function () {\n $('[role=\"tooltip\"]').hide();\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"n1a1a113960107dd":{"_id":"n1a1a113960107dd","component":"_Channel","state":"$editorUpdateModelId","action":"function $editorUpdateModelId(oldId, newId) { \n this.require('factory').updateModelId(oldId, newId);\n\n this.require('designer').save();\n \n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"m1219c18bd215028":{"_id":"m1219c18bd215028","component":"_Channel","state":"$designerUpdateBehavior","action":"function $designerUpdateBehavior(id, behavior) { \n this.require('factory').udpdateBehavior(id, behavior);\n\n this.require('designer').save();\n \n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"g1271811dd61f96f":{"_id":"g1271811dd61f96f","component":"_Channel","state":"$editorDeleteBehavior","action":"function $editorDeleteBehavior(id) { \n var dbBehaviors = [],\n behavior = null;\n\n dbBehaviors = this.require('db').collections().ModelBehavior.find({\n 'uuid': id\n });\n if (dbBehaviors.length) {\n behavior = this.require(dbBehaviors[0]._id);\n if (behavior) {\n behavior.hide();\n behavior.destroy();\n }\n }\n\n this.require('factory').deleteBehavior(id);\n\n this.require('designer').save();\n \n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"m1433e1b8e71050a":{"_id":"m1433e1b8e71050a","component":"_Channel","state":"$editorUpdateComponent","action":"function $editorUpdateComponent(id, collection, component) { \n this.require('factory').overwriteComponent(id, collection, component);\n\n this.require('designer').save();\n\n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"e1acfa1989b122ec":{"_id":"e1acfa1989b122ec","component":"_Channel","state":"$editorDeleteComponent","action":"function $editorDeleteComponent(id, collection) { \n var models = [],\n model = null;\n\n models = this.require('db').collections().ModelComponent.find({\n 'uuid': id\n });\n if (models.length) {\n model = this.require(models[0]._id);\n if (model) {\n model.hide();\n model.destroy();\n }\n }\n\n this.require('factory').deleteComponent(id, collection);\n\n this.require('designer').save();\n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"x11f721f8111c41a":{"_id":"x11f721f8111c41a","component":"_Channel","state":"$editorUpdateSystem","action":"function $editorUpdateSystem(id, system) { \n this.require('factory').updateSystem(id, system);\n \n this.require('designer').save();\n\n this.require('state').space(system.name);\n \n this.require('spaces').render();\n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"d180f31873a19ef7":{"_id":"d180f31873a19ef7","component":"_Channel","state":"$appLoadSystem","action":"function $appLoadSystem(system) { \n var Dialog = null,\n dialog = null,\n message = this.require('message');\n\n if (system.name) {\n if (system.name !== 'designer-runtime') {\n Dialog = this.require('DialogImport');\n dialog = new Dialog({\n 'title': 'A system has been found',\n 'message': 'Do you want to import the system ?',\n 'data': system\n });\n dialog.show();\n \n dialog.on('ok', function () {\n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n \n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n \n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n designer.save();\n \n this.require('state').space(sys.name());\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n designer.save();\n \n message.success('Importation of the system is done.');\n });\n }\n } else {\n message.warning('There is no system to import.');\n }\n}","useCoreAPI":false,"core":false},"r1318213d401b598":{"_id":"r1318213d401b598","component":"_Channel","state":"$runtimeCreateComponent","action":"function $runtimeCreateComponent(collection, component) { \n this.require('factory').createComponent(collection, component);\n\n this.require('designer').save();\n\n if (this.require('state').menu() === 'components') {\n this.require('workspace').render();\n }\t\n}","useCoreAPI":false,"core":false},"a125ea107d41f237":{"_id":"a125ea107d41f237","component":"_Channel","state":"$runtimeDeleteComponent","action":"function $runtimeDeleteComponent(id, collection) { \n this.require('factory').deleteComponent(id, collection);\n\n this.require('designer').save();\n\n if (this.require('state').menu() === 'components') {\n this.require('workspace').render();\n }\n}","useCoreAPI":false,"core":false},"n1636d1853518a09":{"_id":"n1636d1853518a09","component":"_Channel","state":"$runtimeUpdateComponent","action":"function $runtimeUpdateComponent(id, collection, field, value) { \n this.require('factory').updateComponent(id, collection, field, value);\n \n this.require('designer').save();\n \n if (this.require('state').menu() === 'components') {\n this.require('workspace').render();\n }\n}","useCoreAPI":false,"core":false},"v165f81ca0d1bd5f":{"_id":"v165f81ca0d1bd5f","component":"_Channel","state":"$designerDeleteSchema","action":"function $designerDeleteSchema(id) { \n var dbSchemas = [],\n schema = null;\n\n dbSchemas = this.require('db').collections().ModelSchema.find({\n 'uuid': id\n });\n if (dbSchemas.length) {\n schema = this.require(dbSchemas[0]._id);\n if (schema) {\n schema.hide();\n schema.destroy();\n }\n }\n\n this.require('factory').deleteSchema(id, false);\n \n this.require('designer').save();\n \n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"u1a9411d65313eb8":{"_id":"u1a9411d65313eb8","component":"_Channel","state":"$editorUpdateBehavior","action":"function $editorUpdateBehavior(id, behavior) { \n this.require('factory').updateBehavior(id, behavior);\n\n this.require('designer').save();\n \n this.require('workspace').render();\n}","useCoreAPI":false,"core":false},"s192131208d1553f":{"_id":"s192131208d1553f","component":"_Channel","state":"init","action":"function init(conf) { \n window.addEventListener('message', function message(event) {\n var data = null,\n config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n data = JSON.parse(event.data);\n if (data &&\n typeof data.event !== 'undefined' &&\n typeof data.from !== 'undefined' &&\n typeof data.data !== 'undefined') {\n $db._Message.insert(data);\n }\n }.bind(this), false);\n\n this.require('_Storage').on('changed', function changed(obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n if (this.require('designer').debugWindow()) {\n this.require('designer').debugWindow().postMessage(JSON.stringify(obj['system-designer-message'].newValue), '*');\n }\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":true,"core":false},"i1fa311dc26116f8":{"_id":"i1fa311dc26116f8","component":"y187401decb196c4","state":"click","action":"function click() {\n $('#designer-toolbar-item-export').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var message = this.require('message');\n var Dialog = this.require('DialogExport');\n\n if (this.require('factory').system()) {\n var dialog = new Dialog({\n 'title': 'Export the current system',\n });\n dialog.show();\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"f1ae6e164301b982":{"_id":"f1ae6e164301b982","component":"x1371910b7812e58","state":"click","action":"function click() {\n var debugWindow = this.require('designer').debugWindow(),\n config = this.require('storage').get('system-designer-config'),\n message = this.require('message');\n\n $('#designer-toolbar-item-refresh').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (config) {\n if (typeof config.debugType !== 'undefined' && config.debugType === 'client') {\n if (config.urlClient) {\n if (debugWindow && !debugWindow.closed) {\n message.success('Searching for a system...');\n this.require('channel').$designerSync();\n } else {\n message.success('Opening the page...');\n this.require('designer').debugWindow(this.require('designer').open(config.urlClient, 'debug'));\n }\n } else {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n }\n if (typeof config.debugType !== 'undefined' && config.debugType === 'server') {\n if (config.urlServer) {\n message.success('Searching for a server...');\n var self = this;\n $.getJSON(config.urlServer.replace(':8888', '') + ':8888/$designerSync', function (system) {\n var Dialog = null,\n dialog = null,\n message = runtime.require('message');\n \n if (system && system.name) {\n Dialog = self.require('DialogImport');\n dialog = new Dialog({\n 'title': 'A system has been found',\n 'message': 'Do you wan to import it ?',\n 'data': system\n });\n dialog.show();\n \n dialog.on('ok', function () {\n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n \n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n \n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n designer.save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n designer.save();\n \n message.success('Importation of the system is done.');\n });\n } else {\n message.warning('There is no system to import.');\n }\n });\n } else {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n }\n if (typeof config.debugType === 'undefined') {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n } else {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"q141da1eb5d1916b":{"_id":"q141da1eb5d1916b","component":"g12f9e166c71cf91","state":"click","action":"function click() {\n $('#designer-toolbar-item-extension').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogExtension = this.require('DialogExtension');\n\n DialogExtension = new DialogExtension({\n 'title': 'Manage your extensions'\n });\n DialogExtension.show();\n}","useCoreAPI":false,"core":false},"k1f66b12b5f1b625":{"_id":"k1f66b12b5f1b625","component":"l1f2871e69b1b85e","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"w19413126bf1bf40":{"_id":"w19413126bf1bf40","component":"s1aa5c1170e1eba3","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"y1eaaf1fe0719457":{"_id":"y1eaaf1fe0719457","component":"_Channel","state":"$editorUpdateComponentId","action":"function $editorUpdateComponentId(oldId, newId) { \n this.require('factory').updateComponentId(oldId, newId);\n\n this.require('designer').save();\n \n this.require('workspace').render();\t\t\n}","useCoreAPI":false,"core":false},"w1875419b271fb1c":{"_id":"w1875419b271fb1c","component":"Designer","state":"addShorcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null,\n position = 0;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if (this.require('factory').system()) {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n } else {\n message.warning('There is no system.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + F\n case key === 70 && command:\n if (this.require('factory').system()) {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogSearch');\n dialog = new Dialog({\n 'title': 'Search in the system',\n });\n dialog.show();\n } else {\n message.warning('There is no system.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + '+'\n case (key === 187 || key === 43) && command:\n if (!this.require('factory').system() && this.require('state').menu() !== 'systems') {\n message.warning('There is no system: create first a system to continue.');\n } else {\n if (this.require('factory').system() && Object.keys(this.require('factory').system().schemas()).length === 0 && this.require('state').menu() === 'components') {\n message.warning('There is no schema: create first a schema to continue.');\n } else {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n this.require('workspace').create();\n }\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + I\n case key === 73 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n var DialogImportFile = this.require('DialogImportFile');\n \n DialogImportFile = new DialogImportFile({\n 'title': 'Import a system'\n });\n DialogImportFile.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + E\n case key === 69 && command:\n if (this.require('factory').system()) {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = this.require('DialogExport');\n dialog = new Dialog({\n 'title': 'Export the current system',\n });\n dialog.show();\n } else {\n message.warning('There is no system to export.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + ->\n case key === 39 && command:\n position = this.require('state').navigation().menu().indexOf('designer-menu-item-' + this.require('state').menu());\n if (position !== -1) {\n position = position + 1;\n if (position === this.require('state').navigation().menu().length) {\n position = 0;\n }\n document.getElementById(this.require('state').navigation().menu(position)).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + <-\n case key === 37 && command:\n position = this.require('state').navigation().menu().indexOf('designer-menu-item-' + this.require('state').menu());\n if (position !== -1) {\n position = position - 1;\n if (position === -1) {\n position = this.require('state').navigation().menu().length -1;\n }\n document.getElementById(this.require('state').navigation().menu(position)).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + v\n case key === 40 && command:\n position = this.require('state').navigation().spaces().indexOf('designer-space-' + this.require('state').space());\n if (position !== -1) {\n position = position + 1;\n if (position === this.require('state').navigation().spaces().length) {\n position = 0;\n }\n $('#' + this.require('state').navigation().spaces(position)).children()[0].click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false; \n break;\n // Command + ^\n case key === 38 && command:\n position = this.require('state').navigation().spaces().indexOf('designer-space-' + this.require('state').space());\n if (position !== -1) {\n position = position - 1;\n if (position === -1) {\n position = this.require('state').navigation().spaces().length - 1;\n }\n $('#' + this.require('state').navigation().spaces(position)).children()[0].click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false; \n break; \n // Command + Enter\n case key === 13 && command:\n this.require('13f70137b61b19b').click();\n event.stopPropagation();\n event.preventDefault();\n return false; \n break;\n // Enter \n case key === 13 && !command:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + D\n case key === 68 && command:\n if (this.require('factory').system()) {\n this.require('designer').open('diagram.html#' + this.require('factory').system().id(), 'diagram-' + this.require('factory').system().id());\n } else {\n message.warning('There is no system.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if (this.require('factory').system()) {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n } else {\n message.warning('There is no system.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + F\n case key === 70 && ctrl:\n if (this.require('factory').system()) {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogSearch');\n dialog = new Dialog({\n 'title': 'Search in the system',\n });\n dialog.show();\n } else {\n message.warning('There is no system.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + '+' \n case (key === 187 || key === 43) && ctrl:\n if (!this.require('factory').system() && this.require('state').menu() !== 'systems') {\n message.warning('There is no system: create first a system to continue.');\n } else {\n if (this.require('factory').system() && Object.keys(this.require('factory').system().schemas()).length === 0 && this.require('state').menu() === 'components') {\n message.warning('There is no schema: create first a schema to continue.');\n } else {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n this.require('workspace').create();\n }\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + I\n case key === 73 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n var DialogImportFile = this.require('DialogImportFile');\n \n DialogImportFile = new DialogImportFile({\n 'title': 'Import a system'\n });\n DialogImportFile.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + E\n case key === 69 && ctrl:\n if (this.require('factory').system()) {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = this.require('DialogExport');\n dialog = new Dialog({\n 'title': 'Export the current system',\n });\n dialog.show();\n } else {\n message.warning('There is no system to export.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + ->\n case key === 39 && ctrl:\n position = this.require('state').navigation().menu().indexOf('designer-menu-item-' + this.require('state').menu());\n if (position !== -1) {\n position = position + 1;\n if (position === this.require('state').navigation().menu().length) {\n position = 0;\n }\n document.getElementById(this.require('state').navigation().menu(position)).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + <-\n case key === 37 && ctrl:\n position = this.require('state').navigation().menu().indexOf('designer-menu-item-' + this.require('state').menu());\n if (position !== -1) {\n position = position - 1;\n if (position === -1) {\n position = this.require('state').navigation().menu().length -1;\n }\n document.getElementById(this.require('state').navigation().menu(position)).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + v\n case key === 40 && ctrl:\n position = this.require('state').navigation().spaces().indexOf('designer-space-' + this.require('state').space());\n if (position !== -1) {\n position = position + 1;\n if (position === this.require('state').navigation().spaces().length) {\n position = 0;\n }\n $('#' + this.require('state').navigation().spaces(position)).children()[0].click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false; \n break;\n // Ctrl + ^\n case key === 38 && ctrl:\n position = this.require('state').navigation().spaces().indexOf('designer-space-' + this.require('state').space());\n if (position !== -1) {\n position = position - 1;\n if (position === -1) {\n position = this.require('state').navigation().spaces().length - 1;\n }\n $('#' + this.require('state').navigation().spaces(position)).children()[0].click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false; \n break; \n // Ctrl + Enter\n case key === 13 && ctrl:\n this.require('13f70137b61b19b').click();\n event.stopPropagation();\n event.preventDefault();\n return false; \n break;\n // Enter \n case key === 13 && !ctrl:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break; \n // Ctrl + D\n case key === 68 && ctrl:\n if (this.require('factory').system()) {\n this.require('designer').open('diagram.html#' + this.require('factory').system().id(), 'diagram-' + this.require('factory').system().id());\n } else {\n message.warning('There is no system.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false},"q1e05f1c28c13d04":{"_id":"q1e05f1c28c13d04","component":"Designer","state":"runMessages","action":"function runMessages(messages) { \n messages.forEach(function (message) {\n if (message && message.event && message.event.indexOf('$system') === -1) {\n $db._Message.insert(message);\n }\n });\t\n}","useCoreAPI":true,"core":false},"c107c51c3091756f":{"_id":"c107c51c3091756f","component":"o195831c8251b34e","state":"click","action":"function click() { \n $('#designer-toolbar-item-diagram').tooltip('hide');\n \n var system = this.require('factory').system();\n \n if (system) {\n this.require('designer').open('diagram.html#' + system.id(), 'diagram-' + this.require('factory').system().id());\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"v173801bd85122c0":{"_id":"v173801bd85122c0","component":"t1bcd213629187e0","state":"click","action":"function click() { \n $('#designer-toolbar-item-diagram').tooltip('hide');\n \n var system = this.require('factory').system();\n \n if (system) {\n this.require('designer').open('diagram.html#' + system.id(), 'diagram-' + this.require('factory').system().id());\n } else {\n this.require('message').warning('There is no system.');\n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component","diagram"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"2.9.0"}},"Diagram":{},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.1.1","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1d113198721599d":{"_id":"l1d113198721599d","_name":"MenuItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"u1f9a01abe31b3bf":{"_id":"u1f9a01abe31b3bf","_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"menuitem-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"name":{"type":"string","readOnly":false,"mandatory":false,"default":"template"},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"},"render":{},"click":{}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() { \n\tvar name = $('#modal-modeljson-name').val(),\n\t jsonText = $('#modal-modeljson-json').val(),\n\t json = null,\n\t schema = {},\n\t model = {},\n\t property = '',\n\t type = '',\n\t typeName = '',\n\t arrayType = '',\n\t that = this,\n\t createdTypes = [];\n\t \n\tfunction _getTypeName(parent, name) {\n\t var result = name;\n\t \n\t if (!_validType(name)) {\n\t if (parent) {\n\t result = parent + '_' + name;\n\t } else {\n\t result = name + Math.floor(Math.random() * 11);\n\t }\n\t }\n\t \n\t return result;\n\t} \n\n function _getType(value) {\n var type = '';\n \n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n \n return type;\n } \n \n function _validName(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n } \n \n function _validType(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n return result;\n } \n \n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = ''; \n \n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false); \n \n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n switch (type) {\n case 'object':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = {};\n break;\n case 'number':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'number';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = 0;\n break;\n case 'boolean':\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'boolean';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = false;\n break;\n case 'array':\n typeDef.schema[property] = {};\n typeDef.schema[property].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n \n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n \t typeDef.schema[property].type = [_createTypeFromObject(name, property, obj[property][0])];\n \t typeDef.schema[property].default = [];\n \t } else {\n \t typeDef.schema[property].type = ['object'];\n \t typeDef.schema[property].default = [];\n \t }\n } else {\n typeDef.schema[property].type = [arrayType];\n typeDef.schema[property].default = [];\n }\n } else {\n typeDef.schema[property].type = ['any'];\n typeDef.schema[property].default = [];\n\t }\n break;\n default:\n typeDef.schema[property] = {};\n typeDef.schema[property].type = 'string';\n typeDef.schema[property].mandatory = false;\n typeDef.schema[property].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n \n return typeName;\n }\n \n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n\tif (name && _validName(name) && jsonText) {\n\t try {\n\t json = JSON.parse(jsonText);\n\t if (json) {\n\t // schema\n\t schema = this.require('factory').addSchema(name.trim());\n\t \n\t schema._inherit = [];\n\t this.require('factory').updateSchema(schema._id, schema);\n\t \n\t this.require('designer').save();\n\t \n\t for (property in json) {\n\t if (property.indexOf('_') !== 0) {\n \t type = _getType(json[property]);\n \t if (type === 'array') {\n \t schema[property] = 'collection';\n \t } else {\n \t schema[property] = 'property';\n \t }\n\t }\n\t }\n\t \n\t this.require('factory').updateSchema(schema._id, schema);\n\t this.require('designer').save();\n\t \n\t // model\n\t model = this.require('factory').createModel(schema);\n\t this.require('designer').save();\n\n\t for (property in schema) {\n\t if (property.indexOf('_') !== 0) {\n\t type = _getType(json[property]);\n\t switch (type) {\n\t case 'object':\n\t if (json[property] !== null) {\n\t model[property].type = _createTypeFromObject('', property, json[property]);\n\t model[property].default = {};\n\t } else {\n\t model[property].type = 'object';\n\t model[property].default = {};\n\t }\n\t break;\n\t case 'number':\n\t model[property].type = 'number';\n\t model[property].default = 0;\n\t break;\n\t case 'boolean':\n\t model[property].type = 'boolean';\n\t model[property].default = false;\n\t break;\n\t case 'array':\n\t if (typeof json[property][0] !== 'undefined') {\n\t arrayType = _getType(json[property][0]);\n\t if (arrayType === 'object') {\n\t if (json[property][0] !== null) {\n \t model[property].type = [_createTypeFromObject('', property, json[property][0])];\n \t model[property].default = [];\n \t } else {\n \t model[property].type = ['object'];\n \t model[property].default = [];\n \t }\n\t } else {\n\t model[property].type = [arrayType];\n\t model[property].default = [];\n\t }\n\t } else {\n\t model[property].type = ['any'];\n\t model[property].default = [];\n\t }\n\t break;\n\t \tcase 'string':\n\t model[property].type = 'string';\n\t model[property].default = '';\n\t break;\n\t default:\n\t break;\n\t }\n\t }\n\t }\n\t \n\t this.require('factory').updateModel(model._id, model);\n\t this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\t \n\t this.require('message').success('A model has been created for the JSON.');\n\t }\n\t } catch(e) {\n\t this.hide();\n\t this.require('message').warning('Can not create the model: the JSON is invalid.');\n\t }\n\t} \n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"MenuItem":{},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2018 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v2.9.0"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"A behavior is the action to do when a method or an event is called."},"help-components.html":{"_id":"help-components.html","source":"Components are your classes instances. Their states are saved in a store, a JSON object."},"help-logs.html":{"_id":"help-logs.html","source":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "},"help-models.html":{"_id":"help-models.html","source":"A model is an UML representation of your classes. It is generated from a schema."},"help-schemas.html":{"_id":"help-schemas.html","source":"A schema is the definition of your model. Models are generated based on the schema definition."},"help-system.html":{"_id":"help-system.html","source":"An application is a system. Once you have created one, your next step is to create a schema."},"help-types.html":{"_id":"help-types.html","source":"A type is used in your model to define an enumeration or a structure."},"menu-action-search.html":{"_id":"menu-action-search.html","source":"
    \n
    \n \n
    \n
    "},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-guide.html":{"_id":"menu-item-guide.html","source":"Guide"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs0"},"menu-item-message-save.html":{"_id":"menu-item-message-save.html","source":" file saved!"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-quick-start.html":{"_id":"menu-item-quick-start.html","source":"Quick Start"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"},"toolbar-item-diagram.html":{"_id":"toolbar-item-diagram.html","source":""},"menu-item-diagram.html":{"_id":"menu-item-diagram.html","source":"Class diagram"},"toolbar-item-zoomout.html":{"_id":"toolbar-item-zoomout.html","source":""},"toolbar-item-zoomin.html":{"_id":"toolbar-item-zoomin.html","source":""},"toolbar-item-zoominit.html":{"_id":"toolbar-item-zoominit.html","source":""},"toolbar-item-export-diagram.html":{"_id":"toolbar-item-export-diagram.html","source":""}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.0.0","description":"Quick start\n\nThis system is taken from the quick start: https://system-designer.readme.io/docs/quick-start","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n var luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n var result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vador":{"_id":"vador","father":"","firstName":"Dark","lastName":"Vador"},"luke":{"_id":"luke","father":"vador","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"04-send-messages.json":{"_id":"04-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.0.0","description":"Send messages threw a channel\n\n\nYou can send messages from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. In '_Channel' 'send' method, define how to send the message to another channel (webRTC, XHR, ...).\n3. In another system, define how to get the message and send it to the system with: runtime.message().\n4. To send a message: this.require('channel').myevent(param1, param2, ...).\n5. To listen to the message, just add a behavior to the event.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.0.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"type":"css","readOnly":false,"mandatory":false,"default":""},"render":{}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{},"filter":{"type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n var html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n var div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n var items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n var author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.0.1","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n var http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"04-create-extension.json":{"_id":"04-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.1.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"05-listen-collection-events.json":{"_id":"05-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.0.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""},"field":{"type":"string","mandatory":true,"default":""},"value":{"type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"id":{"type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"type":"string","mandatory":true,"default":""},"document":{"type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179ba":{"_id":"1f8571164c179ba","html":"menu-action-version.html","position":10,"type":"designer"}},"MenuHeader":{"1fb101b99813a12":{"_id":"1fb101b99813a12","html":"menu-header.html","type":"designer"}},"MenuItem":{"14f481302c106e6":{"_id":"14f481302c106e6","name":"models","html":"menu-item-models.html","position":20,"type":"designer","platform":"all"},"14f481302c106e7":{"_id":"14f481302c106e7","name":"logs","html":"menu-item-logs.html","position":60,"type":"designer","platform":"all"},"154dd1323f1ffg0a":{"_id":"154dd1323f1ffg0a","name":"systems","html":"menu-item-system.html","position":10,"type":"designer","platform":"all"},"154dd1323f1ffg1a":{"_id":"154dd1323f1ffg1a","name":"schemas","html":"menu-item-schemas.html","position":10,"type":"designer","platform":"all"},"19ec81ce751e196":{"_id":"19ec81ce751e196","name":"components","html":"menu-item-components.html","position":50,"type":"designer","platform":"all"},"1eb9d188b11824c":{"_id":"1eb9d188b11824c","name":"behaviors","html":"menu-item-behaviors.html","position":40,"type":"designer","platform":"all"},"1fd911618e18ea9":{"_id":"1fd911618e18ea9","name":"types","html":"menu-item-types.html","position":30,"type":"designer","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"1dbc51300e11z17":{"_id":"1dbc51300e11z17","html":"toolbar-item-search.html","position":35,"type":"designer","platform":"all"},"163a01b7ca1935c":{"_id":"163a01b7ca1935c","html":"toolbar-item-refresh.html","position":40,"type":"designer","platform":"web"},"163a01b7ca1935e":{"_id":"163a01b7ca1935e","html":"toolbar-item-export.html","position":50,"type":"designer","platform":"web"},"10bcb1a0511e09f":{"_id":"10bcb1a0511e09f","html":"toolbar-item-create.html","position":20,"type":"designer","platform":"all"},"13a291c27f16310":{"_id":"13a291c27f16310","html":"toolbar-item-copyright.html","position":90,"type":"designer","platform":"all"},"13a291c27f16314":{"_id":"13a291c27f16314","html":"toolbar-item-help.html","position":80,"type":"designer","platform":"all"},"13f70137b61b19b":{"_id":"13f70137b61b19b","html":"toolbar-item-publish.html","position":30,"type":"designer","platform":"all"},"163a01b7ca1935d":{"_id":"163a01b7ca1935d","html":"toolbar-item-import.html","position":45,"type":"designer","platform":"all"},"1dbc51200e116e11":{"_id":"1dbc51200e116e11","html":"toolbar-item-sync.html","position":65,"type":"designer","platform":"all"},"1dbc51200e116e3":{"_id":"1dbc51200e116e3","html":"toolbar-item-config.html","position":70,"type":"designer","platform":"all"},"y187401decb196c4":{"_id":"y187401decb196c4","html":"toolbar-item-export.html","position":50,"type":"designer","platform":"electron"},"x1371910b7812e58":{"_id":"x1371910b7812e58","html":"toolbar-item-refresh.html","position":40,"type":"designer","platform":"electron"},"g12f9e166c71cf91":{"_id":"g12f9e166c71cf91","html":"toolbar-item-extension.html","platform":"all","position":67,"type":"designer"},"l1f2871e69b1b85e":{"_id":"l1f2871e69b1b85e","html":"toolbar-item-command.html","platform":"web","position":37,"type":"designer"},"s1aa5c1170e1eba3":{"_id":"s1aa5c1170e1eba3","html":"toolbar-item-command.html","platform":"electron","position":37,"type":"designer"},"o195831c8251b34e":{"_id":"o195831c8251b34e","html":"toolbar-item-diagram.html","platform":"web","position":38,"type":"designer"},"t1bcd213629187e0":{"_id":"t1bcd213629187e0","html":"toolbar-item-diagram.html","platform":"electron","position":38,"type":"designer"}}},"_id":"e89c617b6b15d28"}); \ No newline at end of file diff --git a/designer/styles/designer.css b/designer/styles/designer.css index 6607a8a..e90b919 100644 --- a/designer/styles/designer.css +++ b/designer/styles/designer.css @@ -796,3 +796,9 @@ designer-spaces-components-header { -moz-transform: rotate(-90deg) !important; -ms-transform: rotate(-90deg) !important; } + +.log-number { + margin-left: 10px; + position: relative; + right: 0px; +} diff --git a/designer/styles/diagram.css b/designer/styles/diagram.css new file mode 100644 index 0000000..8d5cf48 --- /dev/null +++ b/designer/styles/diagram.css @@ -0,0 +1,443 @@ +/* + * System Designer + * + * https://designfirst.io/systemdesigner/ + * + * Copyright 2018 Erwan Carriou + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +body { + padding-top: 70px; + padding-bottom: 30px; +} + +body, +.navbar-fixed-top, +.navbar-fixed-bottom { + min-width: 500px; +} + +.lead { + font-size: 16px; +} + +.page-header { + margin-bottom: 30px; +} + +.page-header .lead { + margin-bottom: 10px; +} + +.container { + width: 100%; + max-width: none !important; +} + +.col-xs-4 { + padding-top: 15px; + padding-bottom: 15px; + background-color: #eee; + background-color: rgba(86, 61, 124, 0.15); + border: 1px solid #ddd; + border: 1px solid rgba(86, 61, 124, 0.2); +} + +.container .navbar-header, +.container .navbar-collapse { + margin-right: 0; + margin-left: 0; +} + +.navbar-header { + float: left; +} + +.navbar-collapse { + display: block !important; + height: auto !important; + padding-bottom: 0; + overflow: visible !important; + visibility: visible !important; +} + +.navbar-toggle { + display: none; +} + +.navbar-collapse { + border-top: 0; +} + +.navbar-brand { + margin-left: -15px; +} + +.navbar-nav { + float: left; + margin: 0; +} + +.navbar-nav > li { + float: left; +} + +.navbar-nav > li > a { + padding: 15px; +} + +.navbar-nav.navbar-right { + float: right; +} + +.navbar .navbar-nav .open .dropdown-menu { + position: absolute; + float: left; + background-color: #fff; + border: 1px solid #ccc; + border: 1px solid rgba(0, 0, 0, 0.15); + border-width: 0 1px 1px; + border-radius: 0 0 4px 4px; + -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175); + box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175); +} + +.navbar-default .navbar-nav .open .dropdown-menu > li > a { + color: #333; +} + +.navbar .navbar-nav .open .dropdown-menu > li > a:hover, +.navbar .navbar-nav .open .dropdown-menu > li > a:focus, +.navbar .navbar-nav .open .dropdown-menu > .active > a, +.navbar .navbar-nav .open .dropdown-menu > .active > a:hover, +.navbar .navbar-nav .open .dropdown-menu > .active > a:focus { + color: #fff !important; + background-color: #428bca !important; +} + +.navbar .navbar-nav .open .dropdown-menu > .disabled > a, +.navbar .navbar-nav .open .dropdown-menu > .disabled > a:hover, +.navbar .navbar-nav .open .dropdown-menu > .disabled > a:focus { + color: #999 !important; + background-color: transparent !important; +} + +.navbar-form { + float: left; + width: auto; + padding-top: 0; + padding-bottom: 0; + margin-right: 0; + margin-left: 0; + border: 0; + -webkit-box-shadow: none; + box-shadow: none; +} + +.navbar-form .form-group { + display: inline-block; + margin-bottom: 0; + vertical-align: middle; +} + +.navbar-form .form-control { + display: inline-block; + width: auto; + vertical-align: middle; +} + +.navbar-form .form-control-static { + display: inline-block; +} + +.navbar-form .input-group { + display: inline-table; + vertical-align: middle; +} + +.navbar-form .input-group .input-group-addon, +.navbar-form .input-group .input-group-btn, +.navbar-form .input-group .form-control { + width: auto; +} + +.navbar-form .input-group > .form-control { + width: 100%; +} + +.navbar-form .control-label { + margin-bottom: 0; + vertical-align: middle; +} + +.navbar-form .radio, +.navbar-form .checkbox { + display: inline-block; + margin-top: 0; + margin-bottom: 0; + vertical-align: middle; +} + +.navbar-form .radio label, +.navbar-form .checkbox label { + padding-left: 0; +} + +.navbar-form .radio input[type="radio"], +.navbar-form .checkbox input[type="checkbox"] { + position: relative; + margin-left: 0; +} + +.navbar-form .has-feedback .form-control-feedback { + top: 0; +} + +.form-inline .form-group { + display: inline-block; + margin-bottom: 0; + vertical-align: middle; +} + +.form-inline .form-control { + display: inline-block; + width: auto; + vertical-align: middle; +} + +.form-inline .form-control-static { + display: inline-block; +} + +.form-inline .input-group { + display: inline-table; + vertical-align: middle; +} + +.form-inline .input-group .input-group-addon, +.form-inline .input-group .input-group-btn, +.form-inline .input-group .form-control { + width: auto; +} + +.form-inline .input-group > .form-control { + width: 100%; +} + +.form-inline .control-label { + margin-bottom: 0; + vertical-align: middle; +} + +.form-inline .radio, +.form-inline .checkbox { + display: inline-block; + margin-top: 0; + margin-bottom: 0; + vertical-align: middle; +} + +.form-inline .radio label, +.form-inline .checkbox label { + padding-left: 0; +} + +.form-inline .radio input[type="radio"], +.form-inline .checkbox input[type="checkbox"] { + position: relative; + margin-left: 0; +} + +.form-inline .has-feedback .form-control-feedback { + top: 0; +} + +.sidebar { + position: fixed; + width: 50px; + top: 40px; + bottom: 0; + left: 0; + z-index: 1000; + display: block; + padding: 20px; + padding-top: 11px; + overflow-x: hidden; + overflow-y: auto; + background-color: #f8f8f8; + border-right: 1px solid #eee; +} + +.nav-sidebar { + margin-right: -21px; + margin-bottom: 20px; + margin-left: -20px; +} + +.nav-sidebar > li { + padding-top: 0px; + padding-bottom: 0px; +} + +.nav-sidebar > li > button { + border: 0px; + background-color: #f8f8f8; +} + +.designer-message-success { + display: none; +} + +.designer-message-info { + display: none; +} + +.designer-message-warning { + display: none; +} + +.designer-message-danger { + display: none; +} + +#designer-message { + z-index: 1000; + padding-right: 20px; + position: fixed; + right: 0px; + bottom: 0; + width: 400px; +} + +#designer-menubar-items li:hover { + background-color: #e7e7e7; +} + +.tooltip-inner { + background-color: #e7e7e7; + color: black; +} + +.tooltip.in { + opacity: 1; +} + +.tooltip.bottom .tooltip-arrow { + border-bottom-color: #e7e7e7 !important; +} + +.tooltip.right .tooltip-arrow { + border-right-color: #e7e7e7 !important; + border-bottom-color: white !important; +} + +.btn:focus { + outline: none !important; +} + +.modal-dialog .modal-content .modal-footer { + border: 0px; +} + +.CodeMirror { + height: inherit !important; +} + +.CodeMirror-gutter { + background-color: white !important; +} + +.CodeMirror-gutters { + border-right: 2px #fff !important; +} + +.CodeMirror-linenumber { + color: #555 !important; +} + +.CodeMirror-lines { + padding-top: 0px !important; + padding-bottom: 0px !important; +} + +.ace_search { + padding-right: 6px !important; + padding: 3px !important; +} + +.icon-reverse { + transform: scaleX(-1) !important; + -moz-transform: scaleX(-1) !important; + -webkit-transform: scaleX(-1) !important; + -ms-transform: scaleX(-1) !important; +} + +.icon-rotate-left { + transform: rotate(90deg) !important; + -webkit-transform: rotate(90deg) !important; + -moz-transform: rotate(90deg) !important; + -ms-transform: rotate(90deg) !important; +} + +#designer-dialog-command-modal .modal-body { + padding-bottom: 0px; +} + +#designer-dialog-command-result-area { + margin-bottom: 0px; +} + +.designer-command-result { + max-height: 300px; + overflow: auto; +} + +.list-group.designer-command-result { + cursor: pointer; + margin-bottom: 0px; +} + +.result-command { + max-height: 400px; + overflow: auto; +} + +.list-group-item { + border-left-width: 0px; + border-right-width: 0px; + color: color !important; + border: 0px; +} + +#designer-diagram { + position: absolute; + top: 4px; + right: 0; + bottom: 0; + left: 50px; + margin-top: 47px; + margin-left: 0px; +} + +.graph { + fill: #007bff; + cursor: move; + user-select: none; +} + +.static { + fill: #888; + cursor: not-allowed; +} diff --git a/designer/system.html b/designer/system.html index 9fa6455..ae92d44 100644 --- a/designer/system.html +++ b/designer/system.html @@ -1,5 +1,5 @@ - + diff --git a/designer/type.html b/designer/type.html index a7df22a..6b635e2 100644 --- a/designer/type.html +++ b/designer/type.html @@ -1,5 +1,5 @@ - + diff --git a/package.json b/package.json index 27cacd0..13af644 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "system-designer-electron", "productName": "System Designer", - "version": "2.8.3", + "version": "2.9.0", "description": "System Designer, an IDE for designing systems", "homepage": "https://designfirst.io/systemdesigner/", "author": "erwan carriou", @@ -9,11 +9,11 @@ "license": "Apache-2.0", "scripts": { "start": "electron main.js", - "macOS": "electron-packager ./ --platform=darwin --asar --arch=x64 --ignore=\"node_modules\" --overwrite --icon=Icon.icns --app-copyright \"Copyright © 2018 Erwan Carriou.\" --app-version 2.8.3 --build-version 300023", - "windows": "electron-packager ./ --platform=win32 --asar --arch=x64 --ignore=\"node_modules\" --overwrite --icon=Icon.ico --app-copyright \"Copyright © 2018 Erwan Carriou\" --app-version 2.8.3 --build-version 300023 --win32metadata.FileDescription=\"An IDE for designing systems\" --win32metadata.ProductName=\"System Designer\" --win32metadata.OriginalFilename=\"System Designer.exe\" " + "macOS": "electron-packager ./ --platform=darwin --asar --arch=x64 --ignore=\"node_modules\" --overwrite --icon=Icon.icns --app-copyright \"Copyright © 2018 Erwan Carriou.\" --app-version 2.9.0 --build-version 300031", + "windows": "electron-packager ./ --platform=win32 --asar --arch=x64 --ignore=\"node_modules\" --overwrite --icon=Icon.ico --app-copyright \"Copyright © 2018 Erwan Carriou\" --app-version 2.9.0 --build-version 300031 --win32metadata.FileDescription=\"An IDE for designing systems\" --win32metadata.ProductName=\"System Designer\" --win32metadata.OriginalFilename=\"System Designer.exe\" " }, "devDependencies": { "electron": "^1.8.7", - "electron-packager": "12.0.0" + "electron-packager": "12.1.0" } }