924,6,163,29,207,29,287,8,398,28,199,32,7230,34,2620,38,3580,22,317,31,434,20,743,30,220,35,490,46,18,42,1699,53,356,45,766,36,382,27,269,32,249,64,248,44,981,42,1075,47,966,61,576,67,2675,34,1065,50,1094,50,444,52,423,41,1674,40,860,46,845,56,1102,49,976,48,230,47,646,50,461,52,451,65,272,56,857,59,958,50,1046,90,199,68,867,24,335,36,209,24,4496,37,921,27,223,22,286,51,1223,57,496,57,296,67,329,63,200,67,652,71,746,83,440,69,833,73,270,75,1320,83,462,51,880,35,1886,47,1027,73,204,68,181,73,196,78,822,86,702,73,302,68,231,73,458,73,1266,68,648,73,357,66,954,72,1481,86,450,85,279,71,976,83,314,83,628,64,551,63,1636,69,1146,79,379,73,455,59,1331,62,136,66,430,78,1451,74,374,86,382,70,559,74,354,72,554,31,152,34,576,26,115,31,639,26,501,41,174,34,782,31,396,34,537,34,281,31,154,34,632,26,234,19,768,24,1068,27,81,30,73,33,330,27,282,37,505,37,769,27,516,49,222,33,723,24,249,24,247,9,900,9,957,18,1327,29,856,24,661 _info {"project":"app01-engine-start","branch":"master","version":204,"versionDate":"2024-05-02T09:31:54.000Z","fromVersion":0,"reset":true,"checksumDocs":"128-100921"} _shared/calcErrorSrc/calc.ls (function(){ return function(){ var d, month, day; d = new Date(); month = _.padStart(d.getMonth() + 1, 2, "0"); day = _.padStart(d.getDate(), 2, "0"); return month + day + "_" + Store("sourceId"); }; })(); _shared/isOnline/isOnline.ls (function(){ return function(){ var online, ref$, ref1$; return online = engine.simulateOffline ? false : engine.isMobileApp ? (ref$ = (ref1$ = engine.networkConnection) != null ? ref1$.isOnline : void 8) != null ? ref$ : true : (ref$ = navigator.onLine) != null ? ref$ : true; }; })(); init.ls (function(){ return function(){ var js, inc, module, exports; js = projects.documentCache["app01-engine-start"]["init/include/include.ls"].text; inc = eval(js)(); module = undefined; exports = undefined; window.app == null && (window.app = {}); inc("/../app01-engine-start/init/errorHandler/errorHandler")(); return setTimeout(function(){ return inc("/../app01-engine-start/init0")(); }); }; })(); init/Lawnchair/Lawnchair.ls (function(){ return function(){ var l; l = inc("lawnchair/lawnchair"); l.adapter("memory", inc("adapters/memory")()); l.adapter("file", inc("adapters/file")()); return window.Lawnchair = l; }; })(); init/Lawnchair/adapters/file.ls (function(){ return function(){ var fs, callSaveCallbacks, save, append, delayedSave, readFile, resetFile, fileAdapter; callSaveCallbacks = function(mthat){ _.forEach(mthat.saveCallbacks, function(callback){ return setTimeout(function(){ return mthat.lambda(callback).call(mthat); }); }); return mthat.saveCallbacks = []; }; save = function(mthat){ var fileName, timestamp, tempFileName, data; fileName = mthat.prefix + '/' + mthat.name + '.json'; timestamp = Date.now(); tempFileName = fileName + '_' + timestamp + '_tmp'; data = JSON.stringify(mthat.storage); mthat.needsRewrite = false; mthat.toAppend = []; return mthat.fs.writeFile(tempFileName, data, 0, function(error){ if (error) { mthat.error = error; mthat.needsRewrite = true; return console.error('error saving', fileName, error); } return mthat.fs.moveFile(tempFileName, fileName, function(error){ if (error) { mthat.error = error; mthat.needsRewrite = true; return console.error('error saving', fileName, error); } return callSaveCallbacks(mthat); }); }); }; append = function(mthat){ var fileName, timestamp, tempFileName, appendSerialized, appendString; if (mthat.toAppend.length === 0) { callSaveCallbacks(mthat); return; } fileName = mthat.prefix + '/' + mthat.name + '.json'; timestamp = Date.now(); tempFileName = fileName + '_' + timestamp + '_tmp'; appendSerialized = _.map(mthat.toAppend, function(obj){ return '"' + obj.key + '":' + JSON.stringify(obj); }); mthat.needsRewrite = false; mthat.toAppend = []; appendString = ',' + appendSerialized.join(',') + '}'; return mthat.fs.copyFile(fileName, tempFileName, function(error){ if (error) { mthat.error = error; mthat.needsRewrite = true; if (error.name !== 'NotFoundError') { console.error('error in copy', fileName, tempFileName, error); } return; } return mthat.fs.writeFile(tempFileName, appendString, -1, function(error){ if (error) { mthat.error = error; mthat.needsRewrite = true; return console.error('error appending', fileName, error); } return mthat.fs.moveFile(tempFileName, fileName, function(error){ if (error) { mthat.error = error; mthat.needsRewrite = true; return console.error('error appending', fileName, tempFileName, error); } return callSaveCallbacks(mthat); }); }); }); }; delayedSave = function(mthat){ if (mthat.saveTimeouts[mthat.name]) { clearTimeout(mthat.saveTimeouts[mthat.name]); } mthat.saveTimeouts[mthat.name] = setTimeout(function(){ if (mthat.fs.isWriting()) { delayedSave(mthat); } else if (mthat.needsRewrite) { save(mthat); } else { append(mthat); } }, 100); }; readFile = function(mthat, callback){ var fileName; fileName = mthat.prefix + '/' + mthat.name + '.json'; return mthat.fs.init(function(error){ if (error) { mthat.error = error; console.error('error init filesystem', error); return callback && callback(error); } return mthat.fs.existsFile(fileName, function(exists){ if (!exists) { return callback && callback(); } else { return mthat.fs.readFile(fileName, function(error, result){ var e; if (error) { mthat.error = e; console.error('error reading file', fileName, error); return resetFile(mthat, callback); } try { if (result.data[1] === ',') { mthat.needsRewrite = true; result.data = result.data[0] + result.data.slice(2); } mthat.storage = JSON.parse(result.data); if (_.isEmpty(mthat.storage)) { mthat.error = new Error('empty file'); } return setTimeout(callback); } catch (e$) { e = e$; mthat.error = e; console.error('error parsing file data', result != null ? result.data : void 8, e); return resetFile(mthat, callback); } }); } }); }); }; resetFile = function(mthat, callback){ var fileName, data; fileName = mthat.prefix + '/' + mthat.name + '.json'; data = JSON.stringify({}); mthat.storage = {}; mthat.needsRewrite = true; mthat.notEmpty = false; return mthat.fs.writeFile(fileName, data, 0, function(error){ if (error) { mthat.error = error; console.error('error saving file', fileName, error); } if (callback) { return mthat.lambda(callback).call(mthat); } }); }; fileAdapter = { valid: function(){ return fileSystem.hasFileSystem(); }, init: function(options, callback){ var mthat; mthat = this; mthat.storage = {}; mthat.toAppend = []; mthat.saveCallbacks = []; mthat.saveTimeouts = {}; mthat.fs = fileSystem.create(); return mthat.fs.init(function(){ return readFile(mthat, function(error){ if (error) { mthat.error = error; } if (callback) { return mthat.fn(mthat.name, callback).call(mthat, mthat); } }); }); }, save: function(obj, callback){ var mthat, key; mthat = this; key = obj.key || mthat.uuid(); if (mthat.storage[key] === undefined) { if (!mthat.notEmpty && _.isEmpty(mthat.storage)) { mthat.needsRewrite = true; } mthat.toAppend.push(obj); } else { mthat.needsRewrite = true; } mthat.notEmpty = true; mthat.storage[key] = obj; obj.key = key; if (callback) { mthat.saveCallbacks.push(callback); } delayedSave(mthat); return mthat; }, batch: function(ary, callback){ var mthat; mthat = this; if (!mthat.notEmpty && _.isEmpty(mthat.storage)) { mthat.needsRewrite = true; } mthat.notEmpty = true; _.forEach(ary, function(obj){ var key; key = obj.key || mthat.uuid(); if (mthat.storage[key] === undefined) { mthat.toAppend.push(obj); } else { mthat.needsRewrite = true; } mthat.storage[key] = obj; return obj.key = key; }); if (callback) { mthat.saveCallbacks.push(callback); } delayedSave(mthat); return mthat; }, keys: function(callback){ var mthat, keys; mthat = this; if (callback) { keys = _.keys(mthat.storage); keys = _.filter(keys, function(key){ return mthat.storage[key] !== undefined; }); mthat.fn('keys', callback).call(mthat, keys); } return mthat; }, get: function(key, callback){ var mthat, r, i, l, k, obj; mthat = this; if (_.isArray(key)) { r = []; i = 0; l = key.length; while (i < l) { k = key[i]; obj = mthat.storage[k]; if (obj) { obj.key = key[i]; r.push(obj); } i++; } if (callback) { mthat.lambda(callback).call(mthat, r); } } else { obj = mthat.storage[key]; if (obj) { obj.key = key; } if (callback) { mthat.lambda(callback).call(mthat, obj); } } return mthat; }, exists: function(key, cb){ var mthat, exists; mthat = this; exists = mthat.storage[key] !== undefined; mthat.lambda(cb).call(mthat, exists); return mthat; }, all: function(callback){ var mthat, r; mthat = this; r = _.compact(_.map(mthat.storage, function(value, key){ if (value) { value.key = key; } return value; })); if (callback) { mthat.fn(mthat.name, callback).call(mthat, r); } return mthat; }, resetFile: function(callback){ var mthat; mthat = this; return resetFile(mthat, callback); }, remove: function(keyOrArray, callback){ var toDelete, i, key, ref$, ref1$; toDelete = keyOrArray; if (!this.isArray(keyOrArray)) { toDelete = [keyOrArray]; } i = 0; while (i < toDelete.length) { key = (ref$ = toDelete[i]) != null && ref$.key ? (ref1$ = toDelete[i]) != null ? ref1$.key : void 8 : toDelete[i]; if (key) { this.storage[key] = undefined; } i++; } this.notEmpty = false; this.needsRewrite = true; if (callback) { this.saveCallbacks.push(callback); } delayedSave(this); return this; }, nuke: function(callback){ var mthat; mthat = this; mthat.needsRewrite = true; mthat.storage = {}; mthat.notEmpty = false; if (callback) { mthat.saveCallbacks.push(callback); } delayedSave(mthat); return mthat; } }; return fileAdapter; }; })(); init/Lawnchair/adapters/memory.ls (function(){ return function(){ var data, memoryAdapter; data = {}; memoryAdapter = { valid: function(){ return true; }, init: function(options, callback){ var cb; data[this.prefix + '_' + this.name] = data[this.prefix + '_' + this.name] || { index: [], store: {} }; this.index = data[this.prefix + '_' + this.name].index; this.store = data[this.prefix + '_' + this.name].store; cb = this.fn(this.name, callback); if (cb) { cb.call(this, this); } return this; }, keys: function(callback){ this.fn('keys', callback).call(this, this.index); return this; }, save: function(obj, cb, saveCallback){ var key; key = obj.key || this.uuid(); this.exists(key, function(exists){ if (!exists) { if (obj.key) { delete obj.key; } this.index.push(key); } this.store[key] = obj; if (cb) { obj.key = key; this.lambda(cb).call(this, obj); } if (saveCallback) { this.lambda(saveCallback).call(this); } }); return this; }, batch: function(objs, cb, saveCallback){ var r, i, l; r = []; i = 0; l = objs.length; while (i < l) { this.save(objs[i], fn$); i++; } if (cb) { this.lambda(cb).call(this, r); } if (saveCallback) { this.lambda(saveCallback).call(this, r); } return this; function fn$(record){ r.push(record); } }, get: function(keyOrArray, cb){ var r, i, l; r = undefined; if (this.isArray(keyOrArray)) { r = []; i = 0; l = keyOrArray.length; while (i < l) { r.push(this.store[keyOrArray[i]]); i++; } } else { r = this.store[keyOrArray]; if (r) { r.key = keyOrArray; } } if (cb) { this.lambda(cb).call(this, r); } return this; }, exists: function(key, cb){ this.lambda(cb).call(this, !!this.store[key]); return this; }, all: function(cb){ var r, i, l, obj; r = []; i = 0; l = this.index.length; while (i < l) { obj = this.store[this.index[i]]; obj.key = this.index[i]; r.push(obj); i++; } this.fn(this.name, cb).call(this, r); return this; }, remove: function(keyOrArray, cb, saveCallback){ var del, i, l, key, whereClause; del = this.isArray(keyOrArray) ? keyOrArray : [keyOrArray]; i = 0; l = del.length; while (i < l) { key = del[i].key ? del[i].key : del[i]; whereClause = this.indexOf(this.index, key); if (whereClause < 0) { i++; continue; } delete this.store[key]; this.index.splice(whereClause, 1); i++; } if (cb) { this.lambda(cb).call(this); } if (saveCallback) { this.lambda(saveCallback).call(this); } return this; }, nuke: function(cb, saveCallback){ this.store = data[this.prefix + '_' + this.name].store = {}; this.index = data[this.prefix + '_' + this.name].index = []; if (cb) { this.lambda(cb).call(this); } if (saveCallback) { this.lambda(saveCallback).call(this); } return this; } }; return memoryAdapter; }; })(); init/Lawnchair/lawnchair/lawnchair.ls (function(){ var Lawnchair; return Lawnchair = (function(){ Lawnchair.displayName = 'Lawnchair'; var prototype = Lawnchair.prototype, constructor = Lawnchair; function Lawnchair(options, callback){ var adapter, j, k, i, l; if (!(this instanceof Lawnchair)) { return new Lawnchair(options, callback); } if (!JSON) { throw new Error('JSON unavailable! Include http://www.json.org/json2.js to fix.'); } if (arguments.length <= 2) { callback = typeof arguments[0] === 'function' ? arguments[0] : arguments[1]; options = typeof arguments[0] === 'function' ? {} : arguments[0] || {}; } else { throw new Error('Incorrect # of ctor args!'); } this.record = options.record || 'record'; this.name = options.name || 'records'; this.prefix = options.prefix || 'lawnchair'; adapter = undefined; if (options.adapter) { if (typeof options.adapter === 'string') { options.adapter = [options.adapter]; } j = 0; k = options.adapter.length; while (j < k) { i = Lawnchair.adapters.length - 1; while (i >= 0) { if (Lawnchair.adapters[i].adapter === options.adapter[j]) { adapter = Lawnchair.adapters[i].valid() ? Lawnchair.adapters[i] : undefined; if (adapter) { break; } } i--; } if (adapter) { break; } j++; } } else { i = 0; l = Lawnchair.adapters.length; while (i < l) { adapter = Lawnchair.adapters[i].valid() ? Lawnchair.adapters[i] : undefined; if (adapter) { break; } i++; } } if (!adapter) { throw new Error('No valid adapter.'); } for (j in adapter) { this[j] = adapter[j]; } i = 0; l = Lawnchair.plugins.length; while (i < l) { Lawnchair.plugins[i].call(this); i++; } this.init(options, callback); } Lawnchair.adapters = []; Lawnchair.usedAdapter = function(){ var adapter, i; adapter = undefined; i = 0; while (i < Lawnchair.adapters.length) { adapter = Lawnchair.adapters[i].valid() ? Lawnchair.adapters[i] : undefined; if (adapter) { break; } i++; } return adapter.adapter; }; Lawnchair.adapter = function(id, obj){ var implementing, indexOf; obj['adapter'] = id; implementing = 'adapter valid init keys save batch get exists all remove nuke'.split(' '); indexOf = this.prototype.indexOf; return Lawnchair.adapters.splice(0, 0, obj); }; Lawnchair.plugins = []; Lawnchair.plugin = function(obj){ var i, results$ = []; for (i in obj) { if (i === 'init') { results$.push(Lawnchair.plugins.push(obj[i])); } else { results$.push(this.prototype[i] = obj[i]); } } return results$; }; Lawnchair.prototype.isArray = Array.isArray || function(o){ return Object.prototype.toString.call(o) === '[object Array]'; }; Lawnchair.prototype.indexOf = function(ary, item, i, l){ if (ary.indexOf) { return ary.indexOf(item); } i = 0; l = ary.length; while (i < l) { if (ary[i] === item) { return i; } i++; } return -1; }; Lawnchair.prototype.lambda = function(callback){ return this.fn(this.record, callback); }; Lawnchair.prototype.fn = function(name, callback){ if (typeof callback === 'string') { return new Function(name, callback); } else { return callback; } }; Lawnchair.prototype.uuid = function(){ var S4; S4 = function(){ return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1); }; return S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4(); }; Lawnchair.prototype.each = function(callback){ var cb, i, l; cb = this.lambda(callback); if (this.__results) { i = 0; l = this.__results.length; while (i < l) { cb.call(this, this.__results[i], i); i++; } } else { this.all(function(r){ var i, l, results$ = []; i = 0; l = r.length; while (i < l) { cb.call(this, r[i], i); results$.push(i++); } return results$; }); } return this; }; return Lawnchair; }()); })(); init/blockIE/block.ls (function(){ return function(){ var a, isIE, div, s; a = window.navigator.userAgent; isIE = /MSIE|Trident/.test(a); if (isIE) { div = document.createElement("div"); div.innerHTML = "Internet Explorer is not supported."; s = div.style; s.fontFamily = "verdana"; document.body.appendChild(div); return true; } }; })(); init/calcCachesEnabled/calc.ls (function(){ return function(cb){ var done, e; done = function(b){ engine.cachesEnabled = b; return setTimeout(cb); }; if (engine.isMobileApp || window.caches == null) { return done(false); } else { try { return typeof caches != 'undefined' && caches !== null ? caches.open("project").then(function(){ return done(true); })['catch'](function(){ return done(false); }) : void 8; } catch (e$) { e = e$; return done(false); } } }; })(); init/debug/debug.ls (function(){ return function(){ projects.includeInjections == null && (projects.includeInjections = {}); return projects.includeInjections.debug = function(filePath){ var f; return f = function(o){ var i$, to$, i, ref$, div, s; if (!engine.isDebug) { return; } if (arguments.length > 1) { for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) { i = i$; f(arguments[i]); } return; } if (typeof navigator != 'undefined' && navigator !== null) { if ((ref$ = navigator.splashscreen) != null) { if (typeof ref$.hide == 'function') { ref$.hide(); } } } div = document.createElement("div"); div.innerHTML = JSON.stringify(o, null, " "); s = div.style; s.color = "grey"; s.whiteSpace = "pre-wrap"; return document.body.appendChild(div); }; }; }; })(); init/debugStart/debugStart.ls (function(){ return function(){ if (_.includes(location.href, "debugStart") && Store("debug") !== true) { Store("debug", true); Store("ideEngineStart", true); alert("restart"); location.reload(); return true; } }; })(); init/decideContentServer/decide.ls (function(){ var queue; queue = []; return app.decideContentServer = function(cb){ var start, decideDone; start = function(){ queue.push(cb); if (queue.length === 1) { return inc("decide/decide")(decideDone); } }; decideDone = function(){ var i$, ref$, len$; for (i$ = 0, len$ = (ref$ = queue).length; i$ < len$; ++i$) { (fn$.call(this, ref$[i$])); } return queue = []; function fn$(f){ setTimeout(function(){ return typeof f == 'function' ? f() : void 8; }); } }; return start(); }; })(); init/decideContentServer/decide/_docs/docs.ls (function(){})(); init/decideContentServer/decide/decide.ls (function(){ return function(cb){ var s1, s2, pingLog, isFinished, checkIsOnline, ping, pingDone, finish; s1 = "https://content.anton.app"; s2 = "https://content-2.anton.app"; pingLog = []; isFinished = false; checkIsOnline = function(){ if (!inc("/_shared/isOnline/isOnline")()) { return finish(s1); } else { ping(s1); return ping(s2); } }; ping = function(s){ return inc("ping/ping")({ pingLog: pingLog, server: s, onDone: pingDone }); }; pingDone = function(){ var contentStatus, ref$, content2Status, ref1$; contentStatus = (ref$ = _.find(pingLog, { server: s1 })) != null ? ref$.status : void 8; content2Status = (ref1$ = _.find(pingLog, { server: s2 })) != null ? ref1$.status : void 8; if (contentStatus === "ok") { return finish(s1); } else if (content2Status === "ok" && (contentStatus === "timeout" || contentStatus === "error")) { return finish(s2); } else if (content2Status === "timeout" && contentStatus === "error") { return finish(s2); } else if ((content2Status === "timeout" || content2Status === "error") && (contentStatus === "timeout" || contentStatus === "error")) { return finish(app.contentServer || s1); } }; finish = function(server){ var ref$, ref1$; if (isFinished) { return; } isFinished = true; if (_.find(pingLog, function(l){ return l.status !== "ok"; })) { inc("logDebugEvent/log")(pingLog, server); } app.contentServer = server; app.contentServerFallback = server === s1 ? s2 : s1; app.contentServerDecision = { decidedAt: new Date(), status: { content: (ref$ = _.find(pingLog, { server: s1 })) != null ? ref$.status : void 8, content2: (ref1$ = _.find(pingLog, { server: s2 })) != null ? ref1$.status : void 8 } }; return cb(); }; return checkIsOnline(); }; })(); init/decideContentServer/decide/logDebugEvent/log.ls (function(){ return function(pingLog, server){ var e; e = { event: "deviceDebugDecideContentServer", version: 4, pingLog: pingLog, status: _.find(pingLog, { status: "ok" }) ? "ok" : "error", server: server }; return (typeof deviceLog != 'undefined' && deviceLog !== null ? deviceLog.log(e) : void 8) || helpers.postEvent(Store("deviceLogId"), e); }; })(); init/decideContentServer/decide/ping/ping.ls (function(){ return function(p){ var startedAt, xhr, server, onDone, pingLog, ping, logPing; startedAt = new Date(); xhr = new XMLHttpRequest(); server = p.server; onDone = p.onDone; pingLog = p.pingLog; ping = function(){ xhr.timeout = 1000; xhr.open("get", server + "/ping?cached=true"); xhr.onload = function(){ return trySafe(function(){ logPing("ok"); return onDone(); }); }; xhr.onerror = function(){ return trySafe(function(){ logPing("error"); return onDone(); }); }; xhr.ontimeout = function(){ return trySafe(function(){ logPing("timeout"); return onDone(); }); }; return xhr.send(); }; logPing = function(status){ return pingLog.push({ server: server, status: status, xhrStatus: xhr.status, duration: new Date() - startedAt }); }; return ping(); }; })(); init/engineIsDebug/engineIsDebug.ls (function(){ return function(){ return Object.defineProperty(engine, "isDebug", { configurable: true, enumerable: true, get: function(){ var d; d = typeof Store == 'function' ? Store("debug") : void 8; if (d == null) { d = false; } else if (!d || !_.isBoolean(d)) { d = false; if (typeof Store != 'undefined' && Store !== null) { Store.remove("debug"); } } return d; } }); }; })(); init/engineVersion/init.ls (function(){ return function(){ var cv, ev, ev2; cv = engine.clientVersion; ev = Store("engineVersion") || ""; if (cv === ev.split("-")[0]) { return; } ev2 = engine["isi" + "OsApp"] ? cv + "-" + cv : cv; if (ev !== ev2) { return Store("engineVersion", ev2); } }; })(); init/entryPoints/entryPoints.ls (function(){ return function(){ if (window.overwriteEntryPoints) { return; } window.overwriteEntryPoints = true; inc("requestAnimationFrame/requestAnimationFrame")(); inc("setTimeout/setTimeout")(); return inc("setInterval/setInterval")(); }; })(); init/entryPoints/requestAnimationFrame/requestAnimationFrame.ls (function(){ return function(){ var originalRAF; originalRAF = window.requestAnimationFrame; return window.requestAnimationFrame = function(onFrame){ return originalRAF(function(t){ return trySafe(function(){ return onFrame(t); }); }); }; }; })(); init/entryPoints/setInterval/setInterval.ls (function(){ return function(){ var originalSet, originalClear, functions, intervals; originalSet = window.setInterval; originalClear = window.clearInterval; functions = []; intervals = []; window.setInterval = function(){ var f, g, args, i$, to$, i, interval; if (f = arguments[0]) { if (!_.isFunction(f)) { debug("first argument of setInterval must be a function", f); } g = function(){ var args, mthis; args = [].slice.call(arguments); mthis = this; return trySafe(function(){ return f.apply(mthis, args); }); }; args = [g]; for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) { i = i$; args.push(arguments[i]); } interval = originalSet.apply(null, args); functions.push(f); intervals.push(interval); return interval; } }; window.clearInterval = function(interval){ var index; originalClear(interval); if ((index = intervals.indexOf(interval)) >= 0) { functions.splice(index, 1); return intervals.splice(index, 1); } }; return window.setIntervalFunctions = functions; }; })(); init/entryPoints/setTimeout/setTimeout.ls (function(){ return function(){ var originalSet, originalClear, functions, timeouts; originalSet = window.setTimeout; originalClear = window.clearTimeout; functions = []; timeouts = []; window.setTimeout = function(){ var f, timeout, g, args, i$, to$, i; if (f = arguments[0]) { if (!_.isFunction(f)) { debug("first argument of setTimeout must be a function", f); } g = function(){ var index, args, mthis; if ((index = timeouts.indexOf(timeout)) >= 0) { functions.splice(index, 1); timeouts.splice(index, 1); } args = [].slice.call(arguments); mthis = this; return trySafe(function(){ return f.apply(mthis, args); }); }; args = [g]; for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) { i = i$; args.push(arguments[i]); } timeout = originalSet.apply(null, args); } functions.push(f); timeouts.push(timeout); return timeout; }; window.clearTimeout = function(timeout){ var index; originalClear(timeout); if ((index = timeouts.indexOf(timeout)) >= 0) { functions.splice(index, 1); return timeouts.splice(index, 1); } }; return window.setTimeoutFunctions = functions; }; })(); init/errorHandler/calcErrorDescription/calc.ls (function(){ return function(message, file, line, col, error){ var d, f, e, localPath, fileString, codeLines; d = { message: message, line: line, stack: inc("formatStack/format")(error != null ? error.stack : void 8), error: inc("objectifyError/objectify")(error) }; try { f = error.stack.toString().split("$$")[1]; f = inc("formatStack/format")(f); d.file = "/../" + f.split(":")[0]; d.project = d.file.split("/")[2]; } catch (e$) { e = e$; d.file = file; d.project = "unknown"; } try { if (line > 0 && _.includes(d.file, "/../")) { localPath = d.file.substr(5 + d.project.length); fileString = projects.documents(d.project, localPath)[localPath]; codeLines = fileString.split("\n"); d.codeLineBefore = (((line - 1) + ": ") + _.trim(codeLines[line - 2])).substr(0, 200); d.codeLine = ((line + ": ") + _.trim(codeLines[line - 1])).substr(0, 200); d.codeLineAfter = (((line + 1) + ": ") + _.trim(codeLines[line])).substr(0, 200); } } catch (e$) {} return d; }; })(); init/errorHandler/calcErrorDescription/formatStack/format.ls (function(){ return function(stack){ var s, r, i$, len$, a, res$, ref$; if (!stack) { return; } s = stack.toString(); r = [["at HTMLDivElement.", "at "], ["at HTMLBodyElement.", "at "], ["at Object.", "at "], ["at fn$", ""], ["$$", ""], ["$S", "/"], ["$D", "."], ["$M", "-"], ["$B", " "], ["$P", ":"]]; for (i$ = 0, len$ = r.length; i$ < len$; ++i$) { a = r[i$]; s = s.split(a[0]).join(a[1]); } res$ = []; for (i$ = 0, len$ = (ref$ = s.split("\n")).length; i$ < len$; ++i$) { s = ref$[i$]; res$.push(s.split(" (eval")[0].trim()); } a = res$; return s = a.join("\n"); }; })(); init/errorHandler/calcErrorDescription/objectifyError/objectify.ls (function(){ return function(error){ var recursivePropertyFinder; try { recursivePropertyFinder = function(obj){ var copy; copy = function(result, value, key){ if (_.isFunction(obj[value]) === false) { if (_.isObject(obj[value])) { result[value] = recursivePropertyFinder(obj[value]); } else { result[value] = obj[value]; } } return result; }; if (deepEq$(obj, Object.prototype, '===')) { return {}; } else { return _.reduce(Object.getOwnPropertyNames(obj), copy, recursivePropertyFinder(Object.getPrototypeOf(obj))); } }; return recursivePropertyFinder(error); } catch (e$) {} }; })(); function deepEq$(x, y, type){ var toString = {}.toString, hasOwnProperty = {}.hasOwnProperty, has = function (obj, key) { return hasOwnProperty.call(obj, key); }; var first = true; return eq(x, y, []); function eq(a, b, stack) { var className, length, size, result, alength, blength, r, key, ref, sizeB; if (a == null || b == null) { return a === b; } if (a.__placeholder__ || b.__placeholder__) { return true; } if (a === b) { return a !== 0 || 1 / a == 1 / b; } className = toString.call(a); if (toString.call(b) != className) { return false; } switch (className) { case '[object String]': return a == String(b); case '[object Number]': return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b); case '[object Date]': case '[object Boolean]': return +a == +b; case '[object RegExp]': return a.source == b.source && a.global == b.global && a.multiline == b.multiline && a.ignoreCase == b.ignoreCase; } if (typeof a != 'object' || typeof b != 'object') { return false; } length = stack.length; while (length--) { if (stack[length] == a) { return true; } } stack.push(a); size = 0; result = true; if (className == '[object Array]') { alength = a.length; blength = b.length; if (first) { switch (type) { case '===': result = alength === blength; break; case '<==': result = alength <= blength; break; case '<<=': result = alength < blength; break; } size = alength; first = false; } else { result = alength === blength; size = alength; } if (result) { while (size--) { if (!(result = size in a == size in b && eq(a[size], b[size], stack))){ break; } } } } else { if ('constructor' in a != 'constructor' in b || a.constructor != b.constructor) { return false; } for (key in a) { if (has(a, key)) { size++; if (!(result = has(b, key) && eq(a[key], b[key], stack))) { break; } } } if (result) { sizeB = 0; for (key in b) { if (has(b, key)) { ++sizeB; } } if (first) { if (type === '<<=') { result = size < sizeB; } else if (type === '<==') { result = size <= sizeB } else { result = size === sizeB; } } else { first = false; result = size === sizeB; } } } stack.pop(); return result; } } init/errorHandler/errorHandler.ls (function(){ return function(){ var onError; onError = function(message, file, line, col, error){ var d, ref$, div, errorSrc, s, e; try { d = inc("calcErrorDescription/calc")(message, file, line, col, error); } catch (e$) {} if (typeof navigator != 'undefined' && navigator !== null) { if ((ref$ = navigator.splashscreen) != null) { if (typeof ref$.hide == 'function') { ref$.hide(); } } } div = document.createElement("div"); errorSrc = inc("/_shared/calcErrorSrc/calc")(); div.innerHTML = "Unexpected error (" + errorSrc + "), please restart."; s = div.style; s.fontFamily = "verdana"; document.body.appendChild(div); try { if (engine.isDebug) { debug(_.omit(d, ["error"])); } } catch (e$) {} try { e = { event: "deviceDebugEngineStartError", message: d.message, file: d.file, codeLine: d.codeLine, stack: d.stack, userAgent: navigator.userAgent, isMobileApp: engine.isMobileApp, engineVersion: engine.clientVersion }; return helpers.postEvent(Store("deviceLogId"), e); } catch (e$) {} }; window.onerror = onError; return helpers.errorHandler = onError; }; })(); init/fileSystem/fileSystem/createDir/createDir.ls (function(){ return function(fs, path, callback, index){ var parts, subPath, directory, checkFullPath, checkSubPath, createSubPath, finish; parts = path.split("/"); subPath = parts.slice(0, index + 1).join("/"); directory = null; checkFullPath = function(){ return fs.existsDir(path, function(exists, directory){ if (exists) { return typeof callback == 'function' ? callback(void 8, directory) : void 8; } else { return checkSubPath(); } }); }; checkSubPath = function(){ return fs.existsDir(subPath, function(exists, d){ if (!exists) { return createSubPath(); } else { directory = d; return finish(); } }); }; createSubPath = function(){ return fs.root.getDirectory(fs.dataDir + subPath, { create: true }, function(d){ return trySafe(function(){ directory = d; return finish(); }); }, function(error){ return trySafe(function(){ return callback(error); }); }); }; finish = function(){ var nextIndex; nextIndex = index + 1; if (nextIndex === parts.length) { return callback(void 8, directory); } else { return inc(THISFILE)(fs, path, callback, nextIndex); } }; return checkFullPath(); }; })(); init/fileSystem/fileSystem/existsDir/existsDir.ls (function(){ return function(fs, path, callback){ var p, getDir, finish; p = fs.dataDir + path; getDir = function(){ return fs.root.getDirectory(p, { create: false }, function(directory){ return finish(true, directory); }, function(error){ return finish(false); }); }; finish = function(exists, directory){ return trySafe(function(){ return typeof callback == 'function' ? callback(exists, directory) : void 8; }); }; return getDir(); }; })(); init/fileSystem/fileSystem/existsFile/existsFile.ls (function(){ return function(fs, path, callback){ var p, getFile, finish; p = fs.dataDir + path; getFile = function(){ return fs.root.getFile(p, { create: false }, function(fe){ return finish(true, fe); }, function(){ return finish(false); }); }; finish = function(exists, fileEntry){ return trySafe(function(){ return typeof callback == 'function' ? callback(exists, fileEntry) : void 8; }); }; return getFile(); }; })(); init/fileSystem/fileSystem/fileSystem.ls (function(){ return function(){ var fs, isCrosswalk, ref$, cd, rp, ref1$; return fs = { isCrosswalk: isCrosswalk = (typeof xwalk != 'undefined' && xwalk !== null ? (ref$ = xwalk.experimental) != null ? ref$.native_file_system : void 8 : void 8) != null, cordovaDir: cd = cordova.file.externalDataDirectory || cordova.file.dataDirectory, rootUrl: isCrosswalk ? "EXTERNAL" : cd, realPath: rp = typeof xwalk != 'undefined' && xwalk !== null ? (ref1$ = xwalk.experimental) != null ? ref1$.native_file_system.getRealPath("EXTERNAL") : void 8 : void 8, dataDir: !isCrosswalk ? "" : "EXTERNAL" + cd.replace("file://", "").replace(rp, ""), root: "", init: function(cb){ return inc("init/init")(fs, cb); }, existsFile: function(p, cb){ return inc("existsFile/existsFile")(fs, p, cb); }, existsDir: function(p, cb){ return inc("existsDir/existsDir")(fs, p, cb); }, readFile: function(p, cb){ return inc("readFile/readFile")(fs, p, cb); }, removeDir: function(p, cb){ return inc("removeDir/removeDir")(fs, p, cb); }, removeFile: function(p, cb){ return inc("removeFile/removeFile")(fs, p, cb); }, listDir: function(p, cb){ return inc("listDir/listDir")(fs, p, cb); }, createDir: function(p, cb){ return inc("createDir/createDir")(fs, p, cb, 0); }, writeFile: function(p, data, offset, cb){ return inc("writeFile/writeFile")(fs, p, data, offset, cb); }, moveFile: function(frP, toP, cb){ return inc("moveOrCopyFile/moveOrCopy")(fs, "moveTo", frP, toP, cb); }, copyFile: function(frP, toP, cb){ return inc("moveOrCopyFile/moveOrCopy")(fs, "copyTo", frP, toP, cb); }, _isWriting: false, isWriting: function(){ var ref$; return (ref$ = fs._isWriting) != null ? ref$ : false; } }; }; })(); init/fileSystem/fileSystem/init/init.ls (function(){ var _root; _root = null; return function(fs, callback){ if (_root) { fs.root = _root; if (typeof callback == 'function') { callback(); } return; } if (fs.isCrosswalk) { return xwalk.experimental.native_file_system.requestNativeFileSystem(fs.rootUrl, function(f){ return trySafe(function(){ _root = f.root; fs.root = _root; return typeof callback == 'function' ? callback() : void 8; }); }, function(error){ return trySafe(function(){ throw Error("FileError Crosswalk, fileUrl: " + fs.rootUrl); }); }); } else { return window.resolveLocalFileSystemURL(fs.rootUrl, function(root){ return trySafe(function(){ _root = root; fs.root = _root; return typeof callback == 'function' ? callback() : void 8; }); }, function(error){ return trySafe(function(){ throw Error("FileError errorCode: " + error.code + ", fileUrl: " + fs.rootUrl); }); }); } }; })(); init/fileSystem/fileSystem/listDir/listDir.ls (function(){ return function(fs, path, callback){ var dirReader, entries, getDir, createReader, readEntries, finish; dirReader = undefined; entries = []; getDir = function(){ var p; p = fs.dataDir + path; return fs.root.getDirectory(p, { create: false }, createReader, finish); }; createReader = function(directory){ return trySafe(function(){ dirReader = directory.createReader(); return readEntries(); }); }; readEntries = function(){ return dirReader.readEntries(function(result){ var i$, len$, entry; if (result.length > 0) { for (i$ = 0, len$ = result.length; i$ < len$; ++i$) { entry = result[i$]; entries.push(entry); } return readEntries(); } else { return finish(); } }, function(error){ return finish(error); }); }; finish = function(error){ return trySafe(function(){ return callback(error, entries); }); }; return getDir(); }; })(); init/fileSystem/fileSystem/moveOrCopyFile/moveOrCopy.ls (function(){ return function(fs, mode, fromPath, toPath, callback){ var dirPath, newName, directory, fileEntry, getDir, getFileEntry, moveOrCopy; dirPath = toPath.split("/").slice(0, -1).join("/"); newName = toPath.split("/").slice(-1)[0]; directory = null; fileEntry = null; getDir = function(){ return fs.createDir(dirPath, function(error, d){ if (error) { return typeof callback == 'function' ? callback(error) : void 8; } else { directory = d; return getFileEntry(); } }); }; getFileEntry = function(){ var p; p = fs.dataDir + fromPath; return fs.root.getFile(p, { create: false }, function(fe){ return trySafe(function(){ fileEntry = fe; return moveOrCopy(); }); }, function(error){ return trySafe(function(){ return callback(error); }); }); }; moveOrCopy = function(){ return fileEntry[mode](directory, newName, function(newFileEntry){ return trySafe(function(){ return typeof callback == 'function' ? callback(void 8, newFileEntry) : void 8; }); }, function(error){ return trySafe(function(){ return typeof callback == 'function' ? callback(error) : void 8; }); }); }; return getDir(); }; })(); init/fileSystem/fileSystem/readFile/file/file.ls (function(){ return function(fs, path, callback){ var p, getFile, readFile, finish; p = fs.dataDir + path; getFile = function(){ return fs.root.getFile(p, { create: false }, function(fe){ return trySafe(function(){ return readFile(fe); }); }, function(error){ return trySafe(function(){ return finish(error); }); }); }; readFile = function(fileEntry){ return fileEntry.file(function(file){ return trySafe(function(){ var reader; reader = new FileReader(); reader.onloadend = function(e){ return trySafe(function(){ var result, error; try { result = { path: path, url: fs.rootUrl + path, data: e.target.result }; return finish(void 8, result); } catch (e$) { error = e$; return finish(error); } }); }; reader.onerror = function(e){ return trySafe(function(){ return finish(e.target.error); }); }; return reader.readAsText(file); }); }); }; finish = function(error, result){ return typeof callback == 'function' ? callback(error, result) : void 8; }; return getFile(); }; })(); init/fileSystem/fileSystem/readFile/readFile.ls (function(){ return function(fs, path, cb){ if (fs.isCrosswalk || (device.platform === "iOS" && device.version.split(".")[0] < 11)) { return inc("file/file")(fs, path, cb); } else { return inc("xhr/xhr")(fs, path, cb); } }; })(); init/fileSystem/fileSystem/readFile/xhr/xhr.ls (function(){ return function(fs, path, callback){ var url, xhr; url = fs.rootUrl + path; if (engine.isiOsApp) { url = "ios" + url; } xhr = new XMLHttpRequest(); xhr.onload = function(){ return trySafe(function(){ var result; result = { path: path, url: url, data: xhr.response }; return typeof callback == 'function' ? callback(void 8, result) : void 8; }); }; xhr.onerror = function(error){ return trySafe(function(){ return typeof callback == 'function' ? callback(error) : void 8; }); }; xhr.open("GET", url); xhr.responseType = "text"; xhr.setRequestHeader("Cache-Control", "no-cache, no-store, must-revalidate"); return xhr.send(); }; })(); init/fileSystem/fileSystem/removeDir/removeDir.ls (function(){ return function(fs, path, callback){ var p, getDir, removeDir, finish; p = fs.dataDir + path; getDir = function(){ return fs.root.getDirectory(p, { create: false }, removeDir, finish); }; removeDir = function(directory){ return trySafe(function(){ return directory.removeRecursively(finish, finish); }); }; finish = function(){ return trySafe(function(){ return typeof callback == 'function' ? callback() : void 8; }); }; return getDir(); }; })(); init/fileSystem/fileSystem/removeFile/removeFile.ls (function(){ return function(fs, path, callback){ var p, getFile, removeFile, finish; p = fs.dataDir + path; getFile = function(){ return fs.root.getFile(p, { create: false }, removeFile, finish); }; removeFile = function(fileEntry){ return trySafe(function(){ return fileEntry.remove(finish, finish); }); }; finish = function(){ return trySafe(function(){ return typeof callback == 'function' ? callback() : void 8; }); }; return getFile(); }; })(); init/fileSystem/fileSystem/writeFile/_createDataString/create.ls (function(){ return function(data, callback){ var r; if (data instanceof Blob) { r = new FileReader(); r.onloadend = function(e){ return trySafe(function(){ return callback(e.srcElement.result); }); }; return r.readAsText(data); } else { return callback(data); } }; })(); init/fileSystem/fileSystem/writeFile/crosswalk/write.ls (function(){ return function(fs, file, data, offset, finish, onError){ var writer, blob, createWriter, write, onWrite; writer = undefined; offset == null && (offset = 0); blob = _.isString(data) ? new Blob([data], { type: "text/plain" }) : data; createWriter = function(){ return file.createWriter(function(w){ return trySafe(function(){ writer = w; return write(); }); }, function(error){ return onError(error); }); }; write = function(){ if (offset < 0) { offset = writer.length + offset; } writer.seek(offset); writer.onwrite = onWrite; writer.onerror = function(event){ return onError(event.target.error); }; return writer.write(blob); }; onWrite = function(){ if (fs.isCrosswalk && writer.length > offset + blob.size) { writer.onwrite = finish; return writer.truncate(offset + blob.size); } else { return finish(); } }; return createWriter(); }; })(); init/fileSystem/fileSystem/writeFile/writeChunked/write.ls (function(){ return function(fs, file, data, offset, finish, onError){ var writer, dataString, pos, chunkSize, createDataString, createWriter, prepareWriter, writeNextChunk; offset == null && (offset = 0); writer = null; dataString = ""; pos = 0; chunkSize = 1000000; createDataString = function(){ return inc("../_createDataString/create")(data, function(ds){ dataString = ds; return createWriter(); }); }; createWriter = function(){ return file.createWriter(prepareWriter, onError); }; prepareWriter = function(w){ return trySafe(function(){ writer = w; writer.onwrite = writeNextChunk; writer.onerror = onError; if (offset < 0) { offset = writer.length + offset; } writer.seek(offset); return writeNextChunk(); }); }; writeNextChunk = function(){ return trySafe(function(){ var s, l; s = dataString.substr(pos, chunkSize); l = s.length; if (l > 0) { writer.write(s); return pos += l; } else { return finish(); } }); }; return createDataString(); }; })(); init/fileSystem/fileSystem/writeFile/writeFile.ls (function(){ return function(fs, path, data, offset, callback){ var dir, file, createDir, openFile, write, finish, onError; dir = path.split("/").slice(0, -1).join("/"); file = undefined; createDir = function(){ return fs.createDir(dir, openFile); }; openFile = function(){ var p; p = fs.dataDir + path; return fs.root.getFile(p, { create: true }, function(f){ return trySafe(function(){ file = f; return write(); }); }, function(error){ return onError(error); }); }; write = function(){ var f; f = fs.isCrosswalk ? inc("crosswalk/write") : engine.isAndroidApp ? inc("writeNativeFileWriter/write") : engine.isiOsApp ? inc("writeChunked/write") : void 8; return f(fs, file, data, offset, finish, onError); }; finish = function(){ return trySafe(function(){ fs._isWriting = false; return typeof callback == 'function' ? callback() : void 8; }); }; onError = function(error){ return trySafe(function(){ fs._isWriting = false; return typeof callback == 'function' ? callback(error) : void 8; }); }; fs._isWriting = true; return createDir(); }; })(); init/fileSystem/fileSystem/writeFile/writeNativeFileWriter/pluginSaveCallback/callback.ls (function(){ return function(callbackId){ var cb; cb = window.pluginSaveCallbacks[callbackId]; delete window.pluginSaveCallbacks[callbackId]; return typeof cb == 'function' ? cb() : void 8; }; })(); init/fileSystem/fileSystem/writeFile/writeNativeFileWriter/write.ls (function(){ window.pluginSaveCallbacks == null && (window.pluginSaveCallbacks = {}); window.pluginSaveCallback == null && (window.pluginSaveCallback = inc("pluginSaveCallback/callback")); return function(fs, file, data, offset, finish, onError){ var dataString, path, callbackId, createDataString, write, onDone; dataString = ""; path = _.replace(file.nativeURL, "file://", "") + "/"; callbackId = _.random(0, 1000000000); createDataString = function(){ return inc("../_createDataString/create")(data, function(ds){ dataString = ds; return write(); }); }; write = function(){ window.pluginSaveCallbacks[callbackId] = onDone; return NativeFileWriter.writeFile(path, dataString, offset, callbackId); }; onDone = function(error){ return trySafe(function(){ if (error) { return onError(error); } else { return finish(error); } }); }; return createDataString(); }; })(); init/fileSystem/init.ls (function(){ return function(done){ var fs; if (!engine.isMobileApp) { window.fileSystem = undefined; return done(); } else { window.fileSystem = { hasFileSystem: function(){ return true; }, create: inc("fileSystem/fileSystem") }; fs = fileSystem.create(); engine.fileSystem = fs; app.fileSystem = fs; return fs.init(done); } }; })(); init/fixFirefoxIosStartError/fix.ls (function(){ return function(){ var div, ref$; div = document.createElement("div"); div.innerHTML = "."; div.style.opacity = 0; return (ref$ = document.body) != null ? ref$.appendChild(div) : void 8; }; })(); init/include/include.ls (function(){ return function(){ var f; projects.includeCache == null && (projects.includeCache = {}); f = function(absolutePath, params, injectTHISFILE){ var reduceErrorStack, onError, project, localPath, cache, cacheId, ref$, c, files, result, p, res$, fileString, code, injectPath, injectT, injectDebug, injectStartPage, localCache, injectInclude, n, code2, i$, ref1$, len$, i, s, compile, error; params = _.isObject(params) ? params : params === true ? { returnAsObject: true, silentError: false } : { returnAsObject: false, silentError: false }; reduceErrorStack = function(error){ var a, i$, i; a = error.stack.split("\n"); for (i$ = 1; i$ <= 4; ++i$) { i = i$; if (_.includes(a[i], "injectInclude")) { a[i] = null; break; } else { a[i] = null; } } return error.stack = _.compact(a).join("\n"); }; onError = function(message, file){ var error, a; file == null && (file = absolutePath); if (params.silentError) { return { includeError: message, file: file }; } else { error = new Error(message); reduceErrorStack(error); a = error.stack.split("\n"); a[0] += "\n at $$" + file.substr(4) + "$$"; error.stack = a.join("\n"); error.hideErrorCodeLines = true; throw error; } }; project = absolutePath.split("/")[2]; localPath = absolutePath.substr(5 + project.length); if (localPath.indexOf(".") === -1 && localPath.indexOf("*") === -1) { localPath += ".ls"; } absolutePath = "/../" + project + "/" + localPath; cache = projects.includeCache[project]; if (!cache) { projects.includeCache[project] = {}; cache = projects.includeCache[project]; } cacheId = localPath + ((ref$ = params.returnAsObject) != null ? ref$ : ""); if (c = cache[cacheId]) { return c; } if (absolutePath.indexOf("*") > -1) { files = projects.documents(project, localPath); if (params.returnAsObject) { result = {}; for (p in files) { if (p === "_info") { continue; } else { result[p] = f("/../" + project + "/" + p); } } } else { res$ = []; for (p in files) { if (p === "_info") { continue; } else { res$.push(f("/../" + project + "/" + p)); } } result = res$; } return cache[cacheId] = result; } try { fileString = (ref$ = projects.documentCache[project][localPath]) != null ? ref$.text : void 8; } catch (e$) {} if (!fileString) { return onError("include file not found: " + absolutePath, injectTHISFILE); } if (localPath.indexOf(".json") > -1 || (localPath.indexOf(".ls") === -1 && localPath.indexOf(".js") === -1)) { return cache[cacheId] = fileString; } else if (localPath.indexOf(".js") > -1) { code = fileString; } else { if (fileString.indexOf("Livescript" + " compilation error") > -1) { return onError("include ls compilation error"); } if (fileString.indexOf("Error:" + " Parse") > -1) { return onError("include ls parse error"); } if (fileString.indexOf("(function") !== 0) { return onError("include ls start function missing error"); } injectTHISFILE = absolutePath; injectPath = function(path){ return helpers.getAbsolutePath(path, absolutePath); }; injectT = function(){ return typeof engine.translate == 'function' ? engine.translate({ project: project, localPath: localPath, absolutePath: absolutePath, arguments: arguments }) : void 8; }; injectDebug = function(){ var ref$; return typeof (ref$ = projects.includeInjections).debug == 'function' ? ref$.debug(absolutePath).apply(void 8, arguments) : void 8; }; injectStartPage = function(){ return projects.includeInjections.startPage(absolutePath).apply(void 8, arguments); }; localCache = {}; cache._localCaches == null && (cache._localCaches = {}); cache._localCaches[cacheId] = localCache; injectInclude = function(path, params){ var r; r = localCache[path]; if (r) { return r; } r = f(injectPath(path), params, injectTHISFILE); if (r != null && params == null && path.substr(0, 4) !== "/../") { localCache[path] = r; } return r; }; code = fileString; n = absolutePath.substr(4); n = n.split(".").join("$D"); n = n.split("/").join("$S"); n = n.split("-").join("$M"); n = n.split(" ").join("$B"); code2 = ""; for (i$ = 0, len$ = (ref1$ = code.split("function(")).length; i$ < len$; ++i$) { i = i$; s = ref1$[i$]; code2 += i === 0 ? s : ("function $$" + n + "$P" + (i - 1) + "$$(") + s; } code = code2; } compile = function(THISFILE, path, include, inc, debug, startPage, T){ return eval(code); }; try { result = compile(injectTHISFILE, injectPath, injectInclude, injectInclude, injectDebug, injectStartPage, injectT); } catch (e$) { error = e$; return onError("include js error: " + error.message); } return cache[cacheId] = result; }; return f; }; })(); init/projects/documents/documents.ls (function(){ return function(project, path){ var dc, documents, ref$, p, regex, paths, validPaths, i$, len$, ref1$; dc = projects.documentCache[project]; if (!_.includes(path, '*')) { documents = {}; documents[path] = dc != null ? (ref$ = dc[path]) != null ? ref$.text : void 8 : void 8; return documents; } p = path.replace(/\//g, '\\/'); p = p.replace(/\./g, '\\.'); p = p.replace(/\*\*/g, '.*'); p = p.replace(/([^\.]|\\\.)(\*)/, function(a, b){ return b + "[^\\/]*"; }); p = p.replace(/^(\*)/, "[^\\/]*"); if (p === '*') { p = '.*'; } p = "^" + p + "$"; regex = new RegExp(p); paths = _.keys(dc); validPaths = _.filter(paths, function(p){ return p.match(regex); }); validPaths = _.sortBy(validPaths); documents = {}; for (i$ = 0, len$ = validPaths.length; i$ < len$; ++i$) { path = validPaths[i$]; documents[path] = dc != null ? (ref1$ = dc[path]) != null ? ref1$.text : void 8 : void 8; } return documents; }; })(); init/projects/info/info.ls (function(){ return function(){ var infos, p, ref$, d, i; infos = {}; for (p in ref$ = projects.documentCache) { d = ref$[p]; if (d._info) { i = _.clone(d._info); i.isLoaded = true; infos[p] = i; } } return infos; }; })(); init/projects/init.ls (function(){ return function(){ projects.info = inc("info/info"); projects.documentCache == null && (projects.documentCache = {}); projects.documents = inc("documents/documents"); projects.loadProjects = inc("loadProjects/load"); return projects.unload = inc("unload/unload"); }; })(); init/projects/loadProjects/calcEnvironment/calc.ls (function(){ return function(params, onDone){ var projectVersions, fileNames, prebundleVersions, maxAgeProjectVersions, offline, local, getProjectVersions, getFileNames, getPrebundleVersions, totalDone, finish; projectVersions = null; fileNames = null; prebundleVersions = null; maxAgeProjectVersions = params.maxAgeProjectVersions; offline = !inc("/_shared/isOnline/isOnline")(); local = inc("calcL/calc")(); getProjectVersions = function(){ return inc("getProjectVersions/get")(maxAgeProjectVersions, offline, local, function(l){ projectVersions = l; return finish(); }); }; getFileNames = function(){ return inc("getFileNames/get")(function(f){ fileNames = f; return finish(); }); }; getPrebundleVersions = function(){ return inc("getPrebundleVersions/get")(function(v){ prebundleVersions = v; return finish(); }); }; totalDone = 0; finish = function(){ var environment; totalDone++; if (totalDone === 3) { environment = { projectVersions: projectVersions, fileNames: fileNames, prebundleVersions: prebundleVersions, offline: offline, local: local }; inc("overwritePrebundleVersions/overwrite")(environment); return onDone(environment); } }; getProjectVersions(); getFileNames(); return getPrebundleVersions(); }; })(); init/projects/loadProjects/calcEnvironment/calcL/calc.ls (function(){ return function(){ var a, ref$, ref1$, v, l, n; a = (ref$ = (ref1$ = Store("engineVersion")) != null ? ref1$.split("-") : void 8) != null ? ref$ : []; v = a[0]; l = (ref$ = a[2]) != null ? ref$ : a[1]; if (!v || !l || +l === 0) { return false; } n = function(s){ var x, a, i$, len$, i, p; x = "000"; a = s.split("."); for (i$ = 0, len$ = a.length; i$ < len$; ++i$) { i = i$; p = a[i$]; a[i] = x.substr(0, 3 - p.length) + p; } return a.join("."); }; return l = n(v) >= n(l); }; })(); init/projects/loadProjects/calcEnvironment/calcO/calc.ls (function(){ return function(){ var online, ref$, ref1$; online = engine.simulateOffline ? false : engine.isMobileApp ? (ref$ = (ref1$ = engine.networkConnection) != null ? ref1$.isOnline : void 8) != null ? ref$ : true : (ref$ = navigator.onLine) != null ? ref$ : true; return !online; }; })(); init/projects/loadProjects/calcEnvironment/getFileNames/app/app.ls (function(){ return function(onDone){ var fs, ref$; fs = (ref$ = engine.fileSystem) != null ? ref$ : app.fileSystem; return fs.listDir("/project", function(error, dir){ return trySafe(function(){ var fileNames; if (error) { return onDone([]); } else { fileNames = _.map(dir, "name"); return onDone(fileNames); } }); }); }; })(); init/projects/loadProjects/calcEnvironment/getFileNames/get.ls (function(){ return function(onDone){ if (engine.isMobileApp) { return inc("app/app")(onDone); } else if (engine.cachesEnabled) { return inc("web/web")(onDone); } else { return onDone([]); } }; })(); init/projects/loadProjects/calcEnvironment/getFileNames/web/web.ls (function(){ return function(onDone){ var cache, t1, openCache, list, finish; cache = null; t1 = new Date(); openCache = function(){ return caches.open("project").then(function(c){ return trySafe(function(){ cache = c; return list(); }); }); }; list = function(){ return cache.keys().then(function(keys){ return trySafe(function(){ var fileNames, res$, i$, ref$, len$, k; res$ = []; for (i$ = 0, len$ = (ref$ = keys).length; i$ < len$; ++i$) { k = ref$[i$]; res$.push(k.url.replace("http://project/", "")); } fileNames = res$; return finish(fileNames); }); }); }; finish = function(fileNames){ return onDone(fileNames); }; return openCache(); }; })(); init/projects/loadProjects/calcEnvironment/getPrebundleVersions/get.ls (function(){ var prebundleVersions; prebundleVersions = null; return function(onDone){ var load, onLoaded; load = function(){ var xhr; xhr = new XMLHttpRequest(); xhr.open("get", "projects/_projects.json"); xhr.send(); xhr.onload = function(){ return trySafe(function(){ return onLoaded(xhr.response); }); }; return xhr.onerror = function(){ return trySafe(function(){ return onDone(); }); }; }; onLoaded = function(result){ try { result = JSON.parse(result); } catch (e$) {} prebundleVersions = result; return onDone(result); }; if (!engine.isMobileApp) { return onDone({}); } else if (prebundleVersions) { return onDone(prebundleVersions); } else if (Store("projectVersionsHistoryDate")) { return onDone({}); } else { return load(); } }; })(); init/projects/loadProjects/calcEnvironment/getProjectVersions/calcVersions/calc.ls (function(){ return function(r){ var versions, s, p, ref$, t, a, o, l, i$, len$, i, n, v; versions = {}; s = "dow" + "nloa" + "dedAt"; versions[s] = new Date(r[s]); for (p in ref$ = r.projects) { t = ref$[p]; a = t.split(","); o = {}; l = ["master", "develop", "masterMin", "developMin"]; for (i$ = 0, len$ = l.length; i$ < len$; ++i$) { i = i$; n = l[i$]; v = +a[i]; if (v > 0) { o[n] = v; } } versions[p] = o; } return versions; }; })(); init/projects/loadProjects/calcEnvironment/getProjectVersions/get.ls (function(){ return function(maxAgeProjectVersions, offline, local, onDone){ var load, get, finish, lastVersions; load = function(){ return inc("load/load")({ onDone: finish, onError: get }); }; get = function(){ return inc("get/get")({ onDone: finish, onError: finish }); }; finish = function(r){ var v; v = r != null && r.projects ? inc("calcVersions/calc")(r) : r != null && r.isLocal ? { isLocal: true } : { loadFailed: true }; projects.projectVersions = v; return onDone(v); }; lastVersions = projects.projectVersions; if ((lastVersions != null && lastVersions.loadFailed) || (lastVersions != null && lastVersions.isLocal)) { lastVersions = undefined; } if (local) { return finish({ isLocal: true }); } else if (lastVersions) { return onDone(lastVersions); } else if (offline) { return get(); } else { return load(); } }; })(); init/projects/loadProjects/calcEnvironment/getProjectVersions/get/get.ls (function(){ return function(p){ return inc("../../../loadProject/loadProject/_shared/rf/rf")("_projectVersions", function(c){ var r; try { r = JSON.parse(c); } catch (e$) {} if (r != null && r.projects) { return p.onDone(r); } else { return p.onError(); } }); }; })(); init/projects/loadProjects/calcEnvironment/getProjectVersions/load/load.ls (function(){ return function(p){ var url, that, d, timeoutDone, load, onError, onTimeout, onLoaded, timeout; url = app.contentServer + "/files/?fileId=projectVersions"; if (engine.isDebug) { url += "/debug"; } if (that = Store("projectVersionsHistoryDate")) { alert("starting with projectVersionsHistoryDate set to " + that); d = that; d = d.split("–").join("-"); url += "/" + d; } timeoutDone = false; load = function(){ var xhr; xhr = new XMLHttpRequest(); xhr.open("get", url); xhr.send(); xhr.onload = function(){ return trySafe(function(){ return onLoaded(xhr.response); }); }; return xhr.onerror = function(){ return trySafe(function(){ return onError(); }); }; }; onError = function(){ var that; if (that = Store("projectVersionsHistoryDate")) { alert("projectVersions load error for: " + that); } return p.onError(); }; onTimeout = function(){ timeoutDone = true; return p.onError(); }; onLoaded = function(r){ clearTimeout(timeout); try { r = JSON.parse(r); } catch (e$) {} if (!(r != null && r.projects)) { if (!timeoutDone) { p.onError(); } return; } r["dow" + "nloa" + "dedAt"] = new Date().toISOString(); inc("../../../loadProject/loadProject/_shared/sf/sf")("_projectVersions", JSON.stringify(r)); if (!timeoutDone) { return p.onDone(r); } }; load(); return timeout = setTimeout(onTimeout, 5000); }; })(); init/projects/loadProjects/calcEnvironment/overwritePrebundleVersions/overwrite.ls (function(){ return function(env){ var project, ref$, preVersion, pv, results$ = []; for (project in ref$ = env.prebundleVersions) { preVersion = ref$[project]; pv = env.projectVersions[project]; if (pv == null) { pv = { master: preVersion }; results$.push(env.projectVersions[project] = pv); } else if (env.local) { results$.push(pv.master = preVersion); } else if (pv.master < preVersion) { results$.push(pv.master = preVersion); } } return results$; }; })(); init/projects/loadProjects/calcResultEvent/calc.ls (function(){ return function(projectDescriptions){ var projectsByStatus, i$, len$, pd, r, rSlim, key$, ref$, s, total, e; projectsByStatus = {}; for (i$ = 0, len$ = projectDescriptions.length; i$ < len$; ++i$) { pd = projectDescriptions[i$]; r = pd.result; rSlim = _.omit(r, ["status", "project", "logs"]); if (r.branch === "master") { delete rSlim.branch; } if (r.minVersion === 0) { delete rSlim.minVersion; } projectsByStatus[key$ = r.status] == null && (projectsByStatus[key$] = {}); projectsByStatus[r.status][r.project] = rSlim; } for (i$ = 0, len$ = (ref$ = ["latest", "local", "offline"]).length; i$ < len$; ++i$) { s = ref$[i$]; total = _.keys(projectsByStatus[s]).length; if (total > 0) { projectsByStatus[s] = total; } } return e = { event: "deviceDebugLoadProjects", projectsByStatus: projectsByStatus, engineVersion: engine.clientVersion, loadVersion: 20 }; }; })(); init/projects/loadProjects/load.ls (function(){ var loadProject, calcResultEvent; loadProject = inc("loadProject/load"); calcResultEvent = inc("calcResultEvent/calc"); return function(params){ var projectDescriptions, calcEnvironment, calcProjectDescriptions, loadProjects, onProjectDone; params.logResults == null && (params.logResults = true); params.maxAgeProjectVersions == null && (params.maxAgeProjectVersions = 10); projectDescriptions = null; calcEnvironment = function(){ return inc("calcEnvironment/calc")(params, calcProjectDescriptions); }; calcProjectDescriptions = function(environment){ var res$, i$, ref$, len$, pd, pd2; res$ = []; for (i$ = 0, len$ = (ref$ = params.projectDescriptions).length; i$ < len$; ++i$) { pd = ref$[i$]; pd2 = _.clone(pd); pd2.timeout == null && (pd2.timeout = params.timeout); pd2.debug == null && (pd2.debug = params.debug); pd2.reset == null && (pd2.reset = params.reset); pd2.onProjectDone = onProjectDone; pd2.environment = environment; res$.push(pd2); } projectDescriptions = res$; return loadProjects(); }; loadProjects = function(){ var i$, ref$, len$, pd, results$ = []; for (i$ = 0, len$ = (ref$ = projectDescriptions).length; i$ < len$; ++i$) { pd = ref$[i$]; results$.push(loadProject(pd, projectDescriptions)); } return results$; }; onProjectDone = function(pd){ var totalDone, totalErrors, resultEvent; totalDone = _.filter(projectDescriptions, { done: true }).length; totalErrors = _.filter(projectDescriptions, { error: true }).length; if (totalDone < projectDescriptions.length) { return; } resultEvent = calcResultEvent(projectDescriptions); if (params.logResults) { if (typeof deviceLog != 'undefined' && deviceLog !== null) { deviceLog.log(resultEvent); } } if (totalErrors === 0) { return params.onDone(projectDescriptions, resultEvent); } else { return params.onProjectMissingError(projectDescriptions, resultEvent); } }; return calcEnvironment(); }; })(); init/projects/loadProjects/loadProject/load.ls (function(){ var loadProject; loadProject = inc("loadProject/load"); return function(pd, projectDescriptions){ var load, waitForRequiredProjects, triggerInit, finish; load = function(){ return loadProject(pd, function(result){ if (_.startsWith(result.status, "failed")) { pd.error = true; return finish(); } else { return waitForRequiredProjects(); } }); }; waitForRequiredProjects = function(){ var i$, ref$, len$, project, pd2; for (i$ = 0, len$ = (ref$ = pd.required || []).length; i$ < len$; ++i$) { project = ref$[i$]; pd2 = _.find(projectDescriptions, { project: project }); if (pd2.error) { finish(); return; } else if (pd2.done !== true) { setTimeout(waitForRequiredProjects, 50); return; } } return triggerInit(); }; triggerInit = function(){ if (pd.init != null) { return pd.init(finish); } else { return finish(); } }; finish = function(){ return setTimeout(function(){ if (pd.done) { return; } pd.doneOffline = true; pd.doneUpdate = true; pd.done = true; return pd.onProjectDone(pd); }); }; return load(); }; })(); init/projects/loadProjects/loadProject/loadProject/_shared/df/app/app.ls (function(){ return function(f){ var filePath, fs, ref$; filePath = "project/" + f; fs = (ref$ = engine.fileSystem) != null ? ref$ : app.fileSystem; return fs.removeFile(filePath, function(){}); }; })(); init/projects/loadProjects/loadProject/loadProject/_shared/df/df.ls (function(){ var a, w; a = inc("app/app"); w = inc("web/web"); return function(f){ if (engine.isMobileApp) { return a(f); } else if (engine.cachesEnabled) { return w(f); } }; })(); init/projects/loadProjects/loadProject/loadProject/_shared/df/web/web.ls (function(){ return function(f){ var url; url = "http://project/" + f; return caches.open("project").then(function(cache){ return trySafe(function(){ return cache['delete'](url); }); }); }; })(); init/projects/loadProjects/loadProject/loadProject/_shared/pdo/parse/parse.ls (function(){ return function(s){ var headerLength, headerValues, pos, documents, values, i$, to$, i, j, length, key, e; if (!s) { return { parseError: "pdo empty" }; } headerLength = +s.substr(0, s.indexOf(",")); headerValues = s.substr(0, headerLength - 1).split(","); pos = headerLength; documents = {}; values = []; for (i$ = 1, to$ = headerValues.length - 1; i$ <= to$; ++i$) { i = i$; j = (i - 1) % 2; length = +headerValues[i]; if (j === 0) { key = s.substr(pos, length - 1); } if (j === 1) { documents[key] = { text: s.substr(pos, length - 1) }; } pos += length; } if (pos !== s.length) { return { parseError: "wrong pdo length, " + pos + ", " + s.length }; } try { documents._info = JSON.parse(documents._info.text); } catch (e$) { e = e$; return { parseError: "_info parse failed" }; } return documents; }; })(); init/projects/loadProjects/loadProject/loadProject/_shared/pdo/stringify/stringify.ls (function(){ return function(documents){ var content, positions, info, k, d, positionsString, headerLength, digits, s; content = ""; positions = []; info = documents._info; documents._info = { text: JSON.stringify(info) }; positions = []; for (k in documents) { d = documents[k]; content += k + "\n"; positions.push(k.length + 1); content += d.text + "\n"; positions.push(d.text.length + 1); } documents._info = info; positionsString = positions.join(","); headerLength = positionsString.length + 2; digits = ("" + headerLength).length; if (("" + (headerLength + digits)).length > digits) { digits++; } headerLength += digits; return s = headerLength + "," + positionsString + "\n" + content; }; })(); init/projects/loadProjects/loadProject/loadProject/_shared/rf/app/app.ls (function(){ return function(fileName, onDone){ var f, fs, ref$; f = "project/" + fileName; fs = (ref$ = engine.fileSystem) != null ? ref$ : app.fileSystem; return fs.readFile(f, function(error, result){ return trySafe(function(){ return onDone(result != null ? result.data : void 8); }); }); }; })(); init/projects/loadProjects/loadProject/loadProject/_shared/rf/rf.ls (function(){ var a, w; a = inc("app/app"); w = inc("web/web"); return function(f, onDone){ if (engine.isMobileApp) { return a(f, onDone); } else if (engine.cachesEnabled) { return w(f, onDone); } else { return onDone(); } }; })(); init/projects/loadProjects/loadProject/loadProject/_shared/rf/web/web.ls (function(){ return function(fileName, onDone){ var path; path = "http://project/" + fileName; return caches.open("project").then(function(cache){ return trySafe(function(){ return cache.match(path); }); }).then(function(response){ return trySafe(function(){ return response.text(); }); }).then(function(documents){ return trySafe(function(){ return onDone(documents); }); })['catch'](function(){ return trySafe(function(){ return onDone(); }); }); }; })(); init/projects/loadProjects/loadProject/loadProject/_shared/sf/app/app.ls (function(){ return function(f, c, onDone){ var filePath, filePathTemp, fs, ref$, removeTempFile, writeTempFile, onWriteDone, removeFile, replaceCurrentFile, finish; filePath = "project/" + f; filePathTemp = filePath + "_tmp"; fs = (ref$ = engine.fileSystem) != null ? ref$ : app.fileSystem; removeTempFile = function(){ return fs.removeFile(filePathTemp, writeTempFile); }; writeTempFile = function(){ return trySafe(function(){ return fs.writeFile(filePathTemp, c, 0, onWriteDone); }); }; onWriteDone = function(error){ return trySafe(function(){ var e, ref$; if (error) { e = { event: "deviceDebugProjectW" + "riteError", filePath: filePath, error: error }; if ((ref$ = window.deviceLog) != null && ref$.log) { deviceLog.log(e); } else { helpers.postEvent(Store("deviceLogId"), e); } return typeof onDone == 'function' ? onDone(f, error) : void 8; } else { return removeFile(); } }); }; removeFile = function(){ return trySafe(function(){ return fs.removeFile(filePath, replaceCurrentFile); }); }; replaceCurrentFile = function(){ return trySafe(function(){ return fs.moveFile(filePathTemp, filePath, finish); }); }; finish = function(){ return trySafe(function(){ return typeof onDone == 'function' ? onDone(f) : void 8; }); }; return removeTempFile(); }; })(); init/projects/loadProjects/loadProject/loadProject/_shared/sf/sf.ls (function(){ var a, w; a = inc("app/app"); w = inc("web/web"); return function(f, c, d){ var onDone; projects.activeStoreJobs == null && (projects.activeStoreJobs = {}); projects.activeStoreJobs[f] = new Date(); onDone = function(f, error){ var ref$; if ((ref$ = projects.activeStoreJobs) != null) { delete ref$[f]; } if (_.keys(projects.activeStoreJobs).length === 0) { delete projects.activeStoreJobs; } return typeof d == 'function' ? d(f, error) : void 8; }; if (engine.isMobileApp) { return a(f, c, onDone); } else if (engine.cachesEnabled) { return w(f, c, onDone); } else { return typeof onDone == 'function' ? onDone() : void 8; } }; })(); init/projects/loadProjects/loadProject/loadProject/_shared/sf/web/web.ls (function(){ return function(f, c, onDone){ var url, response; url = "http://project/" + f; response = new Response(c); return caches.open("project").then(function(cache){ return trySafe(function(){ return cache.put(url, response); }); }).then(function(){ return trySafe(function(){ return typeof onDone == 'function' ? onDone(f) : void 8; }); }); }; })(); init/projects/loadProjects/loadProject/loadProject/apply/apply.ls (function(){ return function(p, mode){ return new Promise(function(resolve){ var s, u, i, iOld, ref$, documents, total, k, d, i$, ref1$, len$, key; s = p.settings; u = mode === "u" ? p.u : mode === "fu" ? p.fu : void 8; if (!u) { resolve(); return; } i = u._info; iOld = (ref$ = p.infoOld) != null ? ref$ : {}; if (iOld.versionDate >= i.versionDate && iOld.version === i.version) { p.log("unchanged " + mode); resolve(); return; } documents = i.reset ? {} : p.documents; total = -1; for (k in u) { d = u[k]; documents[k] = d; total++; } for (i$ = 0, len$ = (ref$ = (ref1$ = i.deletedDocuments) != null ? ref1$ : []).length; i$ < len$; ++i$) { key = ref$[i$]; delete p.documents[key]; } documents._info = _.omit(i, ["deletedDocuments", "fromVersion"]); p.log("apply " + mode + " " + i.version + "/" + i.fromVersion + " (" + (i.reset ? 'reset' : total + ' docs') + ")"); p["applied_" + mode] = true; p.documents = documents; return resolve(); }); }; })(); init/projects/loadProjects/loadProject/loadProject/calcSettings/calc.ls (function(){ var calcFVersion, calcFUVersion; calcFVersion = inc("calcFVersion/calc"); calcFUVersion = inc("calcFUVersion/calc"); return function(p){ var c, s, ref$, i, ref1$, that, ref2$, lv; c = helpers.resolveProject(p.project); s = {}; s.project = p.project; s.branch = (ref$ = p.branch) != null ? ref$ : c.branch; s.server = (ref$ = p.server) != null ? ref$ : c.server; if (s.branch !== "master" && _.includes(s.server, "ide") && !_.endsWith(s.branch, "_ide")) { s.branch += "_ide"; } i = (ref$ = (ref1$ = projects.documentCache[p.project]) != null ? ref1$._info : void 8) != null ? ref$ : {}; if (i.branch === s.branch) { s.mVersion = i.version; } if (that = calcFVersion(p, s)) { s.fVersion = that; } if (s.branch === "master") { if (that = (ref$ = p.environment.prebundleVersions) != null ? ref$[s.project] : void 8) { s.pVersion = that; } } s.hVersion = Math.max((ref2$ = s.mVersion) != null ? ref2$ : 0, (ref2$ = s.fVersion) != null ? ref2$ : 0, (ref2$ = s.pVersion) != null ? ref2$ : 0); if (that = calcFUVersion(p, s)) { s.fuVersion = that; } lv = (ref2$ = p.environment.projectVersions[s.project]) != null ? ref2$ : {}; if (that = lv[s.branch]) { s.lVersion = that; } else { s.lVersion = "latest"; } s.minVersion = Math.max((ref2$ = p.minVersion) != null ? ref2$ : 0, (ref2$ = lv[s.branch + "Min"]) != null ? ref2$ : 0); if (p.local && s.pVersion != null) { s.lVersion = s.pVersion; s.hVersion = s.pVersion; delete s.fuVersion; delete s.fVersion; } return s; }; })(); init/projects/loadProjects/loadProject/loadProject/calcSettings/calcFUVersion/calc.ls (function(){ var df; df = inc("../../_shared/df/df"); return function(p, s){ var project, i$, ref$, len$, fn, a, t, f; project = p.engineStart ? s.project + "_engineStart" : s.project; for (i$ = 0, len$ = (ref$ = p.environment.fileNames).length; i$ < len$; ++i$) { fn = ref$[i$]; a = fn.split("!"); if (a[0] === project && a[1] === s.branch && a.length === 4) { t = +a[2]; f = +a[3]; if (f === s.hVersion) { return t; } else { df(fn); } } } }; })(); init/projects/loadProjects/loadProject/loadProject/calcSettings/calcFVersion/calc.ls (function(){ return function(p, s){ var i$, ref$, len$, fn, a, v; for (i$ = 0, len$ = (ref$ = p.environment.fileNames).length; i$ < len$; ++i$) { fn = ref$[i$]; a = fn.split("!"); if (a[0] === s.project && a[1] === s.branch && a.length === 3) { v = +a[2]; return v; } } }; })(); init/projects/loadProjects/loadProject/loadProject/getDocuments/get.ls (function(){ var getFVersion, getPVersion; getFVersion = inc("getFVersion/get"); getPVersion = inc("getPVersion/get"); return function(p){ return new Promise(function(resolve, reject){ var s, get, finish; s = p.settings; get = function(){ var documents; if (s.hVersion === 0) { p.log("get d 0"); documents = {}; return finish(documents); } else if (s.mVersion === s.hVersion) { p.log("get d m " + s.mVersion); documents = _.clone(projects.documentCache[s.project]); return finish(documents); } else if (s.fVersion === s.hVersion) { p.log("get d f " + s.fVersion); return getFVersion(p, finish); } else if (s.pVersion === s.hVersion) { p.log("get d p " + s.pVersion); return getPVersion(p, finish); } }; finish = function(documents){ var that, ref$; if (that = documents.parseError) { return reject(that); } else { p.documents = documents; p.infoOld == null && (p.infoOld = (ref$ = p.documents) != null ? ref$._info : void 8); return resolve(); } }; return get(); }); }; })(); init/projects/loadProjects/loadProject/loadProject/getDocuments/getFVersion/get.ls (function(){ var rf, parse; rf = inc("../../_shared/rf/rf"); parse = inc("../../_shared/pdo/parse/parse"); return function(p, onDone){ var s, f; s = p.settings; f = s.project + "!" + s.branch + "!" + s.fVersion; return rf(f, function(r){ var documents; documents = parse(r); return onDone(documents); }); }; })(); init/projects/loadProjects/loadProject/loadProject/getDocuments/getPVersion/get.ls (function(){ var parse; parse = inc("../../_shared/pdo/parse/parse"); return function(p, onDone){ var s, load, onError, onLoaded; s = p.settings; load = function(){ var xhr; xhr = new XMLHttpRequest(); xhr.open("get", "projects/" + s.project); xhr.onload = function(){ return trySafe(function(){ return onLoaded(xhr.response); }); }; xhr.onerror = function(){ return trySafe(function(){ return onError(); }); }; return xhr.send(); }; onError = function(){ return onDone({ parseError: "prebundle load error" }); }; onLoaded = function(r){ var documents; documents = parse(r); return onDone(documents); }; return load(); }; })(); init/projects/loadProjects/loadProject/loadProject/getFU/get.ls (function(){ var rf, df, parse; rf = inc("../_shared/rf/rf"); df = inc("../_shared/df/df"); parse = inc("../_shared/pdo/parse/parse"); return function(p){ return new Promise(function(resolve){ var s, project, f; s = p.settings; if (!s.fuVersion) { resolve(); return; } project = p.engineStart ? s.project + "_engineStart" : s.project; f = project + "!" + s.branch + "!" + s.fuVersion + "!" + s.hVersion; p.log("get fu " + s.fuVersion + "/" + s.hVersion); return rf(f, function(r){ if (r) { p.fu = parse(r); df(f); } return resolve(); }); }); }; })(); init/projects/loadProjects/loadProject/loadProject/getU/get.ls (function(){ var loadShared, parse, store; loadShared = inc("load/load"); parse = inc("../_shared/pdo/parse/parse"); store = inc("storeFU/store"); return function(p){ return new Promise(function(resolve){ var s, l, f, ref$, timeoutDuration, timeoutDone, load, onLoaded, onTimeout, onError, timeout; s = p.settings; l = s.lVersion; f = Math.max(s.hVersion, (ref$ = s.fuVersion) != null ? ref$ : 0); timeoutDuration = +p.timeout.split(",")[f === 0 ? 0 : 1]; timeoutDone = false; load = function(){ var fileId, server, url; fileId = "project/" + s.project + "!" + s.branch + "!" + l + "!" + f; server = _.endsWith(s.branch, "ide") ? "https://apis-content.solocode.com" : p.reset ? app.contentServerFallback : app.contentServer; url = server + "/files/?fileId=" + fileId; return loadShared({ url: url, onLoaded: onLoaded, onError: onError }); }; onLoaded = function(r){ var documents, that; clearTimeout(timeout); documents = parse(r); if (that = documents.parseError) { p.log("u parseError " + that); p.offline = true; resolve(); return; } documents._info["vers" + "ionDow" + "nload" + "edAt"] = new Date().toISOString(); if (timeoutDone) { return setTimeout(function(){ return store(p, documents); }); } else { p.u = documents; return resolve(); } }; onTimeout = function(){ p.log("get u timeout(" + timeoutDuration + "s)"); p.timeoutTriggered = true; timeoutDone = true; return resolve(); }; onError = function(){ p.offline = true; return resolve(); }; if (l === f || p.local || p.offline) { return resolve(); } else { p.log("get u " + l + "/" + f); load(); return timeout = setTimeout(onTimeout, timeoutDuration * 1000); } }); }; })(); init/projects/loadProjects/loadProject/loadProject/getU/load/load.ls (function(){ return function(p){ var url, xhr, ref$, callbacks, ref1$; url = p.url; xhr = (ref$ = projects.activeRequests) != null ? ref$[url] : void 8; callbacks = function(functions, o){ return trySafe(function(){ var ref$, i$, ref1$, len$, results$ = []; if ((ref$ = projects.activeRequests) != null) { delete ref$[url]; } if (_.keys(projects.activeRequests).length === 0) { delete projects.activeRequests; } for (i$ = 0, len$ = (ref1$ = functions).length; i$ < len$; ++i$) { results$.push((fn$.call(this, ref1$[i$]))); } return results$; function fn$(f){ return setTimeout(function(){ return f(o); }); } }); }; if (xhr) { xhr.customOnLoaded.push(p.onLoaded); return xhr.customOnError.push(p.onError); } else { xhr = new XMLHttpRequest(); xhr.onload = function(){ return callbacks(xhr.customOnLoaded, xhr.response); }; xhr.onerror = function(){ return callbacks(xhr.customOnError); }; xhr.customOnLoaded = [p.onLoaded]; xhr.customOnError = [p.onError]; xhr.open("get", url); xhr.send(); projects.activeRequests == null && (projects.activeRequests = {}); return (ref1$ = projects.activeRequests) != null ? ref1$[url] = xhr : void 8; } }; })(); init/projects/loadProjects/loadProject/loadProject/getU/storeFU/clean/clean.ls (function(){ var df; df = inc("../../../_shared/df/df"); return function(p, f){ var a, i$, ref$, len$, fn, results$ = []; a = f.split("!"); for (i$ = 0, len$ = (ref$ = p.environment.fileNames).length; i$ < len$; ++i$) { fn = ref$[i$]; if (_.startsWith(fn, a[0] + "!" + a[1] + "!") && fn.split("!").length === 4 && fn !== f) { results$.push(df(fn)); } } return results$; }; })(); init/projects/loadProjects/loadProject/loadProject/getU/storeFU/store.ls (function(){ var sf, clean, stringify; sf = inc("../../_shared/sf/sf"); clean = inc("clean/clean"); stringify = inc("../../_shared/pdo/stringify/stringify"); return function(p, documents){ var i, project, f, c; i = documents._info; project = p.engineStart ? i.project + "_engineStart" : i.project; f = project + "!" + i.branch + "!" + i.version + "!" + i.fromVersion; c = stringify(documents); return sf(f, c, function(){ return clean(p, f); }); }; })(); init/projects/loadProjects/loadProject/loadProject/load.ls (function(){ var log, calcSettings, reset, getDocuments, getFU, getU, apply, validate, rollout, load; log = inc("log/log"); calcSettings = inc("calcSettings/calc"); reset = inc("reset/reset"); getDocuments = inc("getDocuments/get"); getFU = inc("getFU/get"); getU = inc("getU/get"); apply = inc("apply/apply"); validate = inc("validate/validate"); rollout = inc("rollout/rollout"); return load = function(p, onDone){ var s; p.startedAt = new Date(); p.offline == null && (p.offline = p.environment.offline); p.local == null && (p.local = p.environment.local); p.timeout == null && (p.timeout = "15,10"); p.log == null && (p.log = log(p)); p.documents = {}; s = calcSettings(p); p.settings = s; if (p.reset) { p.log("manual reset"); reset(p); } else if (s.hVersion < s.minVersion) { p.log("minVersion reset (" + s.hVersion + "<" + s.minVersion + ")"); reset(p); } return Promise.all([getDocuments(p), getFU(p), getU(p)]).then(function(){ return apply(p, "fu"); }).then(function(){ return apply(p, "u"); }).then(function(){ return validate(p); }).then(function(){ return rollout(p, onDone); })['catch'](function(e){ e = e.message || e; p.log("reset " + e); if (!p.reset) { p.comment = e; p.reset = true; return inc(THISFILE)(p, onDone); } else { p.comment += ", " + e; p.doubleReset = true; return rollout(p, onDone); } }); }; })(); init/projects/loadProjects/loadProject/loadProject/log/log.ls (function(){ return function(p){ p.logs = []; return p.log = function(o){ if (p.debug) { debug(o); } return p.logs.push(o); }; }; })(); init/projects/loadProjects/loadProject/loadProject/reset/reset.ls (function(){ return function(p){ var s, i$, ref$, len$, n; s = p.settings; for (i$ = 0, len$ = (ref$ = ["mVersion", "fVersion", "pVersion", "fuVersion"]).length; i$ < len$; ++i$) { n = ref$[i$]; delete s[n]; } s.hVersion = 0; for (i$ = 0, len$ = (ref$ = ["u", "fu", "infoOld", "applied_u", "applied_fu", "timeoutTriggered"]).length; i$ < len$; ++i$) { n = ref$[i$]; delete p[n]; } p.local = false; return p.reset = true; }; })(); init/projects/loadProjects/loadProject/loadProject/rollout/calcResult/calc.ls (function(){ return function(p){ var s, i, ref$, iOld, r, i$, len$, n, that; s = p.settings; i = (ref$ = p.documents._info) != null ? ref$ : {}; iOld = (ref$ = p.infoOld) != null ? ref$ : {}; r = {}; for (i$ = 0, len$ = (ref$ = ["project", "branch"]).length; i$ < len$; ++i$) { n = ref$[i$]; r[n] = s[n]; } for (i$ = 0, len$ = (ref$ = ["version", "versionDate", "versionDo" + "wnload" + "edAt", "checksumDocs"]).length; i$ < len$; ++i$) { n = ref$[i$]; if (that = i[n]) { r[n] = that; } } if (p.applied_fu || p.applied_u) { r.prevVersion = (ref$ = iOld.version) != null ? ref$ : 0; if (that = iOld.versionDate) { r.prevVersionDate = that; } if (that = iOld.checksumDocs) { r.prevChecksumDocs = that; } if (i.reset) { r.resetDocs = true; } } r.minVersion = s.minVersion; r.duration = new Date() - p.startedAt; r.logs = p.logs; r.status = p.doubleReset ? "failed_doublereset" : i.version < s.minVersion ? "failed_minversion" : !i.version ? p.offline ? "failed_offline" : p.timeoutTriggered ? "failed_timeout" : "failed_unknown" : p.local ? "local" : p.offline ? "offline" : !p.applied_fu && !p.applied_u && !p.timeoutTriggered ? "latest" : p.applied_fu && p.applied_u ? "fupd_upd" : p.applied_fu && p.timeoutTriggered ? "fupd_timeout" : p.applied_fu ? "fupd" : p.applied_u ? "upd" : p.timeoutTriggered ? "timeout" : "unknown"; if (p.reset && !p.doubleReset) { r.status += "_after_reset"; } if (that = p.comment) { r.comment = that; } return r; }; })(); init/projects/loadProjects/loadProject/loadProject/rollout/clean/clean.ls (function(){ var df; df = inc("../../_shared/df/df"); return function(p, fileName){ var i, i$, ref$, len$, fn, results$ = []; i = p.documents._info; for (i$ = 0, len$ = (ref$ = p.environment.fileNames).length; i$ < len$; ++i$) { fn = ref$[i$]; if (_.startsWith(fn, i.project + "!" + i.branch + "!") && fn !== fileName) { results$.push(df(fn)); } } return results$; }; })(); init/projects/loadProjects/loadProject/loadProject/rollout/resetIncludeCache/reset.ls (function(){ return function(project){ var c, i$, ref$, o, k, results$ = []; c = projects.includeCache[project]; if (!c) { return projects.includeCache[project] = {}; } else { for (i$ in ref$ = c._localCaches) { o = ref$[i$]; for (k in o) { delete o[k]; } } for (k in c) { if (k !== "_localCaches") { results$.push((ref$ = c[k], delete c[k], ref$)); } } return results$; } }; })(); init/projects/loadProjects/loadProject/loadProject/rollout/rollout.ls (function(){ var calcResult, store, clean, resetIncludeCache; calcResult = inc("calcResult/calc"); store = inc("store/store"); clean = inc("clean/clean"); resetIncludeCache = inc("resetIncludeCache/reset"); return function(p, onDone){ var s; s = p.settings; if (p.documents._info && !p.doubleReset) { projects.documentCache[p.project] = p.documents; resetIncludeCache(p.project); if (p.applied_fu || p.applied_u) { setTimeout(function(){ return store(p, function(f){ return clean(p, f); }); }); } } p.result = calcResult(p); return onDone(p.result); }; })(); init/projects/loadProjects/loadProject/loadProject/rollout/store/store.ls (function(){ var sf, stringify; sf = inc("../../_shared/sf/sf"); stringify = inc("../../_shared/pdo/stringify/stringify"); return function(p, d){ var i, f, c; i = p.documents._info; f = i.project + "!" + i.branch + "!" + i.version; c = stringify(p.documents); p.log("st" + 'ore' + " " + f); return setTimeout(function(){ return sf(f, c, d); }); }; })(); init/projects/loadProjects/loadProject/loadProject/validate/validate.ls (function(){ return function(p){ return new Promise(function(resolve, reject){ var s, i, ref$, c, totalFiles, totalLength, k, d, c2; s = p.settings; i = (ref$ = p.documents._info) != null ? ref$ : {}; c = i.checksumDocs; if (c) { totalFiles = 0; totalLength = 0; for (k in ref$ = p.documents) { d = ref$[k]; if (k === "_info") { continue; } totalFiles++; totalLength += k.length; totalLength += d.text.length; } c2 = totalFiles + "-" + totalLength; if (c2 !== c) { reject(Error("invalid checksumDocs: " + c2)); return; } } return resolve(); }); }; })(); init/projects/unload/unload.ls (function(){ return function(o, c){ var p; p = o.project || o; delete projects.documentCache[p]; return typeof c == 'function' ? c() : void 8; }; })(); init/restartFrozenPage/restart.ls (function(){ return function(){ var p, i, ref$, url, xhr; if (engine.isMobileApp) { return; } p = "app01-engine-start"; i = (ref$ = projects.documentCache[p]) != null ? ref$._info : void 8; url = app.contentServer + "/files/?fileId=project/app01-engine-start!" + i.branch + "!latest!0"; xhr = new XMLHttpRequest(); xhr.onreadystatechange = function(){ var v1, v2; if (xhr.readyState === 4) { v1 = +i.version; v2 = +xhr.getResponseHeader("anton-version"); if (v1 > 0 && v2 > 0 && v1 !== v2) { return location.reload(); } } }; xhr.open("HEAD", url); return xhr.send(); }; })(); init/startCustom/start.ls (function(){ return function(){ if (window.startCustom != null) { window.startCustom(inc); return true; } }; })(); init/startLandingPage/start.ls (function(){ return function(){ var p; if (!_.includes(location.href, "/lp/")) { return; } projects.loadProjects({ projectDescriptions: (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = ["landing-page", "color", "extended-dom-element"]).length; i$ < len$; ++i$) { p = ref$[i$]; results$.push({ project: p, timeout: "60, 60", logResults: false }); } return results$; }()), onProjectMissingError: function(projectDescriptions, resultEvent){ return debug("onProjectMissingError", resultEvent); }, onDone: function(projectDescriptions, resultEvent){ return inc("/../landing-page/init")(); } }); return true; }; })(); init/store/Store/Store.ls (function(){ return function(key, value){ var l, k, v; l = arguments.length; Store.multiWindowFix(); if (l === 0) { return Store.getAllItems(); } else if (l === 1 && _.isString(key)) { return Store.getItem(key); } else if (l === 2 && _.isString(key)) { if (value !== Store.data[key]) { Store.setItem(key, value); Store.save(); } } else if (l === 1 && _.isPlainObject(key)) { for (k in key) { v = key[k]; Store.setItem(k, v); } Store.save(); } else { throw Error("invalid Store arguments"); } }; })(); init/store/backup/load/_verify/verify.ls (function(){ return function(data){ if (!data) { return false; } return _.startsWith(data.deviceLogId, "D-") && data.sourceId != null && new Date(data.savedAt) > 0; }; })(); init/store/backup/load/app/app.ls (function(){ return function(callback){ var loadNew, loadOld; loadNew = function(){ return engine.fileSystem.readFile(Store.backupPath, function(err, res){ var data; try { data = JSON.parse(res.data); } catch (e$) {} if (data) { return callback(data); } else { return loadOld(); } }); }; loadOld = function(){ return engine.fileSystem.readFile("localStorageSave/localStorage.json", function(err, res){ var data, k, v; try { data = JSON.parse(res.data); } catch (e$) {} if (data) { for (k in data) { v = data[k]; data[k] = JSON.parse(v); } if (data != null) { data.savedAt == null && (data.savedAt = new Date("2000-01-01").toISOString()); } } setTimeout(function(){ return engine.fileSystem.removeDir("localStorageSave"); }); return callback(data); }); }; return loadNew(); }; })(); init/store/backup/load/load.ls (function(){ return function(callback){ var load, verify; load = function(){ if (engine.isMobileApp) { return inc("app/app")(verify); } else if (engine.cachesEnabled) { return inc("web/web")(verify); } else { return callback(); } }; verify = function(data){ var isOk; isOk = inc("_verify/verify")(data); if (isOk) { return callback(data); } else { return callback(); } }; return load(); }; })(); init/store/backup/load/web/web.ls (function(){ return function(cb){ var folder, url; folder = Store.backupPath.split("/")[0]; url = "http://" + Store.backupPath; return caches.open(folder).then(function(cache){ return trySafe(function(){ return cache.match(url); }); }).then(function(response){ return trySafe(function(){ return response.json(); }); }).then(function(data){ return trySafe(function(){ return setTimeout(function(){ return cb(data); }); }); })['catch'](function(){ return trySafe(function(){ return setTimeout(function(){ return cb(); }); }); }); }; })(); init/store/backup/save/app/app.ls (function(){ return function(done){ var content; content = JSON.stringify(Store()); return app.fileSystem.writeFile(Store.backupPath, content, 0, function(err, res){ if (error) { return Store.logEvent({ event: "deviceDebugStoreSaveFileError", error: err.message }); } }); }; })(); init/store/backup/save/save.ls (function(){ return function(){ if (engine.isMobileApp) { return inc("app/app")(); } else if (engine.cachesEnabled) { return inc("web/web")(); } }; })(); init/store/backup/save/web/web.ls (function(){ return function(){ var folder, url, content, res, cache; folder = Store.backupPath.split("/")[0]; url = "http://" + Store.backupPath; content = JSON.stringify(Store()); res = new Response(content); cache = null; return caches.open(folder).then(function(c){ cache = c; return cache['delete'](url); }).then(function(){ return cache.put(url, res)['catch'](function(err){ if (_.includes(err.message, "exists")) { return cache['delete'](url).then(cache.put(url, res)); } else { throw err; } }); })['catch'](function(err){ return Store.logEvent({ event: "deviceDebugStoreSaveCachesError", error: err.message }); }); }; })(); init/store/clear/clear.ls (function(){ return function(){ Store.data = {}; try { if (typeof localStorage != 'undefined' && localStorage !== null) { if (typeof localStorage.clear == 'function') { localStorage.clear(); } } } catch (e$) {} Store.save(); }; })(); init/store/init.ls (function(){ return function(done){ var s; if (engine.isMobileApp) { done(); return; } s = inc("Store/Store"); s.version = 2; s.remove = inc("item/remove/remove"); s.clear = inc("clear/clear"); s.isFake = true; s.data = {}; s.backupPath = "store/backup.json"; s.init = inc("init/init"); s.setItem = inc("item/set/set"); s.getItem = inc("item/get/get"); s.getAllItems = inc("item/getAll/get"); s.save = inc("save/save"); s.syncLocalStorage = inc("localStorage/sync/sync"); s.loadLocalStorage = inc("localStorage/load/load"); s.saveBackup = inc("backup/save/save"); s.loadBackup = inc("backup/load/load"); s.multiWindowFix = inc("multiWindowFix/fix"); s.logEvent = inc("logEvent/log"); s.originalStore = window.Store; window.Store = s; return Store.init(done); }; })(); init/store/init/init.ls (function(){ return function(done){ var local, backup, loadLocalStorage, loadBackup, decide, finish; local = undefined; backup = undefined; loadLocalStorage = function(){ local = Store.originalStore(); return loadBackup(); }; loadBackup = function(){ return Store.loadBackup(function(b){ backup = b; return decide(); }); }; decide = function(){ var backupAt, localAt; backupAt = backup != null ? backup.savedAt : void 8; localAt = local != null ? local.savedAt : void 8; if (!backupAt) { return finish(local); } else if (local.isSaved && !localAt) { return finish(local); } else if (!localAt) { return finish(backup, true); } else if (backupAt === localAt) { return finish(local); } else if (backupAt < localAt) { return finish(local); } else { return finish(backup, true); } }; finish = function(data, logEvent){ Store.data = data; if (logEvent) { Store.logEvent({ event: "deviceDebugStoreRepaired", local: local, backup: backup }); } Store.save(); return setTimeout(function(){ return typeof done == 'function' ? done() : void 8; }); }; loadLocalStorage(); }; })(); init/store/item/get/get.ls (function(){ return function(key){ return _.cloneDeep(Store.data[key]); }; })(); init/store/item/getAll/get.ls (function(){ return function(){ return _.cloneDeep(Store.data); }; })(); init/store/item/remove/remove.ls (function(){ return function(key){ Store.multiWindowFix(); if (!key || Store.data[key] == null) { return; } delete Store.data[key]; try { if (typeof localStorage != 'undefined' && localStorage !== null) { if (typeof localStorage.removeItem == 'function') { localStorage.removeItem(key); } } } catch (e$) {} Store.save(); }; })(); init/store/item/set/set.ls (function(){ return function(key, value){ Store.data[key] = value; try { if (typeof localStorage != 'undefined' && localStorage !== null) { if (typeof localStorage.setItem == 'function') { localStorage.setItem(key, JSON.stringify(value)); } } } catch (e$) {} return value; }; })(); init/store/localStorage/load/load.ls (function(){ return function(){ var data, i$, to$, i, key, value, e, err; data = {}; try { for (i$ = 0, to$ = localStorage.length - 1; i$ <= to$; ++i$) { i = i$; key = localStorage.key(i); if (!key) { continue; } value = localStorage.getItem(key); value = (fn$()); data[key] = value; } } catch (e$) { err = e$; Store.logEvent({ event: "deviceDebugStoreLocalLoadError", error: err.message }); } return data; function fn$(){ try { return JSON.parse(value); } catch (e$) { e = e$; return value; } } }; })(); init/store/localStorage/sync/sync.ls (function(){ return function(){ var sync, err; sync = function(){ var key, ref$, value, jsonValue, localValue, e, results$ = []; for (key in ref$ = Store.data) { value = ref$[key]; jsonValue = JSON.stringify(value); localValue = localStorage.getItem(key); if (localValue === null) { localValue = undefined; } if (jsonValue !== localValue) { try { results$.push(localStorage.setItem(key, jsonValue)); } catch (e$) { e = e$; localStorage.removeItem(key); results$.push(localStorage.setItem(key, jsonValue)); } } } return results$; }; try { return sync(); } catch (e$) { err = e$; try { localStorage.clear(); } catch (e$) {} try { return sync(); } catch (e$) { err = e$; return Store.logEvent({ event: "deviceDebugStoreLocalSyncError", error: err.message }); } } }; })(); init/store/logEvent/log.ls (function(){ return function(event){ var ref$, ref1$, ref2$; event.userAgent = navigator.userAgent; if (Store("debug")) { console.log(event); } Store.totalLoggedError == null && (Store.totalLoggedError = 0); Store.totalLoggedError += 1; if (Store.totalLoggedError >= 3) { return; } if ((ref$ = window.deviceLog) != null && ref$.log) { return deviceLog.log(event); } else { return helpers.postEvent((ref1$ = (ref2$ = Store.data) != null ? ref2$.deviceLogId : void 8) != null ? ref1$ : "INT-Store", event); } }; })(); init/store/multiWindowFix/calcHasChanged/calc.ls (function(){ return function(a, b){ var key, j1, j2; for (key in a) { if (key === "savedAt") { continue; } j1 = JSON.stringify(a[key]); j2 = JSON.stringify(b[key]); if (j1 !== j2) { return true; } } return false; }; })(); init/store/multiWindowFix/fix.ls (function(){ return function(){ var memoryAt, localAt, hasChanged, dataOld; memoryAt = Store.data.savedAt; try { localAt = JSON.parse(typeof localStorage != 'undefined' && localStorage !== null ? typeof localStorage.getItem == 'function' ? localStorage.getItem("savedAt") : void 8 : void 8); } catch (e$) {} if (localAt > memoryAt && new Date(localAt) > 0) { hasChanged = inc("calcHasChanged/calc")(Store.data, Store.loadLocalStorage()); dataOld = Store.data; Store.data = Store.loadLocalStorage(); if (hasChanged && !_.includes(navigator.userAgent, "Headless")) { return Store.logEvent({ event: "deviceDebugStoreMultiWindowFix", memoryAt: memoryAt, localAt: localAt, dataOld: dataOld, dataNew: Store.data }); } } }; })(); init/store/save/save.ls (function(){ var save, saveDebounced; save = function(){ Store.syncLocalStorage(); return Store.saveBackup(); }; saveDebounced = _.debounce(save, 200); return function(){ Store.setItem("savedAt", new Date().toISOString()); saveDebounced(); }; })(); init/trySafe/trySafe.ls (function(){ return function(){ return window.trySafe = engine.isiOsApp ? function(f){ var e; try { return f(); } catch (e$) { e = e$; return helpers.errorHandler(e.message, e.file, e.line, e.column, e); } } : function(f){ return f(); }; }; })(); init0.ls (function(){ return function(){ var initTrySafe, initEntryPoints, decideContentServer, restartFrozenPage, calcCachesEnabled, initFileSystem, initStore, init1; initTrySafe = function(){ inc("init/trySafe/trySafe")(); return initEntryPoints(); }; initEntryPoints = function(){ inc("init/entryPoints/entryPoints")(); return decideContentServer(); }; decideContentServer = function(){ return trySafe(function(){ return inc("init/decideContentServer/decide")(restartFrozenPage); }); }; restartFrozenPage = function(){ inc("init/restartFrozenPage/restart")(); return calcCachesEnabled(); }; calcCachesEnabled = function(){ return inc("init/calcCachesEnabled/calc")(initFileSystem); }; initFileSystem = function(){ return inc("init/fileSystem/init")(initStore); }; initStore = function(){ return inc("init/store/init")(init1); }; init1 = function(){ return inc("init1")(); }; return initTrySafe(); }; })(); init1.ls (function(){ return function(){ var calcLocal, callbackCounter, local, load, start; calcLocal = inc("init/projects/loadProjects/calcEnvironment/calcL/calc"); inc("init/engineVersion/init")(); inc("init/engineIsDebug/engineIsDebug")(); inc("init/projects/init")(); inc("init/debug/debug")(); inc("init/fixFirefoxIosStartError/fix")(); inc("init/Lawnchair/Lawnchair")(); if (inc("init/blockIE/block")() || inc("init/debugStart/debugStart")() || inc("init/startLandingPage/start")() || inc("init/startCustom/start")()) { return; } callbackCounter = 0; local = null; load = function(){ local = calcLocal(); inc("loadMaintenance/load")(start); return inc("loadApp01/load")(start); }; start = function(){ var local2; callbackCounter++; if (callbackCounter !== 2) { return; } local2 = calcLocal(); if (local !== local2) { local = local2; callbackCounter--; return inc("loadApp01/load")(start); } else { return inc("/../app01/init")(); } }; return load(); }; })(); loadApp01/load.ls (function(){ return function(onDone){ var logResult; logResult = function(e){ return helpers.postEvent(Store("deviceLogId"), e); }; return projects.loadProjects({ projectDescriptions: [{ project: "app01", timeout: "60, 0", engineStart: true, logResults: false }], onDone: function(projectDescriptions, resultEvent){ var status; status = projectDescriptions[0].result.status; if (status !== "local" && status !== "latest" && status !== "timeout") { resultEvent.event = "deviceDebugEngineStartApp01Up" + "dated"; logResult(resultEvent); } return onDone(); }, onProjectMissingError: function(projectDescriptions, resultEvent){ var ref$, div, errorSrc, s; resultEvent.event = "deviceDebugEngineStartApp01Failed"; logResult(resultEvent); if (typeof navigator != 'undefined' && navigator !== null) { if ((ref$ = navigator.splashscreen) != null) { if (typeof ref$.hide == 'function') { ref$.hide(); } } } div = document.createElement("div"); errorSrc = inc("/_shared/calcErrorSrc/calc")(); div.innerHTML = "Start error (" + errorSrc + "), please restart online!"; s = div.style; s.fontFamily = "verdana"; document.body.appendChild(div); if (engine.isDebug) { debug(resultEvent); if (Store("serverConfigOverride")) { debug("Reset server/project config, please restart"); return Store.remove("serverConfigOverride"); } } } }); }; })(); loadMaintenance/etag/etag.ls (function(){ return function(etag){ var checksum, s, i$, len$, c, a, lv, n, ev, v, ev2; checksum = etag.split("-")[2]; if (!checksum) { return; } s = ""; for (i$ = 0, len$ = checksum.length; i$ < len$; ++i$) { c = checksum[i$]; if (in$(c, "cdeVGWSD")) { s += "."; } else { s += c; } } for (i$ = 0, len$ = ("aib").length; i$ < len$; ++i$) { c = ("aib")[i$]; s = s.replace(c, "|"); } a = s.split("|"); if (a.length !== 4) { return; } lv = engine["is" + "And" + "roi" + "dA" + "pp"] ? a[1] : engine["is" + "iO" + "sA" + "pp"] ? a[2] : a[3]; n = "eng" + "ineVer" + "sion"; ev = engine["clien" + "tVersion"]; v = Store(n) || ev + "-" + lv; a = v.split("-"); a[1] = lv; ev2 = a.join("-"); if (ev2 !== Store(n)) { return Store(n, ev2); } }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } loadMaintenance/load.ls (function(){ return function(onDone){ var load, onLoaded; load = function(){ var url, xhr; url = app.contentServer + "/files/?fileId=maintenance"; if (engine.isDebug) { url += "/debug"; } xhr = new XMLHttpRequest(); xhr.open("get", url); xhr.onload = function(){ return trySafe(function(){ return onLoaded(xhr.response); }); }; xhr.onerror = function(){ return trySafe(function(){ return onDone(); }); }; return xhr.send(); }; onLoaded = function(c){ var that; try { c = JSON.parse(c); } catch (e$) {} if (c.etag) { inc("etag/etag")(c.etag); } if (that = c.maintenanceMessages) { engine.maintenanceMessages = that; } return onDone(); }; return load(); }; })();