Parse DB min

Parse DB ver 1.3.3 min

As of 2015-01-22. See the latest version.

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greatest.deepsurf.us/scripts/7601/32976/Parse%20DB%20min.js

  1. // ==UserScript==
  2. // @name Parse DB min
  3. // @version 1.3.3
  4. // ==/UserScript==
  5. ! function(a) {
  6. a.Parse = a.Parse || {}, a.Parse.VERSION = "js1.3.3"
  7. }(this),
  8. function() {
  9. var a = this,
  10. b = a._,
  11. c = {},
  12. d = Array.prototype,
  13. e = Object.prototype,
  14. f = Function.prototype,
  15. g = d.push,
  16. h = d.slice,
  17. i = d.concat,
  18. j = e.toString,
  19. k = e.hasOwnProperty,
  20. l = d.forEach,
  21. m = d.map,
  22. n = d.reduce,
  23. o = d.reduceRight,
  24. p = d.filter,
  25. q = d.every,
  26. r = d.some,
  27. s = d.indexOf,
  28. t = d.lastIndexOf,
  29. u = Array.isArray,
  30. v = Object.keys,
  31. w = f.bind,
  32. x = function(a) {
  33. return a instanceof x ? a : this instanceof x ? (this._wrapped = a, void 0) : new x(a)
  34. };
  35. "undefined" != typeof exports ? ("undefined" != typeof module && module.exports && (exports = module.exports = x), exports._ = x) : a._ = x, x.VERSION = "1.4.4";
  36. var y = x.each = x.forEach = function(a, b, d) {
  37. if (null != a)
  38. if (l && a.forEach === l) a.forEach(b, d);
  39. else if (a.length === +a.length) {
  40. for (var e = 0, f = a.length; f > e; e++)
  41. if (b.call(d, a[e], e, a) === c) return
  42. } else
  43. for (var g in a)
  44. if (x.has(a, g) && b.call(d, a[g], g, a) === c) return
  45. };
  46. x.map = x.collect = function(a, b, c) {
  47. var d = [];
  48. return null == a ? d : m && a.map === m ? a.map(b, c) : (y(a, function(a, e, f) {
  49. d[d.length] = b.call(c, a, e, f)
  50. }), d)
  51. };
  52. var z = "Reduce of empty array with no initial value";
  53. x.reduce = x.foldl = x.inject = function(a, b, c, d) {
  54. var e = arguments.length > 2;
  55. if (null == a && (a = []), n && a.reduce === n) return d && (b = x.bind(b, d)), e ? a.reduce(b, c) : a.reduce(b);
  56. if (y(a, function(a, f, g) {
  57. e ? c = b.call(d, c, a, f, g) : (c = a, e = !0)
  58. }), !e) throw new TypeError(z);
  59. return c
  60. }, x.reduceRight = x.foldr = function(a, b, c, d) {
  61. var e = arguments.length > 2;
  62. if (null == a && (a = []), o && a.reduceRight === o) return d && (b = x.bind(b, d)), e ? a.reduceRight(b, c) : a.reduceRight(b);
  63. var f = a.length;
  64. if (f !== +f) {
  65. var g = x.keys(a);
  66. f = g.length
  67. }
  68. if (y(a, function(h, i, j) {
  69. i = g ? g[--f] : --f, e ? c = b.call(d, c, a[i], i, j) : (c = a[i], e = !0)
  70. }), !e) throw new TypeError(z);
  71. return c
  72. }, x.find = x.detect = function(a, b, c) {
  73. var d;
  74. return A(a, function(a, e, f) {
  75. return b.call(c, a, e, f) ? (d = a, !0) : void 0
  76. }), d
  77. }, x.filter = x.select = function(a, b, c) {
  78. var d = [];
  79. return null == a ? d : p && a.filter === p ? a.filter(b, c) : (y(a, function(a, e, f) {
  80. b.call(c, a, e, f) && (d[d.length] = a)
  81. }), d)
  82. }, x.reject = function(a, b, c) {
  83. return x.filter(a, function(a, d, e) {
  84. return !b.call(c, a, d, e)
  85. }, c)
  86. }, x.every = x.all = function(a, b, d) {
  87. b || (b = x.identity);
  88. var e = !0;
  89. return null == a ? e : q && a.every === q ? a.every(b, d) : (y(a, function(a, f, g) {
  90. return (e = e && b.call(d, a, f, g)) ? void 0 : c
  91. }), !!e)
  92. };
  93. var A = x.some = x.any = function(a, b, d) {
  94. b || (b = x.identity);
  95. var e = !1;
  96. return null == a ? e : r && a.some === r ? a.some(b, d) : (y(a, function(a, f, g) {
  97. return e || (e = b.call(d, a, f, g)) ? c : void 0
  98. }), !!e)
  99. };
  100. x.contains = x.include = function(a, b) {
  101. return null == a ? !1 : s && a.indexOf === s ? -1 != a.indexOf(b) : A(a, function(a) {
  102. return a === b
  103. })
  104. }, x.invoke = function(a, b) {
  105. var c = h.call(arguments, 2),
  106. d = x.isFunction(b);
  107. return x.map(a, function(a) {
  108. return (d ? b : a[b]).apply(a, c)
  109. })
  110. }, x.pluck = function(a, b) {
  111. return x.map(a, function(a) {
  112. return a[b]
  113. })
  114. }, x.where = function(a, b, c) {
  115. return x.isEmpty(b) ? c ? null : [] : x[c ? "find" : "filter"](a, function(a) {
  116. for (var c in b)
  117. if (b[c] !== a[c]) return !1;
  118. return !0
  119. })
  120. }, x.findWhere = function(a, b) {
  121. return x.where(a, b, !0)
  122. }, x.max = function(a, b, c) {
  123. if (!b && x.isArray(a) && a[0] === +a[0] && a.length < 65535) return Math.max.apply(Math, a);
  124. if (!b && x.isEmpty(a)) return -1 / 0;
  125. var d = {
  126. computed: -1 / 0,
  127. value: -1 / 0
  128. };
  129. return y(a, function(a, e, f) {
  130. var g = b ? b.call(c, a, e, f) : a;
  131. g >= d.computed && (d = {
  132. value: a,
  133. computed: g
  134. })
  135. }), d.value
  136. }, x.min = function(a, b, c) {
  137. if (!b && x.isArray(a) && a[0] === +a[0] && a.length < 65535) return Math.min.apply(Math, a);
  138. if (!b && x.isEmpty(a)) return 1 / 0;
  139. var d = {
  140. computed: 1 / 0,
  141. value: 1 / 0
  142. };
  143. return y(a, function(a, e, f) {
  144. var g = b ? b.call(c, a, e, f) : a;
  145. g < d.computed && (d = {
  146. value: a,
  147. computed: g
  148. })
  149. }), d.value
  150. }, x.shuffle = function(a) {
  151. var b, c = 0,
  152. d = [];
  153. return y(a, function(a) {
  154. b = x.random(c++), d[c - 1] = d[b], d[b] = a
  155. }), d
  156. };
  157. var B = function(a) {
  158. return x.isFunction(a) ? a : function(b) {
  159. return b[a]
  160. }
  161. };
  162. x.sortBy = function(a, b, c) {
  163. var d = B(b);
  164. return x.pluck(x.map(a, function(a, b, e) {
  165. return {
  166. value: a,
  167. index: b,
  168. criteria: d.call(c, a, b, e)
  169. }
  170. }).sort(function(a, b) {
  171. var c = a.criteria,
  172. d = b.criteria;
  173. if (c !== d) {
  174. if (c > d || void 0 === c) return 1;
  175. if (d > c || void 0 === d) return -1
  176. }
  177. return a.index < b.index ? -1 : 1
  178. }), "value")
  179. };
  180. var C = function(a, b, c, d) {
  181. var e = {},
  182. f = B(b || x.identity);
  183. return y(a, function(b, g) {
  184. var h = f.call(c, b, g, a);
  185. d(e, h, b)
  186. }), e
  187. };
  188. x.groupBy = function(a, b, c) {
  189. return C(a, b, c, function(a, b, c) {
  190. (x.has(a, b) ? a[b] : a[b] = []).push(c)
  191. })
  192. }, x.countBy = function(a, b, c) {
  193. return C(a, b, c, function(a, b) {
  194. x.has(a, b) || (a[b] = 0), a[b] ++
  195. })
  196. }, x.sortedIndex = function(a, b, c, d) {
  197. c = null == c ? x.identity : B(c);
  198. for (var e = c.call(d, b), f = 0, g = a.length; g > f;) {
  199. var h = f + g >>> 1;
  200. c.call(d, a[h]) < e ? f = h + 1 : g = h
  201. }
  202. return f
  203. }, x.toArray = function(a) {
  204. return a ? x.isArray(a) ? h.call(a) : a.length === +a.length ? x.map(a, x.identity) : x.values(a) : []
  205. }, x.size = function(a) {
  206. return null == a ? 0 : a.length === +a.length ? a.length : x.keys(a).length
  207. }, x.first = x.head = x.take = function(a, b, c) {
  208. return null == a ? void 0 : null == b || c ? a[0] : h.call(a, 0, b)
  209. }, x.initial = function(a, b, c) {
  210. return h.call(a, 0, a.length - (null == b || c ? 1 : b))
  211. }, x.last = function(a, b, c) {
  212. return null == a ? void 0 : null == b || c ? a[a.length - 1] : h.call(a, Math.max(a.length - b, 0))
  213. }, x.rest = x.tail = x.drop = function(a, b, c) {
  214. return h.call(a, null == b || c ? 1 : b)
  215. }, x.compact = function(a) {
  216. return x.filter(a, x.identity)
  217. };
  218. var D = function(a, b, c) {
  219. return y(a, function(a) {
  220. x.isArray(a) ? b ? g.apply(c, a) : D(a, b, c) : c.push(a)
  221. }), c
  222. };
  223. x.flatten = function(a, b) {
  224. return D(a, b, [])
  225. }, x.without = function(a) {
  226. return x.difference(a, h.call(arguments, 1))
  227. }, x.uniq = x.unique = function(a, b, c, d) {
  228. x.isFunction(b) && (d = c, c = b, b = !1);
  229. var e = c ? x.map(a, c, d) : a,
  230. f = [],
  231. g = [];
  232. return y(e, function(c, d) {
  233. (b ? d && g[g.length - 1] === c : x.contains(g, c)) || (g.push(c), f.push(a[d]))
  234. }), f
  235. }, x.union = function() {
  236. return x.uniq(i.apply(d, arguments))
  237. }, x.intersection = function(a) {
  238. var b = h.call(arguments, 1);
  239. return x.filter(x.uniq(a), function(a) {
  240. return x.every(b, function(b) {
  241. return x.indexOf(b, a) >= 0
  242. })
  243. })
  244. }, x.difference = function(a) {
  245. var b = i.apply(d, h.call(arguments, 1));
  246. return x.filter(a, function(a) {
  247. return !x.contains(b, a)
  248. })
  249. }, x.zip = function() {
  250. for (var a = h.call(arguments), b = x.max(x.pluck(a, "length")), c = new Array(b), d = 0; b > d; d++) c[d] = x.pluck(a, "" + d);
  251. return c
  252. }, x.object = function(a, b) {
  253. if (null == a) return {};
  254. for (var c = {}, d = 0, e = a.length; e > d; d++) b ? c[a[d]] = b[d] : c[a[d][0]] = a[d][1];
  255. return c
  256. }, x.indexOf = function(a, b, c) {
  257. if (null == a) return -1;
  258. var d = 0,
  259. e = a.length;
  260. if (c) {
  261. if ("number" != typeof c) return d = x.sortedIndex(a, b), a[d] === b ? d : -1;
  262. d = 0 > c ? Math.max(0, e + c) : c
  263. }
  264. if (s && a.indexOf === s) return a.indexOf(b, c);
  265. for (; e > d; d++)
  266. if (a[d] === b) return d;
  267. return -1
  268. }, x.lastIndexOf = function(a, b, c) {
  269. if (null == a) return -1;
  270. var d = null != c;
  271. if (t && a.lastIndexOf === t) return d ? a.lastIndexOf(b, c) : a.lastIndexOf(b);
  272. for (var e = d ? c : a.length; e--;)
  273. if (a[e] === b) return e;
  274. return -1
  275. }, x.range = function(a, b, c) {
  276. arguments.length <= 1 && (b = a || 0, a = 0), c = arguments[2] || 1;
  277. for (var d = Math.max(Math.ceil((b - a) / c), 0), e = 0, f = new Array(d); d > e;) f[e++] = a, a += c;
  278. return f
  279. }, x.bind = function(a, b) {
  280. if (a.bind === w && w) return w.apply(a, h.call(arguments, 1));
  281. var c = h.call(arguments, 2);
  282. return function() {
  283. return a.apply(b, c.concat(h.call(arguments)))
  284. }
  285. }, x.partial = function(a) {
  286. var b = h.call(arguments, 1);
  287. return function() {
  288. return a.apply(this, b.concat(h.call(arguments)))
  289. }
  290. }, x.bindAll = function(a) {
  291. var b = h.call(arguments, 1);
  292. return 0 === b.length && (b = x.functions(a)), y(b, function(b) {
  293. a[b] = x.bind(a[b], a)
  294. }), a
  295. }, x.memoize = function(a, b) {
  296. var c = {};
  297. return b || (b = x.identity),
  298. function() {
  299. var d = b.apply(this, arguments);
  300. return x.has(c, d) ? c[d] : c[d] = a.apply(this, arguments)
  301. }
  302. }, x.delay = function(a, b) {
  303. var c = h.call(arguments, 2);
  304. return setTimeout(function() {
  305. return a.apply(null, c)
  306. }, b)
  307. }, x.defer = function(a) {
  308. return x.delay.apply(x, [a, 1].concat(h.call(arguments, 1)))
  309. }, x.throttle = function(a, b) {
  310. var c, d, e, f, g = 0,
  311. h = function() {
  312. g = new Date, e = null, f = a.apply(c, d)
  313. };
  314. return function() {
  315. var i = new Date,
  316. j = b - (i - g);
  317. return c = this, d = arguments, 0 >= j ? (clearTimeout(e), e = null, g = i, f = a.apply(c, d)) : e || (e = setTimeout(h, j)), f
  318. }
  319. }, x.debounce = function(a, b, c) {
  320. var d, e;
  321. return function() {
  322. var f = this,
  323. g = arguments,
  324. h = function() {
  325. d = null, c || (e = a.apply(f, g))
  326. },
  327. i = c && !d;
  328. return clearTimeout(d), d = setTimeout(h, b), i && (e = a.apply(f, g)), e
  329. }
  330. }, x.once = function(a) {
  331. var b, c = !1;
  332. return function() {
  333. return c ? b : (c = !0, b = a.apply(this, arguments), a = null, b)
  334. }
  335. }, x.wrap = function(a, b) {
  336. return function() {
  337. var c = [a];
  338. return g.apply(c, arguments), b.apply(this, c)
  339. }
  340. }, x.compose = function() {
  341. var a = arguments;
  342. return function() {
  343. for (var b = arguments, c = a.length - 1; c >= 0; c--) b = [a[c].apply(this, b)];
  344. return b[0]
  345. }
  346. }, x.after = function(a, b) {
  347. return 0 >= a ? b() : function() {
  348. return --a < 1 ? b.apply(this, arguments) : void 0
  349. }
  350. }, x.keys = v || function(a) {
  351. if (a !== Object(a)) throw new TypeError("Invalid object");
  352. var b = [];
  353. for (var c in a) x.has(a, c) && (b[b.length] = c);
  354. return b
  355. }, x.values = function(a) {
  356. var b = [];
  357. for (var c in a) x.has(a, c) && b.push(a[c]);
  358. return b
  359. }, x.pairs = function(a) {
  360. var b = [];
  361. for (var c in a) x.has(a, c) && b.push([c, a[c]]);
  362. return b
  363. }, x.invert = function(a) {
  364. var b = {};
  365. for (var c in a) x.has(a, c) && (b[a[c]] = c);
  366. return b
  367. }, x.functions = x.methods = function(a) {
  368. var b = [];
  369. for (var c in a) x.isFunction(a[c]) && b.push(c);
  370. return b.sort()
  371. }, x.extend = function(a) {
  372. return y(h.call(arguments, 1), function(b) {
  373. if (b)
  374. for (var c in b) a[c] = b[c]
  375. }), a
  376. }, x.pick = function(a) {
  377. var b = {},
  378. c = i.apply(d, h.call(arguments, 1));
  379. return y(c, function(c) {
  380. c in a && (b[c] = a[c])
  381. }), b
  382. }, x.omit = function(a) {
  383. var b = {},
  384. c = i.apply(d, h.call(arguments, 1));
  385. for (var e in a) x.contains(c, e) || (b[e] = a[e]);
  386. return b
  387. }, x.defaults = function(a) {
  388. return y(h.call(arguments, 1), function(b) {
  389. if (b)
  390. for (var c in b) null == a[c] && (a[c] = b[c])
  391. }), a
  392. }, x.clone = function(a) {
  393. return x.isObject(a) ? x.isArray(a) ? a.slice() : x.extend({}, a) : a
  394. }, x.tap = function(a, b) {
  395. return b(a), a
  396. };
  397. var E = function(a, b, c, d) {
  398. if (a === b) return 0 !== a || 1 / a == 1 / b;
  399. if (null == a || null == b) return a === b;
  400. a instanceof x && (a = a._wrapped), b instanceof x && (b = b._wrapped);
  401. var e = j.call(a);
  402. if (e != j.call(b)) return !1;
  403. switch (e) {
  404. case "[object String]":
  405. return a == String(b);
  406. case "[object Number]":
  407. return a != +a ? b != +b : 0 == a ? 1 / a == 1 / b : a == +b;
  408. case "[object Date]":
  409. case "[object Boolean]":
  410. return +a == +b;
  411. case "[object RegExp]":
  412. return a.source == b.source && a.global == b.global && a.multiline == b.multiline && a.ignoreCase == b.ignoreCase
  413. }
  414. if ("object" != typeof a || "object" != typeof b) return !1;
  415. for (var f = c.length; f--;)
  416. if (c[f] == a) return d[f] == b;
  417. c.push(a), d.push(b);
  418. var g = 0,
  419. h = !0;
  420. if ("[object Array]" == e) {
  421. if (g = a.length, h = g == b.length)
  422. for (; g-- && (h = E(a[g], b[g], c, d)););
  423. } else {
  424. var i = a.constructor,
  425. k = b.constructor;
  426. if (i !== k && !(x.isFunction(i) && i instanceof i && x.isFunction(k) && k instanceof k)) return !1;
  427. for (var l in a)
  428. if (x.has(a, l) && (g++, !(h = x.has(b, l) && E(a[l], b[l], c, d)))) break;
  429. if (h) {
  430. for (l in b)
  431. if (x.has(b, l) && !g--) break;
  432. h = !g
  433. }
  434. }
  435. return c.pop(), d.pop(), h
  436. };
  437. x.isEqual = function(a, b) {
  438. return E(a, b, [], [])
  439. }, x.isEmpty = function(a) {
  440. if (null == a) return !0;
  441. if (x.isArray(a) || x.isString(a)) return 0 === a.length;
  442. for (var b in a)
  443. if (x.has(a, b)) return !1;
  444. return !0
  445. }, x.isElement = function(a) {
  446. return !(!a || 1 !== a.nodeType)
  447. }, x.isArray = u || function(a) {
  448. return "[object Array]" == j.call(a)
  449. }, x.isObject = function(a) {
  450. return a === Object(a)
  451. }, y(["Arguments", "Function", "String", "Number", "Date", "RegExp"], function(a) {
  452. x["is" + a] = function(b) {
  453. return j.call(b) == "[object " + a + "]"
  454. }
  455. }), x.isArguments(arguments) || (x.isArguments = function(a) {
  456. return !(!a || !x.has(a, "callee"))
  457. }), "function" != typeof /./ && (x.isFunction = function(a) {
  458. return "function" == typeof a
  459. }), x.isFinite = function(a) {
  460. return isFinite(a) && !isNaN(parseFloat(a))
  461. }, x.isNaN = function(a) {
  462. return x.isNumber(a) && a != +a
  463. }, x.isBoolean = function(a) {
  464. return a === !0 || a === !1 || "[object Boolean]" == j.call(a)
  465. }, x.isNull = function(a) {
  466. return null === a
  467. }, x.isUndefined = function(a) {
  468. return void 0 === a
  469. }, x.has = function(a, b) {
  470. return k.call(a, b)
  471. }, x.noConflict = function() {
  472. return a._ = b, this
  473. }, x.identity = function(a) {
  474. return a
  475. }, x.times = function(a, b, c) {
  476. for (var d = Array(a), e = 0; a > e; e++) d[e] = b.call(c, e);
  477. return d
  478. }, x.random = function(a, b) {
  479. return null == b && (b = a, a = 0), a + Math.floor(Math.random() * (b - a + 1))
  480. };
  481. var F = {
  482. escape: {
  483. "&": "&amp;",
  484. "<": "&lt;",
  485. ">": "&gt;",
  486. '"': "&quot;",
  487. "'": "&#x27;",
  488. "/": "&#x2F;"
  489. }
  490. };
  491. F.unescape = x.invert(F.escape);
  492. var G = {
  493. escape: new RegExp("[" + x.keys(F.escape).join("") + "]", "g"),
  494. unescape: new RegExp("(" + x.keys(F.unescape).join("|") + ")", "g")
  495. };
  496. x.each(["escape", "unescape"], function(a) {
  497. x[a] = function(b) {
  498. return null == b ? "" : ("" + b).replace(G[a], function(b) {
  499. return F[a][b]
  500. })
  501. }
  502. }), x.result = function(a, b) {
  503. if (null == a) return null;
  504. var c = a[b];
  505. return x.isFunction(c) ? c.call(a) : c
  506. }, x.mixin = function(a) {
  507. y(x.functions(a), function(b) {
  508. var c = x[b] = a[b];
  509. x.prototype[b] = function() {
  510. var a = [this._wrapped];
  511. return g.apply(a, arguments), L.call(this, c.apply(x, a))
  512. }
  513. })
  514. };
  515. var H = 0;
  516. x.uniqueId = function(a) {
  517. var b = ++H + "";
  518. return a ? a + b : b
  519. }, x.templateSettings = {
  520. evaluate: /<%([\s\S]+?)%>/g,
  521. interpolate: /<%=([\s\S]+?)%>/g,
  522. escape: /<%-([\s\S]+?)%>/g
  523. };
  524. var I = /(.)^/,
  525. J = {
  526. "'": "'",
  527. "\\": "\\",
  528. "\r": "r",
  529. "\n": "n",
  530. " ": "t",
  531. "\u2028": "u2028",
  532. "\u2029": "u2029"
  533. },
  534. K = /\\|'|\r|\n|\t|\u2028|\u2029/g;
  535. x.template = function(a, b, c) {
  536. var d;
  537. c = x.defaults({}, c, x.templateSettings);
  538. var e = new RegExp([(c.escape || I).source, (c.interpolate || I).source, (c.evaluate || I).source].join("|") + "|$", "g"),
  539. f = 0,
  540. g = "__p+='";
  541. a.replace(e, function(b, c, d, e, h) {
  542. return g += a.slice(f, h).replace(K, function(a) {
  543. return "\\" + J[a]
  544. }), c && (g += "'+\n((__t=(" + c + "))==null?'':_.escape(__t))+\n'"), d && (g += "'+\n((__t=(" + d + "))==null?'':__t)+\n'"), e && (g += "';\n" + e + "\n__p+='"), f = h + b.length, b
  545. }), g += "';\n", c.variable || (g = "with(obj||{}){\n" + g + "}\n"), g = "var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n" + g + "return __p;\n";
  546. try {
  547. d = new Function(c.variable || "obj", "_", g)
  548. } catch (h) {
  549. throw h.source = g, h
  550. }
  551. if (b) return d(b, x);
  552. var i = function(a) {
  553. return d.call(this, a, x)
  554. };
  555. return i.source = "function(" + (c.variable || "obj") + "){\n" + g + "}", i
  556. }, x.chain = function(a) {
  557. return x(a).chain()
  558. };
  559. var L = function(a) {
  560. return this._chain ? x(a).chain() : a
  561. };
  562. x.mixin(x), y(["pop", "push", "reverse", "shift", "sort", "splice", "unshift"], function(a) {
  563. var b = d[a];
  564. x.prototype[a] = function() {
  565. var c = this._wrapped;
  566. return b.apply(c, arguments), "shift" != a && "splice" != a || 0 !== c.length || delete c[0], L.call(this, c)
  567. }
  568. }), y(["concat", "join", "slice"], function(a) {
  569. var b = d[a];
  570. x.prototype[a] = function() {
  571. return L.call(this, b.apply(this._wrapped, arguments))
  572. }
  573. }), x.extend(x.prototype, {
  574. chain: function() {
  575. return this._chain = !0, this
  576. },
  577. value: function() {
  578. return this._wrapped
  579. }
  580. })
  581. }.call(this),
  582. function(a) {
  583. a.Parse = a.Parse || {};
  584. var b = a.Parse;
  585. "undefined" != typeof exports && exports._ ? (b._ = exports._.noConflict(), b.localStorage = require("localStorage"), b.XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest, exports.Parse = b) : (b._ = _.noConflict(), "undefined" != typeof localStorage && (b.localStorage = localStorage), "undefined" != typeof XMLHttpRequest && (b.XMLHttpRequest = XMLHttpRequest)), "undefined" != typeof $ && (b.$ = $);
  586. var c = function() {},
  587. d = function(a, d, e) {
  588. var f;
  589. return f = d && d.hasOwnProperty("constructor") ? d.constructor : function() {
  590. a.apply(this, arguments)
  591. }, b._.extend(f, a), c.prototype = a.prototype, f.prototype = new c, d && b._.extend(f.prototype, d), e && b._.extend(f, e), f.prototype.constructor = f, f.__super__ = a.prototype, f
  592. };
  593. b.serverURL = "https://api.parse.com", "undefined" != typeof process && process.versions && process.versions.node && (b._isNode = !0), b.initialize = function(a, c, d) {
  594. if (d) throw "Parse.initialize() was passed a Master Key, which is only allowed from within Node.js.";
  595. b._initialize(a, c)
  596. }, b._initialize = function(a, c, d) {
  597. b.applicationId = a, b.javaScriptKey = c, b.masterKey = d, b._useMasterKey = !1
  598. }, b._isNode && (b.initialize = b._initialize, b.Cloud = b.Cloud || {}, b.Cloud.useMasterKey = function() {
  599. b._useMasterKey = !0
  600. }), b._getParsePath = function(a) {
  601. if (!b.applicationId) throw "You need to call Parse.initialize before using Parse.";
  602. if (a || (a = ""), !b._.isString(a)) throw "Tried to get a localStorage path that wasn't a String.";
  603. return "/" === a[0] && (a = a.substring(1)), "Parse/" + b.applicationId + "/" + a
  604. }, b._installationId = null, b._getInstallationId = function() {
  605. if (b._installationId) return b._installationId;
  606. var a = b._getParsePath("installationId");
  607. if (b._installationId = b.localStorage.getItem(a), !b._installationId || "" === b._installationId) {
  608. var c = function() {
  609. return Math.floor(65536 * (1 + Math.random())).toString(16).substring(1)
  610. };
  611. b._installationId = c() + c() + "-" + c() + "-" + c() + "-" + c() + "-" + c() + c() + c(), b.localStorage.setItem(a, b._installationId)
  612. }
  613. return b._installationId
  614. }, b._parseDate = function(a) {
  615. var b = new RegExp("^([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2})T([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})(.([0-9]+))?Z$"),
  616. c = b.exec(a);
  617. if (!c) return null;
  618. var d = c[1] || 0,
  619. e = (c[2] || 1) - 1,
  620. f = c[3] || 0,
  621. g = c[4] || 0,
  622. h = c[5] || 0,
  623. i = c[6] || 0,
  624. j = c[8] || 0;
  625. return new Date(Date.UTC(d, e, f, g, h, i, j))
  626. }, b._ajaxIE8 = function(a, c, d) {
  627. var e = new b.Promise,
  628. f = new XDomainRequest;
  629. return f.onload = function() {
  630. var a;
  631. try {
  632. a = JSON.parse(f.responseText)
  633. } catch (b) {
  634. e.reject(b)
  635. }
  636. a && e.resolve(a)
  637. }, f.onerror = f.ontimeout = function() {
  638. var a = {
  639. responseText: JSON.stringify({
  640. code: b.Error.X_DOMAIN_REQUEST,
  641. error: "IE's XDomainRequest does not supply error info."
  642. })
  643. };
  644. e.reject(a)
  645. }, f.onprogress = function() {}, f.open(a, c), f.send(d), e
  646. }, b._useXDomainRequest = function() {
  647. return "undefined" != typeof XDomainRequest ? "withCredentials" in new XMLHttpRequest ? !1 : !0 : !1
  648. }, b._ajax = function(a, c, d, e, f) {
  649. var g = {
  650. success: e,
  651. error: f
  652. };
  653. if (b._useXDomainRequest()) return b._ajaxIE8(a, c, d)._thenRunCallbacks(g);
  654. var h = new b.Promise,
  655. i = !1,
  656. j = new b.XMLHttpRequest;
  657. return j.onreadystatechange = function() {
  658. if (4 === j.readyState) {
  659. if (i) return;
  660. if (i = !0, j.status >= 200 && j.status < 300) {
  661. var a;
  662. try {
  663. a = JSON.parse(j.responseText)
  664. } catch (b) {
  665. h.reject(b)
  666. }
  667. a && h.resolve(a, j.status, j)
  668. } else h.reject(j)
  669. }
  670. }, j.open(a, c, !0), j.setRequestHeader("Content-Type", "text/plain"), b._isNode && j.setRequestHeader("User-Agent", "Parse/" + b.VERSION + " (NodeJS " + process.versions.node + ")"), j.send(d), h._thenRunCallbacks(g)
  671. }, b._extend = function(a, b) {
  672. var c = d(this, a, b);
  673. return c.extend = this.extend, c
  674. }, b._request = function(a) {
  675. var c = a.route,
  676. d = a.className,
  677. e = a.objectId,
  678. f = a.method,
  679. g = a.useMasterKey,
  680. h = a.sessionToken,
  681. i = a.data;
  682. if (!b.applicationId) throw "You must specify your applicationId using Parse.initialize.";
  683. if (!b.javaScriptKey && !b.masterKey) throw "You must specify a key using Parse.initialize.";
  684. if (!h) {
  685. var j = b.User.current();
  686. j && j._sessionToken && (h = j._sessionToken)
  687. }
  688. if ("batch" !== c && "classes" !== c && "events" !== c && "files" !== c && "functions" !== c && "login" !== c && "push" !== c && "requestPasswordReset" !== c && "rest_verify_analytics" !== c && "users" !== c && "jobs" !== c && "config" !== c) throw "Bad route: '" + c + "'.";
  689. var k = b.serverURL;
  690. "/" !== k.charAt(k.length - 1) && (k += "/"), k += "1/" + c, d && (k += "/" + d), e && (k += "/" + e), i = b._.clone(i || {}), "POST" !== f && (i._method = f, f = "POST"), b._.isUndefined(g) && (g = b._useMasterKey), i._ApplicationId = b.applicationId, g ? i._MasterKey = b.masterKey : i._JavaScriptKey = b.javaScriptKey, i._ClientVersion = b.VERSION, i._InstallationId = b._getInstallationId(), h && (i._SessionToken = h);
  691. var l = JSON.stringify(i);
  692. return b._ajax(f, k, l).then(null, function(a) {
  693. var c;
  694. if (a && a.responseText) try {
  695. var d = JSON.parse(a.responseText);
  696. c = new b.Error(d.code, d.error)
  697. } catch (e) {
  698. c = new b.Error(b.Error.INVALID_JSON, "Received an error with invalid JSON from Parse: " + a.responseText)
  699. } else c = new b.Error(b.Error.CONNECTION_FAILED, "XMLHttpRequest failed: " + JSON.stringify(a));
  700. return b.Promise.error(c)
  701. })
  702. }, b._getValue = function(a, c) {
  703. return a && a[c] ? b._.isFunction(a[c]) ? a[c]() : a[c] : null
  704. }, b._encode = function(a, c, d) {
  705. var e = b._;
  706. if (a instanceof b.Object) {
  707. if (d) throw "Parse.Objects not allowed here";
  708. if (!c || e.include(c, a) || !a._hasData) return a._toPointer();
  709. if (!a.dirty()) return c = c.concat(a), b._encode(a._toFullJSON(c), c, d);
  710. throw "Tried to save an object with a pointer to a new, unsaved object."
  711. }
  712. if (a instanceof b.ACL) return a.toJSON();
  713. if (e.isDate(a)) return {
  714. __type: "Date",
  715. iso: a.toJSON()
  716. };
  717. if (a instanceof b.GeoPoint) return a.toJSON();
  718. if (e.isArray(a)) return e.map(a, function(a) {
  719. return b._encode(a, c, d)
  720. });
  721. if (e.isRegExp(a)) return a.source;
  722. if (a instanceof b.Relation) return a.toJSON();
  723. if (a instanceof b.Op) return a.toJSON();
  724. if (a instanceof b.File) {
  725. if (!a.url()) throw "Tried to save an object containing an unsaved file.";
  726. return {
  727. __type: "File",
  728. name: a.name(),
  729. url: a.url()
  730. }
  731. }
  732. if (e.isObject(a)) {
  733. var f = {};
  734. return b._objectEach(a, function(a, e) {
  735. f[e] = b._encode(a, c, d)
  736. }), f
  737. }
  738. return a
  739. }, b._decode = function(a, c) {
  740. var d = b._;
  741. if (!d.isObject(c)) return c;
  742. if (d.isArray(c)) return b._arrayEach(c, function(a, d) {
  743. c[d] = b._decode(d, a)
  744. }), c;
  745. if (c instanceof b.Object) return c;
  746. if (c instanceof b.File) return c;
  747. if (c instanceof b.Op) return c;
  748. if (c.__op) return b.Op._decode(c);
  749. if ("Pointer" === c.__type && c.className) {
  750. var e = b.Object._create(c.className);
  751. return e._finishFetch({
  752. objectId: c.objectId
  753. }, !1), e
  754. }
  755. if ("Object" === c.__type && c.className) {
  756. var f = c.className;
  757. delete c.__type, delete c.className;
  758. var g = b.Object._create(f);
  759. return g._finishFetch(c, !0), g
  760. }
  761. if ("Date" === c.__type) return b._parseDate(c.iso);
  762. if ("GeoPoint" === c.__type) return new b.GeoPoint({
  763. latitude: c.latitude,
  764. longitude: c.longitude
  765. });
  766. if ("ACL" === a) return c instanceof b.ACL ? c : new b.ACL(c);
  767. if ("Relation" === c.__type) {
  768. var h = new b.Relation(null, a);
  769. return h.targetClassName = c.className, h
  770. }
  771. if ("File" === c.__type) {
  772. var i = new b.File(c.name);
  773. return i._url = c.url, i
  774. }
  775. return b._objectEach(c, function(a, d) {
  776. c[d] = b._decode(d, a)
  777. }), c
  778. }, b._arrayEach = b._.each, b._traverse = function(a, c, d) {
  779. if (a instanceof b.Object) {
  780. if (d = d || [], b._.indexOf(d, a) >= 0) return;
  781. return d.push(a), b._traverse(a.attributes, c, d), c(a)
  782. }
  783. return a instanceof b.Relation || a instanceof b.File ? c(a) : b._.isArray(a) ? (b._.each(a, function(e, f) {
  784. var g = b._traverse(e, c, d);
  785. g && (a[f] = g)
  786. }), c(a)) : b._.isObject(a) ? (b._each(a, function(e, f) {
  787. var g = b._traverse(e, c, d);
  788. g && (a[f] = g)
  789. }), c(a)) : c(a)
  790. }, b._objectEach = b._each = function(a, c) {
  791. var d = b._;
  792. d.isObject(a) ? d.each(d.keys(a), function(b) {
  793. c(a[b], b)
  794. }) : d.each(a, c)
  795. }, b._isNullOrUndefined = function(a) {
  796. return b._.isNull(a) || b._.isUndefined(a)
  797. }
  798. }(this),
  799. function(a) {
  800. a.Parse = a.Parse || {};
  801. var b = a.Parse,
  802. c = b._;
  803. b.Analytics = b.Analytics || {}, c.extend(b.Analytics, {
  804. track: function(a, d, e) {
  805. if (a = a || "", a = a.replace(/^\s*/, ""), a = a.replace(/\s*$/, ""), 0 === a.length) throw "A name for the custom event must be provided";
  806. return c.each(d, function(a, b) {
  807. if (!c.isString(b) || !c.isString(a)) throw 'track() dimensions expects keys and values of type "string".'
  808. }), e = e || {}, b._request({
  809. route: "events",
  810. className: a,
  811. method: "POST",
  812. data: {
  813. dimensions: d
  814. }
  815. })._thenRunCallbacks(e)
  816. }
  817. })
  818. }(this),
  819. function(a) {
  820. a.Parse = a.Parse || {};
  821. var b = a.Parse,
  822. c = b._;
  823. b.Config = function() {
  824. this.attributes = {}, this._escapedAttributes = {}
  825. }, b.Config.current = function() {
  826. if (b.Config._currentConfig) return b.Config._currentConfig;
  827. var a = b.localStorage.getItem(b._getParsePath(b.Config._CURRENT_CONFIG_KEY)),
  828. c = new b.Config;
  829. return a && (c._finishFetch(JSON.parse(a)), b.Config._currentConfig = c), c
  830. }, b.Config.get = function(a) {
  831. a = a || {};
  832. var c = b._request({
  833. route: "config",
  834. method: "GET"
  835. });
  836. return c.then(function(a) {
  837. if (!a || !a.params) {
  838. var c = new b.Error(b.Error.INVALID_JSON, "Config JSON response invalid.");
  839. return b.Promise.error(c)
  840. }
  841. var d = new b.Config;
  842. return d._finishFetch(a), b.Config._currentConfig = d, d
  843. })._thenRunCallbacks(a)
  844. }, b.Config.prototype = {
  845. escape: function(a) {
  846. var d = this._escapedAttributes[a];
  847. if (d) return d;
  848. var e, f = this.attributes[a];
  849. return e = b._isNullOrUndefined(f) ? "" : c.escape(f.toString()), this._escapedAttributes[a] = e, e
  850. },
  851. get: function(a) {
  852. return this.attributes[a]
  853. },
  854. _finishFetch: function(a) {
  855. this.attributes = b._decode(null, c.clone(a.params)), b.localStorage.setItem(b._getParsePath(b.Config._CURRENT_CONFIG_KEY), JSON.stringify(a))
  856. }
  857. }, b.Config._currentConfig = null, b.Config._CURRENT_CONFIG_KEY = "currentConfig"
  858. }(this),
  859. function(a) {
  860. a.Parse = a.Parse || {};
  861. var b = a.Parse,
  862. c = b._;
  863. b.Error = function(a, b) {
  864. this.code = a, this.message = b
  865. }, c.extend(b.Error, {
  866. OTHER_CAUSE: -1,
  867. INTERNAL_SERVER_ERROR: 1,
  868. CONNECTION_FAILED: 100,
  869. OBJECT_NOT_FOUND: 101,
  870. INVALID_QUERY: 102,
  871. INVALID_CLASS_NAME: 103,
  872. MISSING_OBJECT_ID: 104,
  873. INVALID_KEY_NAME: 105,
  874. INVALID_POINTER: 106,
  875. INVALID_JSON: 107,
  876. COMMAND_UNAVAILABLE: 108,
  877. NOT_INITIALIZED: 109,
  878. INCORRECT_TYPE: 111,
  879. INVALID_CHANNEL_NAME: 112,
  880. PUSH_MISCONFIGURED: 115,
  881. OBJECT_TOO_LARGE: 116,
  882. OPERATION_FORBIDDEN: 119,
  883. CACHE_MISS: 120,
  884. INVALID_NESTED_KEY: 121,
  885. INVALID_FILE_NAME: 122,
  886. INVALID_ACL: 123,
  887. TIMEOUT: 124,
  888. INVALID_EMAIL_ADDRESS: 125,
  889. MISSING_CONTENT_TYPE: 126,
  890. MISSING_CONTENT_LENGTH: 127,
  891. INVALID_CONTENT_LENGTH: 128,
  892. FILE_TOO_LARGE: 129,
  893. FILE_SAVE_ERROR: 130,
  894. DUPLICATE_VALUE: 137,
  895. INVALID_ROLE_NAME: 139,
  896. EXCEEDED_QUOTA: 140,
  897. SCRIPT_FAILED: 141,
  898. VALIDATION_ERROR: 142,
  899. INVALID_IMAGE_DATA: 150,
  900. UNSAVED_FILE_ERROR: 151,
  901. INVALID_PUSH_TIME_ERROR: 152,
  902. FILE_DELETE_ERROR: 153,
  903. REQUEST_LIMIT_EXCEEDED: 155,
  904. INVALID_EVENT_NAME: 160,
  905. USERNAME_MISSING: 200,
  906. PASSWORD_MISSING: 201,
  907. USERNAME_TAKEN: 202,
  908. EMAIL_TAKEN: 203,
  909. EMAIL_MISSING: 204,
  910. EMAIL_NOT_FOUND: 205,
  911. SESSION_MISSING: 206,
  912. MUST_CREATE_USER_THROUGH_SIGNUP: 207,
  913. ACCOUNT_ALREADY_LINKED: 208,
  914. LINKED_ID_MISSING: 250,
  915. INVALID_LINKED_SESSION: 251,
  916. UNSUPPORTED_SERVICE: 252,
  917. AGGREGATE_ERROR: 600,
  918. FILE_READ_ERROR: 601,
  919. X_DOMAIN_REQUEST: 602
  920. })
  921. }(this),
  922. function() {
  923. var a = this,
  924. b = a.Parse || (a.Parse = {}),
  925. c = /\s+/,
  926. d = Array.prototype.slice;
  927. b.Events = {
  928. on: function(a, b, d) {
  929. var e, f, g, h, i;
  930. if (!b) return this;
  931. for (a = a.split(c), e = this._callbacks || (this._callbacks = {}), f = a.shift(); f;) i = e[f], g = i ? i.tail : {}, g.next = h = {}, g.context = d, g.callback = b, e[f] = {
  932. tail: h,
  933. next: i ? i.next : g
  934. }, f = a.shift();
  935. return this
  936. },
  937. off: function(a, b, d) {
  938. var e, f, g, h, i, j;
  939. if (f = this._callbacks) {
  940. if (!(a || b || d)) return delete this._callbacks, this;
  941. for (a = a ? a.split(c) : _.keys(f), e = a.shift(); e;)
  942. if (g = f[e], delete f[e], g && (b || d)) {
  943. for (h = g.tail, g = g.next; g !== h;) i = g.callback, j = g.context, (b && i !== b || d && j !== d) && this.on(e, i, j), g = g.next;
  944. e = a.shift()
  945. } else e = a.shift();
  946. return this
  947. }
  948. },
  949. trigger: function(a) {
  950. var b, e, f, g, h, i, j;
  951. if (!(f = this._callbacks)) return this;
  952. for (i = f.all, a = a.split(c), j = d.call(arguments, 1), b = a.shift(); b;) {
  953. if (e = f[b])
  954. for (g = e.tail;
  955. (e = e.next) !== g;) e.callback.apply(e.context || this, j);
  956. if (e = i)
  957. for (g = e.tail, h = [b].concat(j);
  958. (e = e.next) !== g;) e.callback.apply(e.context || this, h);
  959. b = a.shift()
  960. }
  961. return this
  962. }
  963. }, b.Events.bind = b.Events.on, b.Events.unbind = b.Events.off
  964. }.call(this),
  965. function(a) {
  966. a.Parse = a.Parse || {};
  967. var b = a.Parse,
  968. c = b._;
  969. b.GeoPoint = function(a, d) {
  970. c.isArray(a) ? (b.GeoPoint._validate(a[0], a[1]), this.latitude = a[0], this.longitude = a[1]) : c.isObject(a) ? (b.GeoPoint._validate(a.latitude, a.longitude), this.latitude = a.latitude, this.longitude = a.longitude) : c.isNumber(a) && c.isNumber(d) ? (b.GeoPoint._validate(a, d), this.latitude = a, this.longitude = d) : (this.latitude = 0, this.longitude = 0);
  971. var e = this;
  972. this.__defineGetter__ && this.__defineSetter__ && (this._latitude = this.latitude, this._longitude = this.longitude, this.__defineGetter__("latitude", function() {
  973. return e._latitude
  974. }), this.__defineGetter__("longitude", function() {
  975. return e._longitude
  976. }), this.__defineSetter__("latitude", function(a) {
  977. b.GeoPoint._validate(a, e.longitude), e._latitude = a
  978. }), this.__defineSetter__("longitude", function(a) {
  979. b.GeoPoint._validate(e.latitude, a), e._longitude = a
  980. }))
  981. }, b.GeoPoint._validate = function(a, b) {
  982. if (-90 > a) throw "Parse.GeoPoint latitude " + a + " < -90.0.";
  983. if (a > 90) throw "Parse.GeoPoint latitude " + a + " > 90.0.";
  984. if (-180 > b) throw "Parse.GeoPoint longitude " + b + " < -180.0.";
  985. if (b > 180) throw "Parse.GeoPoint longitude " + b + " > 180.0."
  986. }, b.GeoPoint.current = function(a) {
  987. var c = new b.Promise;
  988. return navigator.geolocation.getCurrentPosition(function(a) {
  989. c.resolve(new b.GeoPoint({
  990. latitude: a.coords.latitude,
  991. longitude: a.coords.longitude
  992. }))
  993. }, function(a) {
  994. c.reject(a)
  995. }), c._thenRunCallbacks(a)
  996. }, b.GeoPoint.prototype = {
  997. toJSON: function() {
  998. return b.GeoPoint._validate(this.latitude, this.longitude), {
  999. __type: "GeoPoint",
  1000. latitude: this.latitude,
  1001. longitude: this.longitude
  1002. }
  1003. },
  1004. radiansTo: function(a) {
  1005. var b = Math.PI / 180,
  1006. c = this.latitude * b,
  1007. d = this.longitude * b,
  1008. e = a.latitude * b,
  1009. f = a.longitude * b,
  1010. g = c - e,
  1011. h = d - f,
  1012. i = Math.sin(g / 2),
  1013. j = Math.sin(h / 2),
  1014. k = i * i + Math.cos(c) * Math.cos(e) * j * j;
  1015. return k = Math.min(1, k), 2 * Math.asin(Math.sqrt(k))
  1016. },
  1017. kilometersTo: function(a) {
  1018. return 6371 * this.radiansTo(a)
  1019. },
  1020. milesTo: function(a) {
  1021. return 3958.8 * this.radiansTo(a)
  1022. }
  1023. }
  1024. }(this),
  1025. function(a) {
  1026. a.Parse = a.Parse || {};
  1027. var b = a.Parse,
  1028. c = b._,
  1029. d = "*";
  1030. b.ACL = function(a) {
  1031. var d = this;
  1032. if (d.permissionsById = {}, c.isObject(a))
  1033. if (a instanceof b.User) d.setReadAccess(a, !0), d.setWriteAccess(a, !0);
  1034. else {
  1035. if (c.isFunction(a)) throw "Parse.ACL() called with a function. Did you forget ()?";
  1036. b._objectEach(a, function(a, e) {
  1037. if (!c.isString(e)) throw "Tried to create an ACL with an invalid userId.";
  1038. d.permissionsById[e] = {}, b._objectEach(a, function(a, b) {
  1039. if ("read" !== b && "write" !== b) throw "Tried to create an ACL with an invalid permission type.";
  1040. if (!c.isBoolean(a)) throw "Tried to create an ACL with an invalid permission value.";
  1041. d.permissionsById[e][b] = a
  1042. })
  1043. })
  1044. }
  1045. }, b.ACL.prototype.toJSON = function() {
  1046. return c.clone(this.permissionsById)
  1047. }, b.ACL.prototype._setAccess = function(a, d, e) {
  1048. if (d instanceof b.User ? d = d.id : d instanceof b.Role && (d = "role:" + d.getName()), !c.isString(d)) throw "userId must be a string.";
  1049. if (!c.isBoolean(e)) throw "allowed must be either true or false.";
  1050. var f = this.permissionsById[d];
  1051. if (!f) {
  1052. if (!e) return;
  1053. f = {}, this.permissionsById[d] = f
  1054. }
  1055. e ? this.permissionsById[d][a] = !0 : (delete f[a], c.isEmpty(f) && delete f[d])
  1056. }, b.ACL.prototype._getAccess = function(a, c) {
  1057. c instanceof b.User ? c = c.id : c instanceof b.Role && (c = "role:" + c.getName());
  1058. var d = this.permissionsById[c];
  1059. return d ? d[a] ? !0 : !1 : !1
  1060. }, b.ACL.prototype.setReadAccess = function(a, b) {
  1061. this._setAccess("read", a, b)
  1062. }, b.ACL.prototype.getReadAccess = function(a) {
  1063. return this._getAccess("read", a)
  1064. }, b.ACL.prototype.setWriteAccess = function(a, b) {
  1065. this._setAccess("write", a, b)
  1066. }, b.ACL.prototype.getWriteAccess = function(a) {
  1067. return this._getAccess("write", a)
  1068. }, b.ACL.prototype.setPublicReadAccess = function(a) {
  1069. this.setReadAccess(d, a)
  1070. }, b.ACL.prototype.getPublicReadAccess = function() {
  1071. return this.getReadAccess(d)
  1072. }, b.ACL.prototype.setPublicWriteAccess = function(a) {
  1073. this.setWriteAccess(d, a)
  1074. }, b.ACL.prototype.getPublicWriteAccess = function() {
  1075. return this.getWriteAccess(d)
  1076. }, b.ACL.prototype.getRoleReadAccess = function(a) {
  1077. if (a instanceof b.Role && (a = a.getName()), c.isString(a)) return this.getReadAccess("role:" + a);
  1078. throw "role must be a Parse.Role or a String"
  1079. }, b.ACL.prototype.getRoleWriteAccess = function(a) {
  1080. if (a instanceof b.Role && (a = a.getName()), c.isString(a)) return this.getWriteAccess("role:" + a);
  1081. throw "role must be a Parse.Role or a String"
  1082. }, b.ACL.prototype.setRoleReadAccess = function(a, d) {
  1083. if (a instanceof b.Role && (a = a.getName()), c.isString(a)) return this.setReadAccess("role:" + a, d), void 0;
  1084. throw "role must be a Parse.Role or a String"
  1085. }, b.ACL.prototype.setRoleWriteAccess = function(a, d) {
  1086. if (a instanceof b.Role && (a = a.getName()), c.isString(a)) return this.setWriteAccess("role:" + a, d), void 0;
  1087. throw "role must be a Parse.Role or a String"
  1088. }
  1089. }(this),
  1090. function(a) {
  1091. a.Parse = a.Parse || {};
  1092. var b = a.Parse,
  1093. c = b._;
  1094. b.Op = function() {
  1095. this._initialize.apply(this, arguments)
  1096. }, b.Op.prototype = {
  1097. _initialize: function() {}
  1098. }, c.extend(b.Op, {
  1099. _extend: b._extend,
  1100. _opDecoderMap: {},
  1101. _registerDecoder: function(a, c) {
  1102. b.Op._opDecoderMap[a] = c
  1103. },
  1104. _decode: function(a) {
  1105. var c = b.Op._opDecoderMap[a.__op];
  1106. return c ? c(a) : void 0
  1107. }
  1108. }), b.Op._registerDecoder("Batch", function(a) {
  1109. var c = null;
  1110. return b._arrayEach(a.ops, function(a) {
  1111. a = b.Op._decode(a), c = a._mergeWithPrevious(c)
  1112. }), c
  1113. }), b.Op.Set = b.Op._extend({
  1114. _initialize: function(a) {
  1115. this._value = a
  1116. },
  1117. value: function() {
  1118. return this._value
  1119. },
  1120. toJSON: function() {
  1121. return b._encode(this.value())
  1122. },
  1123. _mergeWithPrevious: function() {
  1124. return this
  1125. },
  1126. _estimate: function() {
  1127. return this.value()
  1128. }
  1129. }), b.Op._UNSET = {}, b.Op.Unset = b.Op._extend({
  1130. toJSON: function() {
  1131. return {
  1132. __op: "Delete"
  1133. }
  1134. },
  1135. _mergeWithPrevious: function() {
  1136. return this
  1137. },
  1138. _estimate: function() {
  1139. return b.Op._UNSET
  1140. }
  1141. }), b.Op._registerDecoder("Delete", function() {
  1142. return new b.Op.Unset
  1143. }), b.Op.Increment = b.Op._extend({
  1144. _initialize: function(a) {
  1145. this._amount = a
  1146. },
  1147. amount: function() {
  1148. return this._amount
  1149. },
  1150. toJSON: function() {
  1151. return {
  1152. __op: "Increment",
  1153. amount: this._amount
  1154. }
  1155. },
  1156. _mergeWithPrevious: function(a) {
  1157. if (a) {
  1158. if (a instanceof b.Op.Unset) return new b.Op.Set(this.amount());
  1159. if (a instanceof b.Op.Set) return new b.Op.Set(a.value() + this.amount());
  1160. if (a instanceof b.Op.Increment) return new b.Op.Increment(this.amount() + a.amount());
  1161. throw "Op is invalid after previous op."
  1162. }
  1163. return this
  1164. },
  1165. _estimate: function(a) {
  1166. return a ? a + this.amount() : this.amount()
  1167. }
  1168. }), b.Op._registerDecoder("Increment", function(a) {
  1169. return new b.Op.Increment(a.amount)
  1170. }), b.Op.Add = b.Op._extend({
  1171. _initialize: function(a) {
  1172. this._objects = a
  1173. },
  1174. objects: function() {
  1175. return this._objects
  1176. },
  1177. toJSON: function() {
  1178. return {
  1179. __op: "Add",
  1180. objects: b._encode(this.objects())
  1181. }
  1182. },
  1183. _mergeWithPrevious: function(a) {
  1184. if (a) {
  1185. if (a instanceof b.Op.Unset) return new b.Op.Set(this.objects());
  1186. if (a instanceof b.Op.Set) return new b.Op.Set(this._estimate(a.value()));
  1187. if (a instanceof b.Op.Add) return new b.Op.Add(a.objects().concat(this.objects()));
  1188. throw "Op is invalid after previous op."
  1189. }
  1190. return this
  1191. },
  1192. _estimate: function(a) {
  1193. return a ? a.concat(this.objects()) : c.clone(this.objects())
  1194. }
  1195. }), b.Op._registerDecoder("Add", function(a) {
  1196. return new b.Op.Add(b._decode(void 0, a.objects))
  1197. }), b.Op.AddUnique = b.Op._extend({
  1198. _initialize: function(a) {
  1199. this._objects = c.uniq(a)
  1200. },
  1201. objects: function() {
  1202. return this._objects
  1203. },
  1204. toJSON: function() {
  1205. return {
  1206. __op: "AddUnique",
  1207. objects: b._encode(this.objects())
  1208. }
  1209. },
  1210. _mergeWithPrevious: function(a) {
  1211. if (a) {
  1212. if (a instanceof b.Op.Unset) return new b.Op.Set(this.objects());
  1213. if (a instanceof b.Op.Set) return new b.Op.Set(this._estimate(a.value()));
  1214. if (a instanceof b.Op.AddUnique) return new b.Op.AddUnique(this._estimate(a.objects()));
  1215. throw "Op is invalid after previous op."
  1216. }
  1217. return this
  1218. },
  1219. _estimate: function(a) {
  1220. if (a) {
  1221. var d = c.clone(a);
  1222. return b._arrayEach(this.objects(), function(a) {
  1223. if (a instanceof b.Object && a.id) {
  1224. var e = c.find(d, function(c) {
  1225. return c instanceof b.Object && c.id === a.id
  1226. });
  1227. if (e) {
  1228. var f = c.indexOf(d, e);
  1229. d[f] = a
  1230. } else d.push(a)
  1231. } else c.contains(d, a) || d.push(a)
  1232. }), d
  1233. }
  1234. return c.clone(this.objects())
  1235. }
  1236. }), b.Op._registerDecoder("AddUnique", function(a) {
  1237. return new b.Op.AddUnique(b._decode(void 0, a.objects))
  1238. }), b.Op.Remove = b.Op._extend({
  1239. _initialize: function(a) {
  1240. this._objects = c.uniq(a)
  1241. },
  1242. objects: function() {
  1243. return this._objects
  1244. },
  1245. toJSON: function() {
  1246. return {
  1247. __op: "Remove",
  1248. objects: b._encode(this.objects())
  1249. }
  1250. },
  1251. _mergeWithPrevious: function(a) {
  1252. if (a) {
  1253. if (a instanceof b.Op.Unset) return a;
  1254. if (a instanceof b.Op.Set) return new b.Op.Set(this._estimate(a.value()));
  1255. if (a instanceof b.Op.Remove) return new b.Op.Remove(c.union(a.objects(), this.objects()));
  1256. throw "Op is invalid after previous op."
  1257. }
  1258. return this
  1259. },
  1260. _estimate: function(a) {
  1261. if (a) {
  1262. var d = c.difference(a, this.objects());
  1263. return b._arrayEach(this.objects(), function(a) {
  1264. a instanceof b.Object && a.id && (d = c.reject(d, function(c) {
  1265. return c instanceof b.Object && c.id === a.id
  1266. }))
  1267. }), d
  1268. }
  1269. return []
  1270. }
  1271. }), b.Op._registerDecoder("Remove", function(a) {
  1272. return new b.Op.Remove(b._decode(void 0, a.objects))
  1273. }), b.Op.Relation = b.Op._extend({
  1274. _initialize: function(a, d) {
  1275. this._targetClassName = null;
  1276. var e = this,
  1277. f = function(a) {
  1278. if (a instanceof b.Object) {
  1279. if (!a.id) throw "You can't add an unsaved Parse.Object to a relation.";
  1280. if (e._targetClassName || (e._targetClassName = a.className), e._targetClassName !== a.className) throw "Tried to create a Parse.Relation with 2 different types: " + e._targetClassName + " and " + a.className + ".";
  1281. return a.id
  1282. }
  1283. return a
  1284. };
  1285. this.relationsToAdd = c.uniq(c.map(a, f)), this.relationsToRemove = c.uniq(c.map(d, f))
  1286. },
  1287. added: function() {
  1288. var a = this;
  1289. return c.map(this.relationsToAdd, function(c) {
  1290. var d = b.Object._create(a._targetClassName);
  1291. return d.id = c, d
  1292. })
  1293. },
  1294. removed: function() {
  1295. var a = this;
  1296. return c.map(this.relationsToRemove, function(c) {
  1297. var d = b.Object._create(a._targetClassName);
  1298. return d.id = c, d
  1299. })
  1300. },
  1301. toJSON: function() {
  1302. var a = null,
  1303. b = null,
  1304. d = this,
  1305. e = function(a) {
  1306. return {
  1307. __type: "Pointer",
  1308. className: d._targetClassName,
  1309. objectId: a
  1310. }
  1311. },
  1312. f = null;
  1313. return this.relationsToAdd.length > 0 && (f = c.map(this.relationsToAdd, e), a = {
  1314. __op: "AddRelation",
  1315. objects: f
  1316. }), this.relationsToRemove.length > 0 && (f = c.map(this.relationsToRemove, e), b = {
  1317. __op: "RemoveRelation",
  1318. objects: f
  1319. }), a && b ? {
  1320. __op: "Batch",
  1321. ops: [a, b]
  1322. } : a || b || {}
  1323. },
  1324. _mergeWithPrevious: function(a) {
  1325. if (a) {
  1326. if (a instanceof b.Op.Unset) throw "You can't modify a relation after deleting it.";
  1327. if (a instanceof b.Op.Relation) {
  1328. if (a._targetClassName && a._targetClassName !== this._targetClassName) throw "Related object must be of class " + a._targetClassName + ", but " + this._targetClassName + " was passed in.";
  1329. var d = c.union(c.difference(a.relationsToAdd, this.relationsToRemove), this.relationsToAdd),
  1330. e = c.union(c.difference(a.relationsToRemove, this.relationsToAdd), this.relationsToRemove),
  1331. f = new b.Op.Relation(d, e);
  1332. return f._targetClassName = this._targetClassName, f
  1333. }
  1334. throw "Op is invalid after previous op."
  1335. }
  1336. return this
  1337. },
  1338. _estimate: function(a, c, d) {
  1339. if (a) {
  1340. if (a instanceof b.Relation) {
  1341. if (this._targetClassName)
  1342. if (a.targetClassName) {
  1343. if (a.targetClassName !== this._targetClassName) throw "Related object must be a " + a.targetClassName + ", but a " + this._targetClassName + " was passed in."
  1344. } else a.targetClassName = this._targetClassName;
  1345. return a
  1346. }
  1347. throw "Op is invalid after previous op."
  1348. }
  1349. var e = new b.Relation(c, d);
  1350. e.targetClassName = this._targetClassName
  1351. }
  1352. }), b.Op._registerDecoder("AddRelation", function(a) {
  1353. return new b.Op.Relation(b._decode(void 0, a.objects), [])
  1354. }), b.Op._registerDecoder("RemoveRelation", function(a) {
  1355. return new b.Op.Relation([], b._decode(void 0, a.objects))
  1356. })
  1357. }(this),
  1358. function(a) {
  1359. a.Parse = a.Parse || {};
  1360. var b = a.Parse,
  1361. c = b._;
  1362. b.Relation = function(a, b) {
  1363. this.parent = a, this.key = b, this.targetClassName = null
  1364. }, b.Relation.prototype = {
  1365. _ensureParentAndKey: function(a, b) {
  1366. if (this.parent = this.parent || a, this.key = this.key || b, this.parent !== a) throw "Internal Error. Relation retrieved from two different Objects.";
  1367. if (this.key !== b) throw "Internal Error. Relation retrieved from two different keys."
  1368. },
  1369. add: function(a) {
  1370. c.isArray(a) || (a = [a]);
  1371. var d = new b.Op.Relation(a, []);
  1372. this.parent.set(this.key, d), this.targetClassName = d._targetClassName
  1373. },
  1374. remove: function(a) {
  1375. c.isArray(a) || (a = [a]);
  1376. var d = new b.Op.Relation([], a);
  1377. this.parent.set(this.key, d), this.targetClassName = d._targetClassName
  1378. },
  1379. toJSON: function() {
  1380. return {
  1381. __type: "Relation",
  1382. className: this.targetClassName
  1383. }
  1384. },
  1385. query: function() {
  1386. var a, c;
  1387. return this.targetClassName ? (a = b.Object._getSubclass(this.targetClassName), c = new b.Query(a)) : (a = b.Object._getSubclass(this.parent.className), c = new b.Query(a), c._extraOptions.redirectClassNameForKey = this.key), c._addCondition("$relatedTo", "object", this.parent._toPointer()), c._addCondition("$relatedTo", "key", this.key), c
  1388. }
  1389. }
  1390. }(this),
  1391. function(a) {
  1392. a.Parse = a.Parse || {};
  1393. var b = a.Parse,
  1394. c = b._;
  1395. b.Promise = function() {
  1396. this._resolved = !1, this._rejected = !1, this._resolvedCallbacks = [], this._rejectedCallbacks = []
  1397. }, c.extend(b.Promise, {
  1398. _isPromisesAPlusCompliant: !1,
  1399. is: function(a) {
  1400. return a && a.then && c.isFunction(a.then)
  1401. },
  1402. as: function() {
  1403. var a = new b.Promise;
  1404. return a.resolve.apply(a, arguments), a
  1405. },
  1406. error: function() {
  1407. var a = new b.Promise;
  1408. return a.reject.apply(a, arguments), a
  1409. },
  1410. when: function(a) {
  1411. var c;
  1412. c = a && b._isNullOrUndefined(a.length) ? arguments : a;
  1413. var d = c.length,
  1414. e = !1,
  1415. f = [],
  1416. g = [];
  1417. if (f.length = c.length, g.length = c.length, 0 === d) return b.Promise.as.apply(this, f);
  1418. var h = new b.Promise,
  1419. i = function() {
  1420. d -= 1, 0 === d && (e ? h.reject(g) : h.resolve.apply(h, f))
  1421. };
  1422. return b._arrayEach(c, function(a, c) {
  1423. b.Promise.is(a) ? a.then(function(a) {
  1424. f[c] = a, i()
  1425. }, function(a) {
  1426. g[c] = a, e = !0, i()
  1427. }) : (f[c] = a, i())
  1428. }), h
  1429. },
  1430. _continueWhile: function(a, c) {
  1431. return a() ? c().then(function() {
  1432. return b.Promise._continueWhile(a, c)
  1433. }) : b.Promise.as()
  1434. }
  1435. }), c.extend(b.Promise.prototype, {
  1436. resolve: function() {
  1437. if (this._resolved || this._rejected) throw "A promise was resolved even though it had already been " + (this._resolved ? "resolved" : "rejected") + ".";
  1438. this._resolved = !0, this._result = arguments;
  1439. var a = arguments;
  1440. b._arrayEach(this._resolvedCallbacks, function(b) {
  1441. b.apply(this, a)
  1442. }), this._resolvedCallbacks = [], this._rejectedCallbacks = []
  1443. },
  1444. reject: function(a) {
  1445. if (this._resolved || this._rejected) throw "A promise was rejected even though it had already been " + (this._resolved ? "resolved" : "rejected") + ".";
  1446. this._rejected = !0, this._error = a, b._arrayEach(this._rejectedCallbacks, function(b) {
  1447. b(a)
  1448. }), this._resolvedCallbacks = [], this._rejectedCallbacks = []
  1449. },
  1450. then: function(a, c) {
  1451. var d = new b.Promise,
  1452. e = function() {
  1453. var c = arguments;
  1454. if (a)
  1455. if (b.Promise._isPromisesAPlusCompliant) try {
  1456. c = [a.apply(this, c)]
  1457. } catch (e) {
  1458. c = [b.Promise.error(e)]
  1459. } else c = [a.apply(this, c)];
  1460. 1 === c.length && b.Promise.is(c[0]) ? c[0].then(function() {
  1461. d.resolve.apply(d, arguments)
  1462. }, function(a) {
  1463. d.reject(a)
  1464. }) : d.resolve.apply(d, c)
  1465. },
  1466. f = function(a) {
  1467. var e = [];
  1468. if (c) {
  1469. if (b.Promise._isPromisesAPlusCompliant) try {
  1470. e = [c(a)]
  1471. } catch (f) {
  1472. e = [b.Promise.error(f)]
  1473. } else e = [c(a)];
  1474. 1 === e.length && b.Promise.is(e[0]) ? e[0].then(function() {
  1475. d.resolve.apply(d, arguments)
  1476. }, function(a) {
  1477. d.reject(a)
  1478. }) : b.Promise._isPromisesAPlusCompliant ? d.resolve.apply(d, e) : d.reject(e[0])
  1479. } else d.reject(a)
  1480. },
  1481. g = function(a) {
  1482. a.call()
  1483. };
  1484. b.Promise._isPromisesAPlusCompliant && ("undefined" != typeof window && window.setTimeout ? g = function(a) {
  1485. window.setTimeout(a, 0)
  1486. } : "undefined" != typeof process && process.nextTick && (g = function(a) {
  1487. process.nextTick(a)
  1488. }));
  1489. var h = this;
  1490. return this._resolved ? g(function() {
  1491. e.apply(h, h._result)
  1492. }) : this._rejected ? g(function() {
  1493. f(h._error)
  1494. }) : (this._resolvedCallbacks.push(e), this._rejectedCallbacks.push(f)), d
  1495. },
  1496. always: function(a) {
  1497. return this.then(a, a)
  1498. },
  1499. done: function(a) {
  1500. return this.then(a)
  1501. },
  1502. fail: function(a) {
  1503. return this.then(null, a)
  1504. },
  1505. _thenRunCallbacks: function(a, d) {
  1506. var e;
  1507. if (c.isFunction(a)) {
  1508. var f = a;
  1509. e = {
  1510. success: function(a) {
  1511. f(a, null)
  1512. },
  1513. error: function(a) {
  1514. f(null, a)
  1515. }
  1516. }
  1517. } else e = c.clone(a);
  1518. return e = e || {}, this.then(function(a) {
  1519. return e.success ? e.success.apply(this, arguments) : d && d.trigger("sync", d, a, e), b.Promise.as.apply(b.Promise, arguments)
  1520. }, function(a) {
  1521. return e.error ? c.isUndefined(d) ? e.error(a) : e.error(d, a) : d && d.trigger("error", d, a, e), b.Promise.error(a)
  1522. })
  1523. },
  1524. _continueWith: function(a) {
  1525. return this.then(function() {
  1526. return a(arguments, null)
  1527. }, function(b) {
  1528. return a(null, b)
  1529. })
  1530. }
  1531. })
  1532. }(this),
  1533. function(a) {
  1534. a.Parse = a.Parse || {};
  1535. var b = a.Parse,
  1536. c = b._,
  1537. d = function(a) {
  1538. if (26 > a) return String.fromCharCode(65 + a);
  1539. if (52 > a) return String.fromCharCode(97 + (a - 26));
  1540. if (62 > a) return String.fromCharCode(48 + (a - 52));
  1541. if (62 === a) return "+";
  1542. if (63 === a) return "/";
  1543. throw "Tried to encode large digit " + a + " in base64."
  1544. },
  1545. e = function(a) {
  1546. var b = [];
  1547. return b.length = Math.ceil(a.length / 3), c.times(b.length, function(c) {
  1548. var e = a[3 * c],
  1549. f = a[3 * c + 1] || 0,
  1550. g = a[3 * c + 2] || 0,
  1551. h = 3 * c + 1 < a.length,
  1552. i = 3 * c + 2 < a.length;
  1553. b[c] = [d(63 & e >> 2), d(48 & e << 4 | 15 & f >> 4), h ? d(60 & f << 2 | 3 & g >> 6) : "=", i ? d(63 & g) : "="].join("")
  1554. }), b.join("")
  1555. },
  1556. f = {
  1557. ai: "application/postscript",
  1558. aif: "audio/x-aiff",
  1559. aifc: "audio/x-aiff",
  1560. aiff: "audio/x-aiff",
  1561. asc: "text/plain",
  1562. atom: "application/atom+xml",
  1563. au: "audio/basic",
  1564. avi: "video/x-msvideo",
  1565. bcpio: "application/x-bcpio",
  1566. bin: "application/octet-stream",
  1567. bmp: "image/bmp",
  1568. cdf: "application/x-netcdf",
  1569. cgm: "image/cgm",
  1570. "class": "application/octet-stream",
  1571. cpio: "application/x-cpio",
  1572. cpt: "application/mac-compactpro",
  1573. csh: "application/x-csh",
  1574. css: "text/css",
  1575. dcr: "application/x-director",
  1576. dif: "video/x-dv",
  1577. dir: "application/x-director",
  1578. djv: "image/vnd.djvu",
  1579. djvu: "image/vnd.djvu",
  1580. dll: "application/octet-stream",
  1581. dmg: "application/octet-stream",
  1582. dms: "application/octet-stream",
  1583. doc: "application/msword",
  1584. docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
  1585. dotx: "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
  1586. docm: "application/vnd.ms-word.document.macroEnabled.12",
  1587. dotm: "application/vnd.ms-word.template.macroEnabled.12",
  1588. dtd: "application/xml-dtd",
  1589. dv: "video/x-dv",
  1590. dvi: "application/x-dvi",
  1591. dxr: "application/x-director",
  1592. eps: "application/postscript",
  1593. etx: "text/x-setext",
  1594. exe: "application/octet-stream",
  1595. ez: "application/andrew-inset",
  1596. gif: "image/gif",
  1597. gram: "application/srgs",
  1598. grxml: "application/srgs+xml",
  1599. gtar: "application/x-gtar",
  1600. hdf: "application/x-hdf",
  1601. hqx: "application/mac-binhex40",
  1602. htm: "text/html",
  1603. html: "text/html",
  1604. ice: "x-conference/x-cooltalk",
  1605. ico: "image/x-icon",
  1606. ics: "text/calendar",
  1607. ief: "image/ief",
  1608. ifb: "text/calendar",
  1609. iges: "model/iges",
  1610. igs: "model/iges",
  1611. jnlp: "application/x-java-jnlp-file",
  1612. jp2: "image/jp2",
  1613. jpe: "image/jpeg",
  1614. jpeg: "image/jpeg",
  1615. jpg: "image/jpeg",
  1616. js: "application/x-javascript",
  1617. kar: "audio/midi",
  1618. latex: "application/x-latex",
  1619. lha: "application/octet-stream",
  1620. lzh: "application/octet-stream",
  1621. m3u: "audio/x-mpegurl",
  1622. m4a: "audio/mp4a-latm",
  1623. m4b: "audio/mp4a-latm",
  1624. m4p: "audio/mp4a-latm",
  1625. m4u: "video/vnd.mpegurl",
  1626. m4v: "video/x-m4v",
  1627. mac: "image/x-macpaint",
  1628. man: "application/x-troff-man",
  1629. mathml: "application/mathml+xml",
  1630. me: "application/x-troff-me",
  1631. mesh: "model/mesh",
  1632. mid: "audio/midi",
  1633. midi: "audio/midi",
  1634. mif: "application/vnd.mif",
  1635. mov: "video/quicktime",
  1636. movie: "video/x-sgi-movie",
  1637. mp2: "audio/mpeg",
  1638. mp3: "audio/mpeg",
  1639. mp4: "video/mp4",
  1640. mpe: "video/mpeg",
  1641. mpeg: "video/mpeg",
  1642. mpg: "video/mpeg",
  1643. mpga: "audio/mpeg",
  1644. ms: "application/x-troff-ms",
  1645. msh: "model/mesh",
  1646. mxu: "video/vnd.mpegurl",
  1647. nc: "application/x-netcdf",
  1648. oda: "application/oda",
  1649. ogg: "application/ogg",
  1650. pbm: "image/x-portable-bitmap",
  1651. pct: "image/pict",
  1652. pdb: "chemical/x-pdb",
  1653. pdf: "application/pdf",
  1654. pgm: "image/x-portable-graymap",
  1655. pgn: "application/x-chess-pgn",
  1656. pic: "image/pict",
  1657. pict: "image/pict",
  1658. png: "image/png",
  1659. pnm: "image/x-portable-anymap",
  1660. pnt: "image/x-macpaint",
  1661. pntg: "image/x-macpaint",
  1662. ppm: "image/x-portable-pixmap",
  1663. ppt: "application/vnd.ms-powerpoint",
  1664. pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
  1665. potx: "application/vnd.openxmlformats-officedocument.presentationml.template",
  1666. ppsx: "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
  1667. ppam: "application/vnd.ms-powerpoint.addin.macroEnabled.12",
  1668. pptm: "application/vnd.ms-powerpoint.presentation.macroEnabled.12",
  1669. potm: "application/vnd.ms-powerpoint.template.macroEnabled.12",
  1670. ppsm: "application/vnd.ms-powerpoint.slideshow.macroEnabled.12",
  1671. ps: "application/postscript",
  1672. qt: "video/quicktime",
  1673. qti: "image/x-quicktime",
  1674. qtif: "image/x-quicktime",
  1675. ra: "audio/x-pn-realaudio",
  1676. ram: "audio/x-pn-realaudio",
  1677. ras: "image/x-cmu-raster",
  1678. rdf: "application/rdf+xml",
  1679. rgb: "image/x-rgb",
  1680. rm: "application/vnd.rn-realmedia",
  1681. roff: "application/x-troff",
  1682. rtf: "text/rtf",
  1683. rtx: "text/richtext",
  1684. sgm: "text/sgml",
  1685. sgml: "text/sgml",
  1686. sh: "application/x-sh",
  1687. shar: "application/x-shar",
  1688. silo: "model/mesh",
  1689. sit: "application/x-stuffit",
  1690. skd: "application/x-koan",
  1691. skm: "application/x-koan",
  1692. skp: "application/x-koan",
  1693. skt: "application/x-koan",
  1694. smi: "application/smil",
  1695. smil: "application/smil",
  1696. snd: "audio/basic",
  1697. so: "application/octet-stream",
  1698. spl: "application/x-futuresplash",
  1699. src: "application/x-wais-source",
  1700. sv4cpio: "application/x-sv4cpio",
  1701. sv4crc: "application/x-sv4crc",
  1702. svg: "image/svg+xml",
  1703. swf: "application/x-shockwave-flash",
  1704. t: "application/x-troff",
  1705. tar: "application/x-tar",
  1706. tcl: "application/x-tcl",
  1707. tex: "application/x-tex",
  1708. texi: "application/x-texinfo",
  1709. texinfo: "application/x-texinfo",
  1710. tif: "image/tiff",
  1711. tiff: "image/tiff",
  1712. tr: "application/x-troff",
  1713. tsv: "text/tab-separated-values",
  1714. txt: "text/plain",
  1715. ustar: "application/x-ustar",
  1716. vcd: "application/x-cdlink",
  1717. vrml: "model/vrml",
  1718. vxml: "application/voicexml+xml",
  1719. wav: "audio/x-wav",
  1720. wbmp: "image/vnd.wap.wbmp",
  1721. wbmxl: "application/vnd.wap.wbxml",
  1722. wml: "text/vnd.wap.wml",
  1723. wmlc: "application/vnd.wap.wmlc",
  1724. wmls: "text/vnd.wap.wmlscript",
  1725. wmlsc: "application/vnd.wap.wmlscriptc",
  1726. wrl: "model/vrml",
  1727. xbm: "image/x-xbitmap",
  1728. xht: "application/xhtml+xml",
  1729. xhtml: "application/xhtml+xml",
  1730. xls: "application/vnd.ms-excel",
  1731. xml: "application/xml",
  1732. xpm: "image/x-xpixmap",
  1733. xsl: "application/xml",
  1734. xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
  1735. xltx: "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
  1736. xlsm: "application/vnd.ms-excel.sheet.macroEnabled.12",
  1737. xltm: "application/vnd.ms-excel.template.macroEnabled.12",
  1738. xlam: "application/vnd.ms-excel.addin.macroEnabled.12",
  1739. xlsb: "application/vnd.ms-excel.sheet.binary.macroEnabled.12",
  1740. xslt: "application/xslt+xml",
  1741. xul: "application/vnd.mozilla.xul+xml",
  1742. xwd: "image/x-xwindowdump",
  1743. xyz: "chemical/x-xyz",
  1744. zip: "application/zip"
  1745. },
  1746. g = function(a, c) {
  1747. var d = new b.Promise;
  1748. if ("undefined" == typeof FileReader) return b.Promise.error(new b.Error(b.Error.FILE_READ_ERROR, "Attempted to use a FileReader on an unsupported browser."));
  1749. var e = new FileReader;
  1750. return e.onloadend = function() {
  1751. if (2 !== e.readyState) return d.reject(new b.Error(b.Error.FILE_READ_ERROR, "Error reading file.")), void 0;
  1752. var a = e.result,
  1753. f = /^data:([^;]*);base64,(.*)$/.exec(a);
  1754. return f ? (d.resolve(f[2], c || f[1]), void 0) : (d.reject(new b.Error(b.Error.FILE_READ_ERROR, "Unable to interpret data URL: " + a)), void 0)
  1755. }, e.readAsDataURL(a), d
  1756. };
  1757. b.File = function(a, d, h) {
  1758. this._name = a;
  1759. var i = /\.([^.]*)$/.exec(a);
  1760. i && (i = i[1].toLowerCase());
  1761. var j = h || f[i] || "text/plain";
  1762. if (c.isArray(d)) this._source = b.Promise.as(e(d), j);
  1763. else if (d && d.base64) {
  1764. var k = /^data:([a-zA-Z]*\/[a-zA-Z+.-]*);(charset=[a-zA-Z0-9\-\/\s]*,)?base64,(\S+)/,
  1765. l = k.exec(d.base64);
  1766. this._source = l && l.length > 0 ? b.Promise.as(4 === l.length ? l[3] : l[2], l[1]) : b.Promise.as(d.base64, j)
  1767. } else if ("undefined" != typeof File && d instanceof File) this._source = g(d, h);
  1768. else if (c.isString(d)) throw "Creating a Parse.File from a String is not yet supported."
  1769. }, b.File.prototype = {
  1770. name: function() {
  1771. return this._name
  1772. },
  1773. url: function() {
  1774. return this._url
  1775. },
  1776. save: function(a) {
  1777. a = a || {};
  1778. var c = this;
  1779. return c._previousSave || (c._previousSave = c._source.then(function(d, e) {
  1780. var f = {
  1781. base64: d,
  1782. _ContentType: e
  1783. };
  1784. return b._request({
  1785. route: "files",
  1786. className: c._name,
  1787. method: "POST",
  1788. data: f,
  1789. useMasterKey: a.useMasterKey
  1790. })
  1791. }).then(function(a) {
  1792. return c._name = a.name, c._url = a.url, c
  1793. })), c._previousSave._thenRunCallbacks(a)
  1794. }
  1795. }
  1796. }(this),
  1797. function(a) {
  1798. a.Parse = a.Parse || {};
  1799. var b = a.Parse,
  1800. c = b._;
  1801. b.Object = function(a, d) {
  1802. if (c.isString(a)) return b.Object._create.apply(this, arguments);
  1803. a = a || {}, d && d.parse && (a = this.parse(a));
  1804. var e = b._getValue(this, "defaults");
  1805. if (e && (a = c.extend({}, e, a)), d && d.collection && (this.collection = d.collection), this._serverData = {}, this._opSetQueue = [{}], this.attributes = {}, this._hashedJSON = {}, this._escapedAttributes = {}, this.cid = c.uniqueId("c"), this.changed = {}, this._silent = {}, this._pending = {}, !this.set(a, {
  1806. silent: !0
  1807. })) throw new Error("Can't create an invalid Parse.Object");
  1808. this.changed = {}, this._silent = {}, this._pending = {}, this._hasData = !0, this._previousAttributes = c.clone(this.attributes), this.initialize.apply(this, arguments)
  1809. }, b.Object.saveAll = function(a, c) {
  1810. return c = c || {}, b.Object._deepSaveAsync(a, {
  1811. useMasterKey: c.useMasterKey
  1812. })._thenRunCallbacks(c)
  1813. }, b.Object.destroyAll = function(a, d) {
  1814. d = d || {};
  1815. var e = function(a) {
  1816. a.trigger("destroy", a, a.collection, d)
  1817. },
  1818. f = [],
  1819. g = function(a) {
  1820. var g = b.Promise.as();
  1821. return a.length > 0 && (g = g.then(function() {
  1822. return b._request({
  1823. route: "batch",
  1824. method: "POST",
  1825. useMasterKey: d.useMasterKey,
  1826. data: {
  1827. requests: c.map(a, function(a) {
  1828. return {
  1829. method: "DELETE",
  1830. path: "/1/classes/" + a.className + "/" + a.id
  1831. }
  1832. })
  1833. }
  1834. })
  1835. }).then(function(c) {
  1836. b._arrayEach(a, function(a, g) {
  1837. if (c[g].success && d.wait) e(a);
  1838. else if (c[g].error) {
  1839. var h = new b.Error(c[g].error.code, c[g].error.error);
  1840. h.object = a, f.push(h)
  1841. }
  1842. })
  1843. })), g
  1844. },
  1845. h = b.Promise.as(),
  1846. i = [];
  1847. return b._arrayEach(a, function(b, c) {
  1848. if (b.id && d.wait || e(b), b.id && i.push(b), 20 === i.length || c + 1 === a.length) {
  1849. var f = i;
  1850. i = [], h = h.then(function() {
  1851. return g(f)
  1852. })
  1853. }
  1854. }), h.then(function() {
  1855. if (0 === f.length) return !0;
  1856. var a = new b.Error(b.Error.AGGREGATE_ERROR, "Error deleting an object in destroyAll");
  1857. return a.errors = f, b.Promise.error(a)
  1858. })._thenRunCallbacks(d)
  1859. }, b.Object.fetchAll = function(a, c) {
  1860. return b.Object._fetchAll(a, !0)._thenRunCallbacks(c)
  1861. }, b.Object.fetchAllIfNeeded = function(a, c) {
  1862. return b.Object._fetchAll(a, !1)._thenRunCallbacks(c)
  1863. }, c.extend(b.Object.prototype, b.Events, {
  1864. _existed: !1,
  1865. initialize: function() {},
  1866. toJSON: function() {
  1867. var a = this._toFullJSON();
  1868. return b._arrayEach(["__type", "className"], function(b) {
  1869. delete a[b]
  1870. }), a
  1871. },
  1872. _toFullJSON: function(a) {
  1873. var d = c.clone(this.attributes);
  1874. return b._objectEach(d, function(c, e) {
  1875. d[e] = b._encode(c, a)
  1876. }), b._objectEach(this._operations, function(a, b) {
  1877. d[b] = a
  1878. }), c.has(this, "id") && (d.objectId = this.id), c.has(this, "createdAt") && (d.createdAt = c.isDate(this.createdAt) ? this.createdAt.toJSON() : this.createdAt), c.has(this, "updatedAt") && (d.updatedAt = c.isDate(this.updatedAt) ? this.updatedAt.toJSON() : this.updatedAt), d.__type = "Object", d.className = this.className, d
  1879. },
  1880. _refreshCache: function() {
  1881. var a = this;
  1882. a._refreshingCache || (a._refreshingCache = !0, b._objectEach(this.attributes, function(d, e) {
  1883. d instanceof b.Object ? d._refreshCache() : c.isObject(d) && a._resetCacheForKey(e) && a.set(e, new b.Op.Set(d), {
  1884. silent: !0
  1885. })
  1886. }), delete a._refreshingCache)
  1887. },
  1888. dirty: function(a) {
  1889. this._refreshCache();
  1890. var b = c.last(this._opSetQueue);
  1891. return a ? b[a] ? !0 : !1 : this.id ? c.keys(b).length > 0 ? !0 : !1 : !0
  1892. },
  1893. dirtyKeys: function() {
  1894. return c.keys(c.last(this._opSetQueue))
  1895. },
  1896. _toPointer: function() {
  1897. if (!this.id) throw new Error("Can't serialize an unsaved Parse.Object");
  1898. return {
  1899. __type: "Pointer",
  1900. className: this.className,
  1901. objectId: this.id
  1902. }
  1903. },
  1904. get: function(a) {
  1905. return this.attributes[a]
  1906. },
  1907. relation: function(a) {
  1908. var c = this.get(a);
  1909. if (c) {
  1910. if (!(c instanceof b.Relation)) throw "Called relation() on non-relation field " + a;
  1911. return c._ensureParentAndKey(this, a), c
  1912. }
  1913. return new b.Relation(this, a)
  1914. },
  1915. escape: function(a) {
  1916. var d = this._escapedAttributes[a];
  1917. if (d) return d;
  1918. var e, f = this.attributes[a];
  1919. return e = b._isNullOrUndefined(f) ? "" : c.escape(f.toString()), this._escapedAttributes[a] = e, e
  1920. },
  1921. has: function(a) {
  1922. return !b._isNullOrUndefined(this.attributes[a])
  1923. },
  1924. _mergeMagicFields: function(a) {
  1925. var d = this,
  1926. e = ["id", "objectId", "createdAt", "updatedAt"];
  1927. b._arrayEach(e, function(e) {
  1928. a[e] && ("objectId" === e ? d.id = a[e] : d[e] = "createdAt" !== e && "updatedAt" !== e || c.isDate(a[e]) ? a[e] : b._parseDate(a[e]), delete a[e])
  1929. })
  1930. },
  1931. _copyServerData: function(a) {
  1932. var c = {};
  1933. b._objectEach(a, function(a, d) {
  1934. c[d] = b._decode(d, a)
  1935. }), this._serverData = c, this._rebuildAllEstimatedData(), this._refreshCache(), this._opSetQueue = [{}], this._rebuildAllEstimatedData()
  1936. },
  1937. _mergeFromObject: function(a) {
  1938. a && (this.id = a.id, this.createdAt = a.createdAt, this.updatedAt = a.updatedAt, this._copyServerData(a._serverData), this._hasData = !0)
  1939. },
  1940. _startSave: function() {
  1941. this._opSetQueue.push({})
  1942. },
  1943. _cancelSave: function() {
  1944. var a = c.first(this._opSetQueue);
  1945. this._opSetQueue = c.rest(this._opSetQueue);
  1946. var d = c.first(this._opSetQueue);
  1947. b._objectEach(a, function(b, c) {
  1948. var e = a[c],
  1949. f = d[c];
  1950. e && f ? d[c] = f._mergeWithPrevious(e) : e && (d[c] = e)
  1951. }), this._saving = this._saving - 1
  1952. },
  1953. _finishSave: function(a) {
  1954. var d = {};
  1955. b._traverse(this.attributes, function(a) {
  1956. a instanceof b.Object && a.id && a._hasData && (d[a.id] = a)
  1957. });
  1958. var e = c.first(this._opSetQueue);
  1959. this._opSetQueue = c.rest(this._opSetQueue), this._applyOpSet(e, this._serverData), this._mergeMagicFields(a);
  1960. var f = this;
  1961. b._objectEach(a, function(a, c) {
  1962. f._serverData[c] = b._decode(c, a);
  1963. var e = b._traverse(f._serverData[c], function(a) {
  1964. return a instanceof b.Object && d[a.id] ? d[a.id] : void 0
  1965. });
  1966. e && (f._serverData[c] = e)
  1967. }), this._rebuildAllEstimatedData(), this._saving = this._saving - 1
  1968. },
  1969. _finishFetch: function(a, b) {
  1970. this._opSetQueue = [{}], this._mergeMagicFields(a), this._copyServerData(a), this._hasData = b
  1971. },
  1972. _applyOpSet: function(a, c) {
  1973. var d = this;
  1974. b._objectEach(a, function(a, e) {
  1975. c[e] = a._estimate(c[e], d, e), c[e] === b.Op._UNSET && delete c[e]
  1976. })
  1977. },
  1978. _resetCacheForKey: function(a) {
  1979. var d = this.attributes[a];
  1980. if (!(!c.isObject(d) || d instanceof b.Object || d instanceof b.File)) {
  1981. d = d.toJSON ? d.toJSON() : d;
  1982. var e = JSON.stringify(d);
  1983. if (this._hashedJSON[a] !== e) {
  1984. var f = !!this._hashedJSON[a];
  1985. return this._hashedJSON[a] = e, f
  1986. }
  1987. }
  1988. return !1
  1989. },
  1990. _rebuildEstimatedDataForKey: function(a) {
  1991. var c = this;
  1992. delete this.attributes[a], this._serverData[a] && (this.attributes[a] = this._serverData[a]), b._arrayEach(this._opSetQueue, function(d) {
  1993. var e = d[a];
  1994. e && (c.attributes[a] = e._estimate(c.attributes[a], c, a), c.attributes[a] === b.Op._UNSET ? delete c.attributes[a] : c._resetCacheForKey(a))
  1995. })
  1996. },
  1997. _rebuildAllEstimatedData: function() {
  1998. var a = this,
  1999. d = c.clone(this.attributes);
  2000. this.attributes = c.clone(this._serverData), b._arrayEach(this._opSetQueue, function(c) {
  2001. a._applyOpSet(c, a.attributes), b._objectEach(c, function(b, c) {
  2002. a._resetCacheForKey(c)
  2003. })
  2004. }), b._objectEach(d, function(b, c) {
  2005. a.attributes[c] !== b && a.trigger("change:" + c, a, a.attributes[c], {})
  2006. }), b._objectEach(this.attributes, function(b, e) {
  2007. c.has(d, e) || a.trigger("change:" + e, a, b, {})
  2008. })
  2009. },
  2010. set: function(a, d, e) {
  2011. var f;
  2012. if (c.isObject(a) || b._isNullOrUndefined(a) ? (f = a, b._objectEach(f, function(a, c) {
  2013. f[c] = b._decode(c, a)
  2014. }), e = d) : (f = {}, f[a] = b._decode(a, d)), e = e || {}, !f) return this;
  2015. f instanceof b.Object && (f = f.attributes), e.unset && b._objectEach(f, function(a, c) {
  2016. f[c] = new b.Op.Unset
  2017. });
  2018. var g = c.clone(f),
  2019. h = this;
  2020. if (b._objectEach(g, function(a, c) {
  2021. a instanceof b.Op && (g[c] = a._estimate(h.attributes[c], h, c), g[c] === b.Op._UNSET && delete g[c])
  2022. }), !this._validate(f, e)) return !1;
  2023. this._mergeMagicFields(f), e.changes = {};
  2024. var i = this._escapedAttributes;
  2025. return this._previousAttributes || {}, b._arrayEach(c.keys(f), function(a) {
  2026. var d = f[a];
  2027. d instanceof b.Relation && (d.parent = h), d instanceof b.Op || (d = new b.Op.Set(d));
  2028. var g = !0;
  2029. d instanceof b.Op.Set && c.isEqual(h.attributes[a], d.value) && (g = !1), g && (delete i[a], e.silent ? h._silent[a] = !0 : e.changes[a] = !0);
  2030. var j = c.last(h._opSetQueue);
  2031. j[a] = d._mergeWithPrevious(j[a]), h._rebuildEstimatedDataForKey(a), g ? (h.changed[a] = h.attributes[a], e.silent || (h._pending[a] = !0)) : (delete h.changed[a], delete h._pending[a])
  2032. }), e.silent || this.change(e), this
  2033. },
  2034. unset: function(a, b) {
  2035. return b = b || {}, b.unset = !0, this.set(a, null, b)
  2036. },
  2037. increment: function(a, d) {
  2038. return (c.isUndefined(d) || c.isNull(d)) && (d = 1), this.set(a, new b.Op.Increment(d))
  2039. },
  2040. add: function(a, c) {
  2041. return this.set(a, new b.Op.Add([c]))
  2042. },
  2043. addUnique: function(a, c) {
  2044. return this.set(a, new b.Op.AddUnique([c]))
  2045. },
  2046. remove: function(a, c) {
  2047. return this.set(a, new b.Op.Remove([c]))
  2048. },
  2049. op: function(a) {
  2050. return c.last(this._opSetQueue)[a]
  2051. },
  2052. clear: function(a) {
  2053. a = a || {}, a.unset = !0;
  2054. var b = c.extend(this.attributes, this._operations);
  2055. return this.set(b, a)
  2056. },
  2057. _getSaveJSON: function() {
  2058. var a = c.clone(c.first(this._opSetQueue));
  2059. return b._objectEach(a, function(b, c) {
  2060. a[c] = b.toJSON()
  2061. }), a
  2062. },
  2063. _canBeSerialized: function() {
  2064. return b.Object._canBeSerializedAsValue(this.attributes)
  2065. },
  2066. fetch: function(a) {
  2067. var c = this;
  2068. a = a || {};
  2069. var d = b._request({
  2070. method: "GET",
  2071. route: "classes",
  2072. className: this.className,
  2073. objectId: this.id,
  2074. useMasterKey: a.useMasterKey
  2075. });
  2076. return d.then(function(a, b, d) {
  2077. return c._finishFetch(c.parse(a, b, d), !0), c
  2078. })._thenRunCallbacks(a, this)
  2079. },
  2080. save: function(a, d, e) {
  2081. var f, g, h;
  2082. if (c.isObject(a) || b._isNullOrUndefined(a) ? (f = a, h = d) : (f = {}, f[a] = d, h = e), !h && f) {
  2083. var i = c.reject(f, function(a, b) {
  2084. return c.include(["success", "error", "wait"], b)
  2085. });
  2086. if (0 === i.length) {
  2087. var j = !0;
  2088. if (c.has(f, "success") && !c.isFunction(f.success) && (j = !1), c.has(f, "error") && !c.isFunction(f.error) && (j = !1), j) return this.save(null, f)
  2089. }
  2090. }
  2091. h = c.clone(h) || {}, h.wait && (g = c.clone(this.attributes));
  2092. var k = c.clone(h) || {};
  2093. k.wait && (k.silent = !0);
  2094. var l;
  2095. if (k.error = function(a, b) {
  2096. l = b
  2097. }, f && !this.set(f, k)) return b.Promise.error(l)._thenRunCallbacks(h, this);
  2098. var m = this;
  2099. m._refreshCache();
  2100. var n = [],
  2101. o = [];
  2102. return b.Object._findUnsavedChildren(m.attributes, n, o), n.length + o.length > 0 ? b.Object._deepSaveAsync(this.attributes, {
  2103. useMasterKey: h.useMasterKey
  2104. }).then(function() {
  2105. return m.save(null, h)
  2106. }, function(a) {
  2107. return b.Promise.error(a)._thenRunCallbacks(h, m)
  2108. }) : (this._startSave(), this._saving = (this._saving || 0) + 1, this._allPreviousSaves = this._allPreviousSaves || b.Promise.as(), this._allPreviousSaves = this._allPreviousSaves._continueWith(function() {
  2109. var a = m.id ? "PUT" : "POST",
  2110. d = m._getSaveJSON(),
  2111. e = "classes",
  2112. i = m.className;
  2113. "_User" !== m.className || m.id || (e = "users", i = null);
  2114. var j = b._request({
  2115. route: e,
  2116. className: i,
  2117. objectId: m.id,
  2118. method: a,
  2119. useMasterKey: h.useMasterKey,
  2120. data: d
  2121. });
  2122. return j = j.then(function(a, b, d) {
  2123. var e = m.parse(a, b, d);
  2124. return h.wait && (e = c.extend(f || {}, e)), m._finishSave(e), h.wait && m.set(g, k), m
  2125. }, function(a) {
  2126. return m._cancelSave(), b.Promise.error(a)
  2127. })._thenRunCallbacks(h, m)
  2128. }), this._allPreviousSaves)
  2129. },
  2130. destroy: function(a) {
  2131. a = a || {};
  2132. var c = this,
  2133. d = function() {
  2134. c.trigger("destroy", c, c.collection, a)
  2135. };
  2136. if (!this.id) return d();
  2137. a.wait || d();
  2138. var e = b._request({
  2139. route: "classes",
  2140. className: this.className,
  2141. objectId: this.id,
  2142. method: "DELETE",
  2143. useMasterKey: a.useMasterKey
  2144. });
  2145. return e.then(function() {
  2146. return a.wait && d(), c
  2147. })._thenRunCallbacks(a, this)
  2148. },
  2149. parse: function(a, d) {
  2150. var e = c.clone(a);
  2151. return c(["createdAt", "updatedAt"]).each(function(a) {
  2152. e[a] && (e[a] = b._parseDate(e[a]))
  2153. }), e.updatedAt || (e.updatedAt = e.createdAt), d && (this._existed = 201 !== d), e
  2154. },
  2155. clone: function() {
  2156. return new this.constructor(this.attributes)
  2157. },
  2158. isNew: function() {
  2159. return !this.id
  2160. },
  2161. change: function(a) {
  2162. a = a || {};
  2163. var d = this._changing;
  2164. this._changing = !0;
  2165. var e = this;
  2166. b._objectEach(this._silent, function(a) {
  2167. e._pending[a] = !0
  2168. });
  2169. var f = c.extend({}, a.changes, this._silent);
  2170. if (this._silent = {}, b._objectEach(f, function(b, c) {
  2171. e.trigger("change:" + c, e, e.get(c), a)
  2172. }), d) return this;
  2173. for (var g = function(a, b) {
  2174. e._pending[b] || e._silent[b] || delete e.changed[b]
  2175. }; !c.isEmpty(this._pending);) this._pending = {}, this.trigger("change", this, a), b._objectEach(this.changed, g), e._previousAttributes = c.clone(this.attributes);
  2176. return this._changing = !1, this
  2177. },
  2178. existed: function() {
  2179. return this._existed
  2180. },
  2181. hasChanged: function(a) {
  2182. return arguments.length ? this.changed && c.has(this.changed, a) : !c.isEmpty(this.changed)
  2183. },
  2184. changedAttributes: function(a) {
  2185. if (!a) return this.hasChanged() ? c.clone(this.changed) : !1;
  2186. var d = {},
  2187. e = this._previousAttributes;
  2188. return b._objectEach(a, function(a, b) {
  2189. c.isEqual(e[b], a) || (d[b] = a)
  2190. }), d
  2191. },
  2192. previous: function(a) {
  2193. return arguments.length && this._previousAttributes ? this._previousAttributes[a] : null
  2194. },
  2195. previousAttributes: function() {
  2196. return c.clone(this._previousAttributes)
  2197. },
  2198. isValid: function() {
  2199. return !this.validate(this.attributes)
  2200. },
  2201. validate: function(a) {
  2202. if (c.has(a, "ACL") && !(a.ACL instanceof b.ACL)) return new b.Error(b.Error.OTHER_CAUSE, "ACL must be a Parse.ACL.");
  2203. var d = !0;
  2204. return b._objectEach(a, function(a, b) {
  2205. /^[A-Za-z][0-9A-Za-z_]*$/.test(b) || (d = !1)
  2206. }), d ? !1 : new b.Error(b.Error.INVALID_KEY_NAME)
  2207. },
  2208. _validate: function(a, b) {
  2209. if (b.silent || !this.validate) return !0;
  2210. a = c.extend({}, this.attributes, a);
  2211. var d = this.validate(a, b);
  2212. return d ? (b && b.error ? b.error(this, d, b) : this.trigger("error", this, d, b), !1) : !0
  2213. },
  2214. getACL: function() {
  2215. return this.get("ACL")
  2216. },
  2217. setACL: function(a, b) {
  2218. return this.set("ACL", a, b)
  2219. }
  2220. }), b.Object._getSubclass = function(a) {
  2221. if (!c.isString(a)) throw "Parse.Object._getSubclass requires a string argument.";
  2222. var d = b.Object._classMap[a];
  2223. return d || (d = b.Object.extend(a), b.Object._classMap[a] = d), d
  2224. }, b.Object._create = function(a, c, d) {
  2225. var e = b.Object._getSubclass(a);
  2226. return new e(c, d)
  2227. }, b.Object._toObjectIdArray = function(a, c) {
  2228. if (0 === a.length) return b.Promise.as(a);
  2229. for (var d, e = a[0].className, f = [], g = 0; g < a.length; g++) {
  2230. var h = a[g];
  2231. if (e !== h.className) return d = new b.Error(b.Error.INVALID_CLASS_NAME, "All objects should be of the same class"), b.Promise.error(d);
  2232. if (!h.id) return d = new b.Error(b.Error.MISSING_OBJECT_ID, "All objects must have an ID"), b.Promise.error(d);
  2233. c && h._hasData || f.push(h.id)
  2234. }
  2235. return b.Promise.as(f)
  2236. }, b.Object._updateWithFetchedResults = function(a, c, d) {
  2237. var e = {};
  2238. b._arrayEach(c, function(a) {
  2239. e[a.id] = a
  2240. });
  2241. for (var f = 0; f < a.length; f++) {
  2242. var g = a[f],
  2243. h = e[g.id];
  2244. if (!h && d) {
  2245. var i = new b.Error(b.Error.OBJECT_NOT_FOUND, "All objects must exist on the server");
  2246. return b.Promise.error(i)
  2247. }
  2248. g._mergeFromObject(h)
  2249. }
  2250. return b.Promise.as(a)
  2251. }, b.Object._fetchAll = function(a, c) {
  2252. if (0 === a.length) return b.Promise.as(a);
  2253. var d = !c;
  2254. return b.Object._toObjectIdArray(a, d).then(function(c) {
  2255. var d = a[0].className,
  2256. e = new b.Query(d);
  2257. return e.containedIn("objectId", c), e.limit = c.length, e.find()
  2258. }).then(function(d) {
  2259. return b.Object._updateWithFetchedResults(a, d, c)
  2260. })
  2261. }, b.Object._classMap = {}, b.Object._extend = b._extend, b.Object.extend = function(a, d, e) {
  2262. if (!c.isString(a)) {
  2263. if (a && c.has(a, "className")) return b.Object.extend(a.className, a, d);
  2264. throw new Error("Parse.Object.extend's first argument should be the className.")
  2265. }
  2266. "User" === a && b.User._performUserRewrite && (a = "_User"), d = d || {}, d.className = a;
  2267. var f = null;
  2268. if (c.has(b.Object._classMap, a)) {
  2269. var g = b.Object._classMap[a];
  2270. f = g._extend(d, e)
  2271. } else f = this._extend(d, e);
  2272. return f.extend = function(d) {
  2273. if (c.isString(d) || d && c.has(d, "className")) return b.Object.extend.apply(f, arguments);
  2274. var e = [a].concat(b._.toArray(arguments));
  2275. return b.Object.extend.apply(f, e)
  2276. }, b.Object._classMap[a] = f, f
  2277. }, b.Object._findUnsavedChildren = function(a, c, d) {
  2278. b._traverse(a, function(a) {
  2279. return a instanceof b.Object ? (a._refreshCache(), a.dirty() && c.push(a), void 0) : a instanceof b.File ? (a.url() || d.push(a), void 0) : void 0
  2280. })
  2281. }, b.Object._canBeSerializedAsValue = function(a) {
  2282. if (a instanceof b.Object) return !!a.id;
  2283. if (a instanceof b.File) return !0;
  2284. var d = !0;
  2285. return c.isArray(a) ? b._arrayEach(a, function(a) {
  2286. b.Object._canBeSerializedAsValue(a) || (d = !1)
  2287. }) : c.isObject(a) && b._objectEach(a, function(a) {
  2288. b.Object._canBeSerializedAsValue(a) || (d = !1)
  2289. }), d
  2290. }, b.Object._deepSaveAsync = function(a, d) {
  2291. var e = [],
  2292. f = [];
  2293. b.Object._findUnsavedChildren(a, e, f);
  2294. var g = b.Promise.as();
  2295. c.each(f, function(a) {
  2296. g = g.then(function() {
  2297. return a.save(d)
  2298. })
  2299. });
  2300. var h = c.uniq(e),
  2301. i = c.uniq(h);
  2302. return g.then(function() {
  2303. return b.Promise._continueWhile(function() {
  2304. return i.length > 0
  2305. }, function() {
  2306. var a = [],
  2307. e = [];
  2308. if (b._arrayEach(i, function(b) {
  2309. return a.length > 20 ? (e.push(b), void 0) : (b._canBeSerialized() ? a.push(b) : e.push(b), void 0)
  2310. }), i = e, 0 === a.length) return b.Promise.error(new b.Error(b.Error.OTHER_CAUSE, "Tried to save a batch with a cycle."));
  2311. var f = b.Promise.when(c.map(a, function(a) {
  2312. return a._allPreviousSaves || b.Promise.as()
  2313. })),
  2314. g = new b.Promise;
  2315. return b._arrayEach(a, function(a) {
  2316. a._allPreviousSaves = g
  2317. }), f._continueWith(function() {
  2318. return b._request({
  2319. route: "batch",
  2320. method: "POST",
  2321. useMasterKey: d.useMasterKey,
  2322. data: {
  2323. requests: c.map(a, function(a) {
  2324. var b = a._getSaveJSON(),
  2325. c = "POST",
  2326. d = "/1/classes/" + a.className;
  2327. return a.id && (d = d + "/" + a.id, c = "PUT"), a._startSave(), {
  2328. method: c,
  2329. path: d,
  2330. body: b
  2331. }
  2332. })
  2333. }
  2334. }).then(function(c, d, e) {
  2335. var f;
  2336. return b._arrayEach(a, function(a, b) {
  2337. c[b].success ? a._finishSave(a.parse(c[b].success, d, e)) : (f = f || c[b].error, a._cancelSave())
  2338. }), f ? b.Promise.error(new b.Error(f.code, f.error)) : void 0
  2339. }).then(function(a) {
  2340. return g.resolve(a), a
  2341. }, function(a) {
  2342. return g.reject(a), b.Promise.error(a)
  2343. })
  2344. })
  2345. })
  2346. }).then(function() {
  2347. return a
  2348. })
  2349. }
  2350. }(this),
  2351. function(a) {
  2352. a.Parse = a.Parse || {};
  2353. var b = a.Parse,
  2354. c = b._;
  2355. b.Role = b.Object.extend("_Role", {
  2356. constructor: function(a, d) {
  2357. c.isString(a) && d instanceof b.ACL ? (b.Object.prototype.constructor.call(this, null, null), this.setName(a), this.setACL(d)) : b.Object.prototype.constructor.call(this, a, d)
  2358. },
  2359. getName: function() {
  2360. return this.get("name")
  2361. },
  2362. setName: function(a, b) {
  2363. return this.set("name", a, b)
  2364. },
  2365. getUsers: function() {
  2366. return this.relation("users")
  2367. },
  2368. getRoles: function() {
  2369. return this.relation("roles")
  2370. },
  2371. validate: function(a, d) {
  2372. if ("name" in a && a.name !== this.getName()) {
  2373. var e = a.name;
  2374. if (this.id && this.id !== a.objectId) return new b.Error(b.Error.OTHER_CAUSE, "A role's name can only be set before it has been saved.");
  2375. if (!c.isString(e)) return new b.Error(b.Error.OTHER_CAUSE, "A role's name must be a String.");
  2376. if (!/^[0-9a-zA-Z\-_ ]+$/.test(e)) return new b.Error(b.Error.OTHER_CAUSE, "A role's name can only contain alphanumeric characters, _, -, and spaces.")
  2377. }
  2378. return b.Object.prototype.validate ? b.Object.prototype.validate.call(this, a, d) : !1
  2379. }
  2380. })
  2381. }(this),
  2382. function(a) {
  2383. a.Parse = a.Parse || {};
  2384. var b = a.Parse,
  2385. c = b._;
  2386. b.Collection = function(a, b) {
  2387. b = b || {}, b.comparator && (this.comparator = b.comparator), b.model && (this.model = b.model), b.query && (this.query = b.query), this._reset(), this.initialize.apply(this, arguments), a && this.reset(a, {
  2388. silent: !0,
  2389. parse: b.parse
  2390. })
  2391. }, c.extend(b.Collection.prototype, b.Events, {
  2392. model: b.Object,
  2393. initialize: function() {},
  2394. toJSON: function() {
  2395. return this.map(function(a) {
  2396. return a.toJSON()
  2397. })
  2398. },
  2399. add: function(a, d) {
  2400. var e, f, g, h, i, j, k = {},
  2401. l = {};
  2402. for (d = d || {}, a = c.isArray(a) ? a.slice() : [a], e = 0, g = a.length; g > e; e++) {
  2403. if (a[e] = this._prepareModel(a[e], d), h = a[e], !h) throw new Error("Can't add an invalid model to a collection");
  2404. if (i = h.cid, k[i] || this._byCid[i]) throw new Error("Duplicate cid: can't add the same model to a collection twice");
  2405. if (j = h.id, !b._isNullOrUndefined(j) && (l[j] || this._byId[j])) throw new Error("Duplicate id: can't add the same model to a collection twice");
  2406. l[j] = h, k[i] = h
  2407. }
  2408. for (e = 0; g > e; e++)(h = a[e]).on("all", this._onModelEvent, this), this._byCid[h.cid] = h, h.id && (this._byId[h.id] = h);
  2409. if (this.length += g, f = b._isNullOrUndefined(d.at) ? this.models.length : d.at, this.models.splice.apply(this.models, [f, 0].concat(a)), this.comparator && this.sort({
  2410. silent: !0
  2411. }), d.silent) return this;
  2412. for (e = 0, g = this.models.length; g > e; e++) h = this.models[e], k[h.cid] && (d.index = e, h.trigger("add", h, this, d));
  2413. return this
  2414. },
  2415. remove: function(a, b) {
  2416. var d, e, f, g;
  2417. for (b = b || {}, a = c.isArray(a) ? a.slice() : [a], d = 0, e = a.length; e > d; d++) g = this.getByCid(a[d]) || this.get(a[d]), g && (delete this._byId[g.id], delete this._byCid[g.cid], f = this.indexOf(g), this.models.splice(f, 1), this.length--, b.silent || (b.index = f, g.trigger("remove", g, this, b)), this._removeReference(g));
  2418. return this
  2419. },
  2420. get: function(a) {
  2421. return a && this._byId[a.id || a]
  2422. },
  2423. getByCid: function(a) {
  2424. return a && this._byCid[a.cid || a]
  2425. },
  2426. at: function(a) {
  2427. return this.models[a]
  2428. },
  2429. sort: function(a) {
  2430. if (a = a || {}, !this.comparator) throw new Error("Cannot sort a set without a comparator");
  2431. var b = c.bind(this.comparator, this);
  2432. return 1 === this.comparator.length ? this.models = this.sortBy(b) : this.models.sort(b), a.silent || this.trigger("reset", this, a), this
  2433. },
  2434. pluck: function(a) {
  2435. return c.map(this.models, function(b) {
  2436. return b.get(a)
  2437. })
  2438. },
  2439. reset: function(a, c) {
  2440. var d = this;
  2441. return a = a || [], c = c || {}, b._arrayEach(this.models, function(a) {
  2442. d._removeReference(a)
  2443. }), this._reset(), this.add(a, {
  2444. silent: !0,
  2445. parse: c.parse
  2446. }), c.silent || this.trigger("reset", this, c), this
  2447. },
  2448. fetch: function(a) {
  2449. a = c.clone(a) || {}, void 0 === a.parse && (a.parse = !0);
  2450. var d = this,
  2451. e = this.query || new b.Query(this.model);
  2452. return e.find({
  2453. useMasterKey: a.useMasterKey
  2454. }).then(function(b) {
  2455. return a.add ? d.add(b, a) : d.reset(b, a), d
  2456. })._thenRunCallbacks(a, this)
  2457. },
  2458. create: function(a, b) {
  2459. var d = this;
  2460. if (b = b ? c.clone(b) : {}, a = this._prepareModel(a, b), !a) return !1;
  2461. b.wait || d.add(a, b);
  2462. var e = b.success;
  2463. return b.success = function(c, f) {
  2464. b.wait && d.add(c, b), e ? e(c, f) : c.trigger("sync", a, f, b)
  2465. }, a.save(null, b), a
  2466. },
  2467. parse: function(a) {
  2468. return a
  2469. },
  2470. chain: function() {
  2471. return c(this.models).chain()
  2472. },
  2473. _reset: function() {
  2474. this.length = 0, this.models = [], this._byId = {}, this._byCid = {}
  2475. },
  2476. _prepareModel: function(a, c) {
  2477. if (a instanceof b.Object) a.collection || (a.collection = this);
  2478. else {
  2479. var d = a;
  2480. c.collection = this, a = new this.model(d, c), a._validate(a.attributes, c) || (a = !1)
  2481. }
  2482. return a
  2483. },
  2484. _removeReference: function(a) {
  2485. this === a.collection && delete a.collection, a.off("all", this._onModelEvent, this)
  2486. },
  2487. _onModelEvent: function(a, b, c, d) {
  2488. ("add" !== a && "remove" !== a || c === this) && ("destroy" === a && this.remove(b, d), b && "change:objectId" === a && (delete this._byId[b.previous("objectId")], this._byId[b.id] = b), this.trigger.apply(this, arguments))
  2489. }
  2490. });
  2491. var d = ["forEach", "each", "map", "reduce", "reduceRight", "find", "detect", "filter", "select", "reject", "every", "all", "some", "any", "include", "contains", "invoke", "max", "min", "sortBy", "sortedIndex", "toArray", "size", "first", "initial", "rest", "last", "without", "indexOf", "shuffle", "lastIndexOf", "isEmpty", "groupBy"];
  2492. b._arrayEach(d, function(a) {
  2493. b.Collection.prototype[a] = function() {
  2494. return c[a].apply(c, [this.models].concat(c.toArray(arguments)))
  2495. }
  2496. }), b.Collection.extend = b._extend
  2497. }(this),
  2498. function(a) {
  2499. a.Parse = a.Parse || {};
  2500. var b = a.Parse,
  2501. c = b._;
  2502. b.View = function(a) {
  2503. this.cid = c.uniqueId("view"), this._configure(a || {}), this._ensureElement(), this.initialize.apply(this, arguments), this.delegateEvents()
  2504. };
  2505. var d = /^(\S+)\s*(.*)$/,
  2506. e = ["model", "collection", "el", "id", "attributes", "className", "tagName"];
  2507. c.extend(b.View.prototype, b.Events, {
  2508. tagName: "div",
  2509. $: function(a) {
  2510. return this.$el.find(a)
  2511. },
  2512. initialize: function() {},
  2513. render: function() {
  2514. return this
  2515. },
  2516. remove: function() {
  2517. return this.$el.remove(), this
  2518. },
  2519. make: function(a, c, d) {
  2520. var e = document.createElement(a);
  2521. return c && b.$(e).attr(c), d && b.$(e).html(d), e
  2522. },
  2523. setElement: function(a, c) {
  2524. return this.$el = b.$(a), this.el = this.$el[0], c !== !1 && this.delegateEvents(), this
  2525. },
  2526. delegateEvents: function(a) {
  2527. if (a = a || b._getValue(this, "events")) {
  2528. this.undelegateEvents();
  2529. var e = this;
  2530. b._objectEach(a, function(b, f) {
  2531. if (c.isFunction(b) || (b = e[a[f]]), !b) throw new Error('Event "' + a[f] + '" does not exist');
  2532. var g = f.match(d),
  2533. h = g[1],
  2534. i = g[2];
  2535. b = c.bind(b, e), h += ".delegateEvents" + e.cid, "" === i ? e.$el.bind(h, b) : e.$el.delegate(i, h, b)
  2536. })
  2537. }
  2538. },
  2539. undelegateEvents: function() {
  2540. this.$el.unbind(".delegateEvents" + this.cid)
  2541. },
  2542. _configure: function(a) {
  2543. this.options && (a = c.extend({}, this.options, a));
  2544. var b = this;
  2545. c.each(e, function(c) {
  2546. a[c] && (b[c] = a[c])
  2547. }), this.options = a
  2548. },
  2549. _ensureElement: function() {
  2550. if (this.el) this.setElement(this.el, !1);
  2551. else {
  2552. var a = b._getValue(this, "attributes") || {};
  2553. this.id && (a.id = this.id), this.className && (a["class"] = this.className), this.setElement(this.make(this.tagName, a), !1)
  2554. }
  2555. }
  2556. }), b.View.extend = b._extend
  2557. }(this),
  2558. function(a) {
  2559. a.Parse = a.Parse || {};
  2560. var b = a.Parse,
  2561. c = b._;
  2562. b.User = b.Object.extend("_User", {
  2563. _isCurrentUser: !1,
  2564. _mergeFromObject: function(a) {
  2565. a.getSessionToken() && (this._sessionToken = a.getSessionToken()), b.User.__super__._mergeFromObject.call(this, a)
  2566. },
  2567. _mergeMagicFields: function(a) {
  2568. a.sessionToken && (this._sessionToken = a.sessionToken, delete a.sessionToken), b.User.__super__._mergeMagicFields.call(this, a)
  2569. },
  2570. _cleanupAuthData: function() {
  2571. if (this.isCurrent()) {
  2572. var a = this.get("authData");
  2573. a && b._objectEach(this.get("authData"), function(b, c) {
  2574. a[c] || delete a[c]
  2575. })
  2576. }
  2577. },
  2578. _synchronizeAllAuthData: function() {
  2579. var a = this.get("authData");
  2580. if (a) {
  2581. var c = this;
  2582. b._objectEach(this.get("authData"), function(a, b) {
  2583. c._synchronizeAuthData(b)
  2584. })
  2585. }
  2586. },
  2587. _synchronizeAuthData: function(a) {
  2588. if (this.isCurrent()) {
  2589. var d;
  2590. c.isString(a) ? (d = a, a = b.User._authProviders[d]) : d = a.getAuthType();
  2591. var e = this.get("authData");
  2592. if (e && a) {
  2593. var f = a.restoreAuthentication(e[d]);
  2594. f || this._unlinkFrom(a)
  2595. }
  2596. }
  2597. },
  2598. _handleSaveResult: function(a) {
  2599. a && (this._isCurrentUser = !0), this._cleanupAuthData(), this._synchronizeAllAuthData(), delete this._serverData.password, this._rebuildEstimatedDataForKey("password"), this._refreshCache(), (a || this.isCurrent()) && b.User._saveCurrentUser(this)
  2600. },
  2601. _linkWith: function(a, d) {
  2602. var e;
  2603. if (c.isString(a) ? (e = a, a = b.User._authProviders[a]) : e = a.getAuthType(), c.has(d, "authData")) {
  2604. var f = this.get("authData") || {};
  2605. f[e] = d.authData, this.set("authData", f);
  2606. var g = c.clone(d) || {};
  2607. return g.success = function(a) {
  2608. a._handleSaveResult(!0), d.success && d.success.apply(this, arguments)
  2609. }, this.save({
  2610. authData: f
  2611. }, g)
  2612. }
  2613. var h = this,
  2614. i = new b.Promise;
  2615. return a.authenticate({
  2616. success: function(a, b) {
  2617. h._linkWith(a, {
  2618. authData: b,
  2619. success: d.success,
  2620. error: d.error
  2621. }).then(function() {
  2622. i.resolve(h)
  2623. })
  2624. },
  2625. error: function(a, b) {
  2626. d.error && d.error(h, b), i.reject(b)
  2627. }
  2628. }), i
  2629. },
  2630. _unlinkFrom: function(a, d) {
  2631. var e;
  2632. c.isString(a) ? (e = a, a = b.User._authProviders[a]) : e = a.getAuthType();
  2633. var f = c.clone(d),
  2634. g = this;
  2635. return f.authData = null, f.success = function() {
  2636. g._synchronizeAuthData(a), d.success && d.success.apply(this, arguments)
  2637. }, this._linkWith(a, f)
  2638. },
  2639. _isLinked: function(a) {
  2640. var b;
  2641. b = c.isString(a) ? a : a.getAuthType();
  2642. var d = this.get("authData") || {};
  2643. return !!d[b]
  2644. },
  2645. _logOutWithAll: function() {
  2646. var a = this.get("authData");
  2647. if (a) {
  2648. var c = this;
  2649. b._objectEach(this.get("authData"), function(a, b) {
  2650. c._logOutWith(b)
  2651. })
  2652. }
  2653. },
  2654. _logOutWith: function(a) {
  2655. this.isCurrent() && (c.isString(a) && (a = b.User._authProviders[a]), a && a.deauthenticate && a.deauthenticate())
  2656. },
  2657. signUp: function(a, d) {
  2658. var e;
  2659. d = d || {};
  2660. var f = a && a.username || this.get("username");
  2661. if (!f || "" === f) return e = new b.Error(b.Error.OTHER_CAUSE, "Cannot sign up user with an empty name."), d && d.error && d.error(this, e), b.Promise.error(e);
  2662. var g = a && a.password || this.get("password");
  2663. if (!g || "" === g) return e = new b.Error(b.Error.OTHER_CAUSE, "Cannot sign up user with an empty password."), d && d.error && d.error(this, e), b.Promise.error(e);
  2664. var h = c.clone(d);
  2665. return h.success = function(a) {
  2666. a._handleSaveResult(!0), d.success && d.success.apply(this, arguments)
  2667. }, this.save(a, h)
  2668. },
  2669. logIn: function(a) {
  2670. var c = this;
  2671. a = a || {};
  2672. var d = b._request({
  2673. route: "login",
  2674. method: "GET",
  2675. useMasterKey: a.useMasterKey,
  2676. data: this.toJSON()
  2677. });
  2678. return d.then(function(a, b, d) {
  2679. var e = c.parse(a, b, d);
  2680. return c._finishFetch(e), c._handleSaveResult(!0), c
  2681. })._thenRunCallbacks(a, this)
  2682. },
  2683. save: function(a, d, e) {
  2684. var f, g;
  2685. c.isObject(a) || c.isNull(a) || c.isUndefined(a) ? (f = a, g = d) : (f = {}, f[a] = d, g = e), g = g || {};
  2686. var h = c.clone(g);
  2687. return h.success = function(a) {
  2688. a._handleSaveResult(!1), g.success && g.success.apply(this, arguments)
  2689. }, b.Object.prototype.save.call(this, f, h)
  2690. },
  2691. fetch: function(a) {
  2692. var d = a ? c.clone(a) : {};
  2693. return d.success = function(b) {
  2694. b._handleSaveResult(!1), a && a.success && a.success.apply(this, arguments)
  2695. }, b.Object.prototype.fetch.call(this, d)
  2696. },
  2697. isCurrent: function() {
  2698. return this._isCurrentUser
  2699. },
  2700. getUsername: function() {
  2701. return this.get("username")
  2702. },
  2703. setUsername: function(a, b) {
  2704. return this.set("username", a, b)
  2705. },
  2706. setPassword: function(a, b) {
  2707. return this.set("password", a, b)
  2708. },
  2709. getEmail: function() {
  2710. return this.get("email")
  2711. },
  2712. setEmail: function(a, b) {
  2713. return this.set("email", a, b)
  2714. },
  2715. authenticated: function() {
  2716. return !!this._sessionToken && b.User.current() && b.User.current().id === this.id
  2717. },
  2718. getSessionToken: function() {
  2719. return this._sessionToken
  2720. }
  2721. }, {
  2722. _currentUser: null,
  2723. _currentUserMatchesDisk: !1,
  2724. _CURRENT_USER_KEY: "currentUser",
  2725. _authProviders: {},
  2726. _performUserRewrite: !0,
  2727. signUp: function(a, c, d, e) {
  2728. d = d || {}, d.username = a, d.password = c;
  2729. var f = b.Object._create("_User");
  2730. return f.signUp(d, e)
  2731. },
  2732. logIn: function(a, c, d) {
  2733. var e = b.Object._create("_User");
  2734. return e._finishFetch({
  2735. username: a,
  2736. password: c
  2737. }), e.logIn(d)
  2738. },
  2739. become: function(a, c) {
  2740. c = c || {};
  2741. var d = b.Object._create("_User");
  2742. return b._request({
  2743. route: "users",
  2744. className: "me",
  2745. method: "GET",
  2746. useMasterKey: c.useMasterKey,
  2747. sessionToken: a
  2748. }).then(function(a, b, c) {
  2749. var e = d.parse(a, b, c);
  2750. return d._finishFetch(e), d._handleSaveResult(!0), d
  2751. })._thenRunCallbacks(c, d)
  2752. },
  2753. logOut: function() {
  2754. null !== b.User._currentUser && (b.User._currentUser._logOutWithAll(), b.User._currentUser._isCurrentUser = !1), b.User._currentUserMatchesDisk = !0, b.User._currentUser = null, b.localStorage.removeItem(b._getParsePath(b.User._CURRENT_USER_KEY))
  2755. },
  2756. requestPasswordReset: function(a, c) {
  2757. c = c || {};
  2758. var d = b._request({
  2759. route: "requestPasswordReset",
  2760. method: "POST",
  2761. useMasterKey: c.useMasterKey,
  2762. data: {
  2763. email: a
  2764. }
  2765. });
  2766. return d._thenRunCallbacks(c)
  2767. },
  2768. current: function() {
  2769. if (b.User._currentUser) return b.User._currentUser;
  2770. if (b.User._currentUserMatchesDisk) return b.User._currentUser;
  2771. b.User._currentUserMatchesDisk = !0;
  2772. var a = b.localStorage.getItem(b._getParsePath(b.User._CURRENT_USER_KEY));
  2773. if (!a) return null;
  2774. b.User._currentUser = b.Object._create("_User"), b.User._currentUser._isCurrentUser = !0;
  2775. var c = JSON.parse(a);
  2776. return b.User._currentUser.id = c._id, delete c._id, b.User._currentUser._sessionToken = c._sessionToken, delete c._sessionToken, b.User._currentUser._finishFetch(c), b.User._currentUser._synchronizeAllAuthData(), b.User._currentUser._refreshCache(), b.User._currentUser._opSetQueue = [{}], b.User._currentUser
  2777. },
  2778. allowCustomUserClass: function(a) {
  2779. this._performUserRewrite = !a
  2780. },
  2781. _saveCurrentUser: function(a) {
  2782. b.User._currentUser !== a && b.User.logOut(), a._isCurrentUser = !0, b.User._currentUser = a, b.User._currentUserMatchesDisk = !0;
  2783. var c = a.toJSON();
  2784. c._id = a.id, c._sessionToken = a._sessionToken, b.localStorage.setItem(b._getParsePath(b.User._CURRENT_USER_KEY), JSON.stringify(c))
  2785. },
  2786. _registerAuthenticationProvider: function(a) {
  2787. b.User._authProviders[a.getAuthType()] = a, b.User.current() && b.User.current()._synchronizeAuthData(a.getAuthType())
  2788. },
  2789. _logInWith: function(a, c) {
  2790. var d = b.Object._create("_User");
  2791. return d._linkWith(a, c)
  2792. }
  2793. })
  2794. }(this),
  2795. function(a) {
  2796. a.Parse = a.Parse || {};
  2797. var b = a.Parse,
  2798. c = b._;
  2799. b.Query = function(a) {
  2800. c.isString(a) && (a = b.Object._getSubclass(a)), this.objectClass = a, this.className = a.prototype.className, this._where = {}, this._include = [], this._limit = -1, this._skip = 0, this._extraOptions = {}
  2801. }, b.Query.or = function() {
  2802. var a = c.toArray(arguments),
  2803. d = null;
  2804. b._arrayEach(a, function(a) {
  2805. if (c.isNull(d) && (d = a.className), d !== a.className) throw "All queries must be for the same class"
  2806. });
  2807. var e = new b.Query(d);
  2808. return e._orQuery(a), e
  2809. }, b.Query.prototype = {
  2810. get: function(a, d) {
  2811. var e = this;
  2812. e.equalTo("objectId", a);
  2813. var f = {};
  2814. return d && c.has(d, "useMasterKey") && (f = {
  2815. useMasterKey: d.useMasterKey
  2816. }), e.first(f).then(function(a) {
  2817. if (a) return a;
  2818. var c = new b.Error(b.Error.OBJECT_NOT_FOUND, "Object not found.");
  2819. return b.Promise.error(c)
  2820. })._thenRunCallbacks(d, null)
  2821. },
  2822. toJSON: function() {
  2823. var a = {
  2824. where: this._where
  2825. };
  2826. return this._include.length > 0 && (a.include = this._include.join(",")), this._select && (a.keys = this._select.join(",")), this._limit >= 0 && (a.limit = this._limit), this._skip > 0 && (a.skip = this._skip), void 0 !== this._order && (a.order = this._order.join(",")), b._objectEach(this._extraOptions, function(b, c) {
  2827. a[c] = b
  2828. }), a
  2829. },
  2830. find: function(a) {
  2831. var d = this;
  2832. a = a || {};
  2833. var e = b._request({
  2834. route: "classes",
  2835. className: this.className,
  2836. method: "GET",
  2837. useMasterKey: a.useMasterKey,
  2838. data: this.toJSON()
  2839. });
  2840. return e.then(function(a) {
  2841. return c.map(a.results, function(c) {
  2842. var e;
  2843. return e = a.className ? new b.Object(a.className) : new d.objectClass, e._finishFetch(c, !0), e
  2844. })
  2845. })._thenRunCallbacks(a)
  2846. },
  2847. count: function(a) {
  2848. var c = this;
  2849. a = a || {};
  2850. var d = this.toJSON();
  2851. d.limit = 0, d.count = 1;
  2852. var e = b._request({
  2853. route: "classes",
  2854. className: c.className,
  2855. method: "GET",
  2856. useMasterKey: a.useMasterKey,
  2857. data: d
  2858. });
  2859. return e.then(function(a) {
  2860. return a.count
  2861. })._thenRunCallbacks(a)
  2862. },
  2863. first: function(a) {
  2864. var d = this;
  2865. a = a || {};
  2866. var e = this.toJSON();
  2867. e.limit = 1;
  2868. var f = b._request({
  2869. route: "classes",
  2870. className: this.className,
  2871. method: "GET",
  2872. useMasterKey: a.useMasterKey,
  2873. data: e
  2874. });
  2875. return f.then(function(a) {
  2876. return c.map(a.results, function(c) {
  2877. var e;
  2878. return e = a.className ? new b.Object(a.className) : new d.objectClass, e._finishFetch(c, !0), e
  2879. })[0]
  2880. })._thenRunCallbacks(a)
  2881. },
  2882. collection: function(a, d) {
  2883. return d = d || {}, new b.Collection(a, c.extend(d, {
  2884. model: this.objectClass,
  2885. query: this
  2886. }))
  2887. },
  2888. skip: function(a) {
  2889. return this._skip = a, this
  2890. },
  2891. limit: function(a) {
  2892. return this._limit = a, this
  2893. },
  2894. equalTo: function(a, d) {
  2895. return c.isUndefined(d) ? this.doesNotExist(a) : (this._where[a] = b._encode(d), this)
  2896. },
  2897. _addCondition: function(a, c, d) {
  2898. return this._where[a] || (this._where[a] = {}), this._where[a][c] = b._encode(d), this
  2899. },
  2900. notEqualTo: function(a, b) {
  2901. return this._addCondition(a, "$ne", b), this
  2902. },
  2903. lessThan: function(a, b) {
  2904. return this._addCondition(a, "$lt", b), this
  2905. },
  2906. greaterThan: function(a, b) {
  2907. return this._addCondition(a, "$gt", b), this
  2908. },
  2909. lessThanOrEqualTo: function(a, b) {
  2910. return this._addCondition(a, "$lte", b), this
  2911. },
  2912. greaterThanOrEqualTo: function(a, b) {
  2913. return this._addCondition(a, "$gte", b), this
  2914. },
  2915. containedIn: function(a, b) {
  2916. return this._addCondition(a, "$in", b), this
  2917. },
  2918. notContainedIn: function(a, b) {
  2919. return this._addCondition(a, "$nin", b), this
  2920. },
  2921. containsAll: function(a, b) {
  2922. return this._addCondition(a, "$all", b), this
  2923. },
  2924. exists: function(a) {
  2925. return this._addCondition(a, "$exists", !0), this
  2926. },
  2927. doesNotExist: function(a) {
  2928. return this._addCondition(a, "$exists", !1), this
  2929. },
  2930. matches: function(a, b, c) {
  2931. return this._addCondition(a, "$regex", b), c || (c = ""), b.ignoreCase && (c += "i"), b.multiline && (c += "m"), c && c.length && this._addCondition(a, "$options", c), this
  2932. },
  2933. matchesQuery: function(a, b) {
  2934. var c = b.toJSON();
  2935. return c.className = b.className, this._addCondition(a, "$inQuery", c), this
  2936. },
  2937. doesNotMatchQuery: function(a, b) {
  2938. var c = b.toJSON();
  2939. return c.className = b.className, this._addCondition(a, "$notInQuery", c), this
  2940. },
  2941. matchesKeyInQuery: function(a, b, c) {
  2942. var d = c.toJSON();
  2943. return d.className = c.className, this._addCondition(a, "$select", {
  2944. key: b,
  2945. query: d
  2946. }), this
  2947. },
  2948. doesNotMatchKeyInQuery: function(a, b, c) {
  2949. var d = c.toJSON();
  2950. return d.className = c.className, this._addCondition(a, "$dontSelect", {
  2951. key: b,
  2952. query: d
  2953. }), this
  2954. },
  2955. _orQuery: function(a) {
  2956. var b = c.map(a, function(a) {
  2957. return a.toJSON().where
  2958. });
  2959. return this._where.$or = b, this
  2960. },
  2961. _quote: function(a) {
  2962. return "\\Q" + a.replace("\\E", "\\E\\\\E\\Q") + "\\E"
  2963. },
  2964. contains: function(a, b) {
  2965. return this._addCondition(a, "$regex", this._quote(b)), this
  2966. },
  2967. startsWith: function(a, b) {
  2968. return this._addCondition(a, "$regex", "^" + this._quote(b)), this
  2969. },
  2970. endsWith: function(a, b) {
  2971. return this._addCondition(a, "$regex", this._quote(b) + "$"), this
  2972. },
  2973. ascending: function() {
  2974. return this._order = [], this.addAscending.apply(this, arguments)
  2975. },
  2976. addAscending: function() {
  2977. var a = this;
  2978. return this._order || (this._order = []), b._arrayEach(arguments, function(b) {
  2979. Array.isArray(b) && (b = b.join()), a._order = a._order.concat(b.replace(/\s/g, "").split(","))
  2980. }), this
  2981. },
  2982. descending: function() {
  2983. return this._order = [], this.addDescending.apply(this, arguments)
  2984. },
  2985. addDescending: function() {
  2986. var a = this;
  2987. return this._order || (this._order = []), b._arrayEach(arguments, function(b) {
  2988. Array.isArray(b) && (b = b.join()), a._order = a._order.concat(c.map(b.replace(/\s/g, "").split(","), function(a) {
  2989. return "-" + a
  2990. }))
  2991. }), this
  2992. },
  2993. near: function(a, c) {
  2994. return c instanceof b.GeoPoint || (c = new b.GeoPoint(c)), this._addCondition(a, "$nearSphere", c), this
  2995. },
  2996. withinRadians: function(a, b, c) {
  2997. return this.near(a, b), this._addCondition(a, "$maxDistance", c), this
  2998. },
  2999. withinMiles: function(a, b, c) {
  3000. return this.withinRadians(a, b, c / 3958.8)
  3001. },
  3002. withinKilometers: function(a, b, c) {
  3003. return this.withinRadians(a, b, c / 6371)
  3004. },
  3005. withinGeoBox: function(a, c, d) {
  3006. return c instanceof b.GeoPoint || (c = new b.GeoPoint(c)), d instanceof b.GeoPoint || (d = new b.GeoPoint(d)), this._addCondition(a, "$within", {
  3007. $box: [c, d]
  3008. }), this
  3009. },
  3010. include: function() {
  3011. var a = this;
  3012. return b._arrayEach(arguments, function(b) {
  3013. c.isArray(b) ? a._include = a._include.concat(b) : a._include.push(b)
  3014. }), this
  3015. },
  3016. select: function() {
  3017. var a = this;
  3018. return this._select = this._select || [], b._arrayEach(arguments, function(b) {
  3019. c.isArray(b) ? a._select = a._select.concat(b) : a._select.push(b)
  3020. }), this
  3021. },
  3022. each: function(a, d) {
  3023. if (d = d || {}, this._order || this._skip || this._limit >= 0) {
  3024. var e = "Cannot iterate on a query with sort, skip, or limit.";
  3025. return b.Promise.error(e)._thenRunCallbacks(d)
  3026. }
  3027. new b.Promise;
  3028. var f = new b.Query(this.objectClass);
  3029. f._limit = d.batchSize || 100, f._where = c.clone(this._where), f._include = c.clone(this._include), f.ascending("objectId");
  3030. var g = {};
  3031. c.has(d, "useMasterKey") && (g.useMasterKey = d.useMasterKey);
  3032. var h = !1;
  3033. return b.Promise._continueWhile(function() {
  3034. return !h
  3035. }, function() {
  3036. return f.find(g).then(function(c) {
  3037. var d = b.Promise.as();
  3038. return b._.each(c, function(b) {
  3039. d = d.then(function() {
  3040. return a(b)
  3041. })
  3042. }), d.then(function() {
  3043. c.length >= f._limit ? f.greaterThan("objectId", c[c.length - 1].id) : h = !0
  3044. })
  3045. })
  3046. })._thenRunCallbacks(d)
  3047. }
  3048. }
  3049. }(this),
  3050. function(a) {
  3051. a.Parse = a.Parse || {};
  3052. var b, c, d = a.Parse,
  3053. e = d._,
  3054. f = !1,
  3055. g = {
  3056. authenticate: function(a) {
  3057. var c = this;
  3058. FB.login(function(b) {
  3059. b.authResponse ? a.success && a.success(c, {
  3060. id: b.authResponse.userID,
  3061. access_token: b.authResponse.accessToken,
  3062. expiration_date: new Date(1e3 * b.authResponse.expiresIn + (new Date).getTime()).toJSON()
  3063. }) : a.error && a.error(c, b)
  3064. }, {
  3065. scope: b
  3066. })
  3067. },
  3068. restoreAuthentication: function(a) {
  3069. if (a) {
  3070. var b = {
  3071. userID: a.id,
  3072. accessToken: a.access_token,
  3073. expiresIn: (d._parseDate(a.expiration_date).getTime() - (new Date).getTime()) / 1e3
  3074. },
  3075. f = e.clone(c);
  3076. f.authResponse = b, f.status = !1;
  3077. var g = FB.getAuthResponse();
  3078. g && g.userID !== b.userID && FB.logout(), FB.init(f)
  3079. }
  3080. return !0
  3081. },
  3082. getAuthType: function() {
  3083. return "facebook"
  3084. },
  3085. deauthenticate: function() {
  3086. this.restoreAuthentication(null)
  3087. }
  3088. };
  3089. d.FacebookUtils = {
  3090. init: function(a) {
  3091. if ("undefined" == typeof FB) throw "The Facebook JavaScript SDK must be loaded before calling init.";
  3092. if (c = e.clone(a) || {}, c.status && "undefined" != typeof console) {
  3093. var b = console.warn || console.log || function() {};
  3094. b.call(console, "The 'status' flag passed into FB.init, when set to true, can interfere with Parse Facebook integration, so it has been suppressed. Please call FB.getLoginStatus() explicitly if you require this behavior.")
  3095. }
  3096. c.status = !1, FB.init(c), d.User._registerAuthenticationProvider(g), f = !0
  3097. },
  3098. isLinked: function(a) {
  3099. return a._isLinked("facebook")
  3100. },
  3101. logIn: function(a, c) {
  3102. if (!a || e.isString(a)) {
  3103. if (!f) throw "You must initialize FacebookUtils before calling logIn.";
  3104. return b = a, d.User._logInWith("facebook", c)
  3105. }
  3106. var g = e.clone(c) || {};
  3107. return g.authData = a, d.User._logInWith("facebook", g)
  3108. },
  3109. link: function(a, c, d) {
  3110. if (!c || e.isString(c)) {
  3111. if (!f) throw "You must initialize FacebookUtils before calling link.";
  3112. return b = c, a._linkWith("facebook", d)
  3113. }
  3114. var g = e.clone(d) || {};
  3115. return g.authData = c, a._linkWith("facebook", g)
  3116. },
  3117. unlink: function(a, b) {
  3118. if (!f) throw "You must initialize FacebookUtils before calling unlink.";
  3119. return a._unlinkFrom("facebook", b)
  3120. }
  3121. }
  3122. }(this),
  3123. function(a) {
  3124. a.Parse = a.Parse || {};
  3125. var b = a.Parse,
  3126. c = b._;
  3127. b.History = function() {
  3128. this.handlers = [], c.bindAll(this, "checkUrl")
  3129. };
  3130. var d = /^[#\/]/,
  3131. e = /msie [\w.]+/;
  3132. b.History.started = !1, c.extend(b.History.prototype, b.Events, {
  3133. interval: 50,
  3134. getHash: function(a) {
  3135. var b = a ? a.location : window.location,
  3136. c = b.href.match(/#(.*)$/);
  3137. return c ? c[1] : ""
  3138. },
  3139. getFragment: function(a, c) {
  3140. if (b._isNullOrUndefined(a))
  3141. if (this._hasPushState || c) {
  3142. a = window.location.pathname;
  3143. var e = window.location.search;
  3144. e && (a += e)
  3145. } else a = this.getHash();
  3146. return a.indexOf(this.options.root) || (a = a.substr(this.options.root.length)), a.replace(d, "")
  3147. },
  3148. start: function(a) {
  3149. if (b.History.started) throw new Error("Parse.history has already been started");
  3150. b.History.started = !0, this.options = c.extend({}, {
  3151. root: "/"
  3152. }, this.options, a), this._wantsHashChange = this.options.hashChange !== !1, this._wantsPushState = !!this.options.pushState, this._hasPushState = !!(this.options.pushState && window.history && window.history.pushState);
  3153. var f = this.getFragment(),
  3154. g = document.documentMode,
  3155. h = e.exec(navigator.userAgent.toLowerCase()) && (!g || 7 >= g);
  3156. h && (this.iframe = b.$('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow, this.navigate(f)), this._hasPushState ? b.$(window).bind("popstate", this.checkUrl) : this._wantsHashChange && "onhashchange" in window && !h ? b.$(window).bind("hashchange", this.checkUrl) : this._wantsHashChange && (this._checkUrlInterval = window.setInterval(this.checkUrl, this.interval)), this.fragment = f;
  3157. var i = window.location,
  3158. j = i.pathname === this.options.root;
  3159. return this._wantsHashChange && this._wantsPushState && !this._hasPushState && !j ? (this.fragment = this.getFragment(null, !0), window.location.replace(this.options.root + "#" + this.fragment), !0) : (this._wantsPushState && this._hasPushState && j && i.hash && (this.fragment = this.getHash().replace(d, ""), window.history.replaceState({}, document.title, i.protocol + "//" + i.host + this.options.root + this.fragment)), this.options.silent ? void 0 : this.loadUrl())
  3160. },
  3161. stop: function() {
  3162. b.$(window).unbind("popstate", this.checkUrl).unbind("hashchange", this.checkUrl), window.clearInterval(this._checkUrlInterval), b.History.started = !1
  3163. },
  3164. route: function(a, b) {
  3165. this.handlers.unshift({
  3166. route: a,
  3167. callback: b
  3168. })
  3169. },
  3170. checkUrl: function() {
  3171. var a = this.getFragment();
  3172. return a === this.fragment && this.iframe && (a = this.getFragment(this.getHash(this.iframe))), a === this.fragment ? !1 : (this.iframe && this.navigate(a), this.loadUrl() || this.loadUrl(this.getHash()), void 0)
  3173. },
  3174. loadUrl: function(a) {
  3175. var b = this.fragment = this.getFragment(a),
  3176. d = c.any(this.handlers, function(a) {
  3177. return a.route.test(b) ? (a.callback(b), !0) : void 0
  3178. });
  3179. return d
  3180. },
  3181. navigate: function(a, c) {
  3182. if (!b.History.started) return !1;
  3183. c && c !== !0 || (c = {
  3184. trigger: c
  3185. });
  3186. var e = (a || "").replace(d, "");
  3187. if (this.fragment !== e) {
  3188. if (this._hasPushState) {
  3189. 0 !== e.indexOf(this.options.root) && (e = this.options.root + e), this.fragment = e;
  3190. var f = c.replace ? "replaceState" : "pushState";
  3191. window.history[f]({}, document.title, e)
  3192. } else this._wantsHashChange ? (this.fragment = e, this._updateHash(window.location, e, c.replace), this.iframe && e !== this.getFragment(this.getHash(this.iframe)) && (c.replace || this.iframe.document.open().close(), this._updateHash(this.iframe.location, e, c.replace))) : window.location.assign(this.options.root + a);
  3193. c.trigger && this.loadUrl(a)
  3194. }
  3195. },
  3196. _updateHash: function(a, b, c) {
  3197. if (c) {
  3198. var d = a.toString().replace(/(javascript:|#).*$/, "");
  3199. a.replace(d + "#" + b)
  3200. } else a.hash = b
  3201. }
  3202. })
  3203. }(this),
  3204. function(a) {
  3205. a.Parse = a.Parse || {};
  3206. var b = a.Parse,
  3207. c = b._;
  3208. b.Router = function(a) {
  3209. a = a || {}, a.routes && (this.routes = a.routes), this._bindRoutes(), this.initialize.apply(this, arguments)
  3210. };
  3211. var d = /:\w+/g,
  3212. e = /\*\w+/g,
  3213. f = /[\-\[\]{}()+?.,\\\^\$\|#\s]/g;
  3214. c.extend(b.Router.prototype, b.Events, {
  3215. initialize: function() {},
  3216. route: function(a, d, e) {
  3217. return b.history = b.history || new b.History, c.isRegExp(a) || (a = this._routeToRegExp(a)), e || (e = this[d]), b.history.route(a, c.bind(function(c) {
  3218. var f = this._extractParameters(a, c);
  3219. e && e.apply(this, f), this.trigger.apply(this, ["route:" + d].concat(f)), b.history.trigger("route", this, d, f)
  3220. }, this)), this
  3221. },
  3222. navigate: function(a, c) {
  3223. b.history.navigate(a, c)
  3224. },
  3225. _bindRoutes: function() {
  3226. if (this.routes) {
  3227. var a = [];
  3228. for (var b in this.routes) this.routes.hasOwnProperty(b) && a.unshift([b, this.routes[b]]);
  3229. for (var c = 0, d = a.length; d > c; c++) this.route(a[c][0], a[c][1], this[a[c][1]])
  3230. }
  3231. },
  3232. _routeToRegExp: function(a) {
  3233. return a = a.replace(f, "\\$&").replace(d, "([^/]+)").replace(e, "(.*?)"), new RegExp("^" + a + "$")
  3234. },
  3235. _extractParameters: function(a, b) {
  3236. return a.exec(b).slice(1)
  3237. }
  3238. }), b.Router.extend = b._extend
  3239. }(this),
  3240. function(a) {
  3241. a.Parse = a.Parse || {};
  3242. var b = a.Parse,
  3243. c = b._;
  3244. b.Cloud = b.Cloud || {}, c.extend(b.Cloud, {
  3245. run: function(a, c, d) {
  3246. d = d || {};
  3247. var e = b._request({
  3248. route: "functions",
  3249. className: a,
  3250. method: "POST",
  3251. useMasterKey: d.useMasterKey,
  3252. data: b._encode(c, null, !0)
  3253. });
  3254. return e.then(function(a) {
  3255. return b._decode(null, a).result
  3256. })._thenRunCallbacks(d)
  3257. }
  3258. })
  3259. }(this),
  3260. function(a) {
  3261. a.Parse = a.Parse || {};
  3262. var b = a.Parse;
  3263. b.Installation = b.Object.extend("_Installation"), b.Push = b.Push || {}, b.Push.send = function(a, c) {
  3264. if (c = c || {}, a.where && (a.where = a.where.toJSON().where), a.push_time && (a.push_time = a.push_time.toJSON()), a.expiration_time && (a.expiration_time = a.expiration_time.toJSON()), a.expiration_time && a.expiration_interval) throw "Both expiration_time and expiration_interval can't be set";
  3265. var d = b._request({
  3266. route: "push",
  3267. method: "POST",
  3268. data: a,
  3269. useMasterKey: c.useMasterKey
  3270. });
  3271. return d._thenRunCallbacks(c)
  3272. }
  3273. }(this);